Forum Navigation
TimeStamp.parse
Moderators:
kris
Posted: 03/17/09 14:19:31 Modified: 03/20/09 10:35:13Hey,
I've got a little problem with TimeStamp?.parse and TimeSpan?
functions. I used the following code to calculate the difference
between to times:int getTimeDifference(char[] first_timestamp, char[] last_timestamp) { auto t_in = TimeStamp.parse(first_timestamp.dup); auto t_out = TimeStamp.parse(last_timestamp.dup); auto t = t_out.span() - t_in.span(); return t.seconds(); }I run through thousands of log file lines and on some of these
lines I got wrong values by the TimeStamp? parser. Here is a output
(the first to numbers are the converted times and behind the original
chars..Output
t_in.span() t_out.span() first_timestamp last_timestamp 63348801727 63348801727 'Wed Jun 11 17:22:07 2008' - 'Wed Jun 11 17:22:07 2008' 63348800663 63348800663 'Wed Jun 11 17:04:23 2008' - 'Wed Jun 11 17:04:23 2008' 315537897599 315537897599 'Wed Jun 11 17:00:32 2008' - 'Wed Jun 11 17:00:32 2008' 63348801826 63348801847 'Wed Jun 11 17:23:46 2008' - 'Wed Jun 11 17:24:07 2008' 63348802335 63348802335 'Wed Jun 11 17:32:15 2008' - 'Wed Jun 11 17:32:15 2008' 63348803866 63348803866 'Wed Jun 11 17:57:46 2008' - 'Wed Jun 11 17:57:46 2008' 63348804450 63348804507 'Wed Jun 11 18:07:30 2008' - 'Wed Jun 11 18:08:27 2008' 315537897599 63348805511 'Wed Jun 11 18:25:00 2008' - 'Wed Jun 11 18:25:11 2008' What could be the problem, that the parser creates these strange values? [[BR]] I almost added .dup everywhere, where a char[] is involved to be sure that [[BR]] no reference is handled. Any ideas? /L