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?

Reply via email to