Fastest way to compare dates using two unix timestamps?
Gary Willoughby
dev at nomad.so
Fri Jul 26 12:51:39 PDT 2013
I'm writing a program that deals a lot with dates in unix
timestamp format. I need to 'normalise' this timestamp to only
give me the date and not the time. To do this i thought of using
only midnight on that day.
Here is the first attempt to normalise these dates:
protected uint trimUnixToDate(uint unixTimeStamp)
{
auto time = SysTime(unixTimeToStdTime(unixTimeStamp));
auto offset = time.dstInEffect ? 3600 : 0;
return (unixTimeStamp - (unixTimeStamp % 86400)) - offset;
}
While this works (for my timezone and DST settings) it is slow.
Is there a faster way to do this?
Or how can i compare two timestamps and only compare the date
contained within, not the time?
More information about the Digitalmars-d-learn
mailing list