Re: ctime double double check
- From: Nelu <spamahead@xxxxxxxxx>
- Date: Fri, 09 Mar 2007 14:16:19 -0500
aisling.cronin@xxxxxxxxx wrote:
On 9 Mar, 00:36, Keith Thompson <k...@xxxxxxx> wrote:<snip>
<snip>
Any program that works with specific numeric time_t values is
non-portable, perhaps needlessly so. If you really need to work with
the specific representation I described above, you should ask in a
system-specific newsgroup, perhaps comp.unix.programmer.
I am trying to create a decoder...
I started in Perl and switched to C yesterday because of my issues
with converting the time. So I apologise for all my syntax errors. I
don't program everyday so I am slightly rusty...
The initial value is '00000109744ea6d6' I was told that I should split
the data up into 2bytes, the first 2bytes are spare, the next 6bytes
are the data, each 2bytes of data the last character gets counted up
(I have no idea why? Maybe someone could explain this to me?). The
rounded up 2bytes are then concated together and convert from hex to
decimal this is how I go the value 1144412677847. I have to take it in
good faith that this is correct... Although I was told yesterday that
the value 1144412677847 is in microseconds so that would explain why I
could not fit it into time_t.
Microseconds since when? Although the standard doesn't say
anything about sub-second divisions of time an implementation may
extend the struct tm structure and possibly alter the value of a
time_t variable to take milliseconds into consideration or not.
However I couldn't find anything in the standard that specifies
how the struct tm - time_t conversions should be done which means
it's up to the implementation, which also means that it is not
portable to use time_t between different applications.
If the number you are receiving is giving you the number of
milliseconds since a fixed time in the past it's up to you to
write a conversion tool or find something to convert it for you
but you should not rely on time_t.
How do people normally store / encode / decode unix/ posix machine
time? Has anyone seen this approach and can guide me?
If you are talking portable then store the numbers as ASCII text
like: "YYYYMMDDHHMMSS[ss] or YYYY-MM-DD HH:MM:SS[.ss]" or if
other format that suits you best. I think there is a standard for
storing date as a string of characters and it may look like in
the previous examples. The advantage of storing the time like
that is that it will also sort the time correctly even as a
string. To make it even more portable you could add a timezone
identifier somewhere.
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
.
- Follow-Ups:
- Re: ctime double double check
- From: Keith Thompson
- Re: ctime double double check
- References:
- ctime double double check
- From: aisling . cronin
- Re: ctime double double check
- From: Eric Sosman
- Re: ctime double double check
- From: aisling . cronin
- Re: ctime double double check
- From: Flash Gordon
- Re: ctime double double check
- From: Keith Thompson
- Re: ctime double double check
- From: aisling . cronin
- ctime double double check
- Prev by Date: Re: Casting of void pointer returned by malloc()
- Next by Date: Re: incrementing void *
- Previous by thread: Re: ctime double double check
- Next by thread: Re: ctime double double check
- Index(es):
Relevant Pages
|