how to migrate to std.datetime

Adam D. Ruppe destructionator at gmail.com
Sun May 8 17:46:38 PDT 2011


I decided to update my compiler today, and regret it for a lot of
reasons, but meh.

One of the things is std.datetime. A lot of my code uses std.date. It
works very, very well for me and I like it.

But, the compile process is nagging me about it. I want it to shut up.


However, I'm not even sure where to start with std.datetime...

Which one of it's functions does the same as std.date.getUTCtime()?

It looks like sysTimeToDTime is almost sorta kinda related, but it's
got that same ugly deprecation text.

sysTimeToDTime(Clock.currTime(UTC())); // best we can do?


Note that it's important to me that the numbers match up - I have
some stored and comparisons need to work the same way.

What about std.date.toUTCString()? There's a lot of toBlahString
in there, but none seem to match up.

Another thing it's bitching at me about is std.file.lastModifed. I
just want to check the file's age. With the old function, this is
simple subtraction. How can I ask the new system "is this file
greater than 8 hours old?"


Last question: my app handles timezones on it's own by means of
addition and subtraction of offsets against the getUTCtime() result.
(it's a web app that fetches the offset from javascript so the server
knows what the user's local time is relative to it's internal
representation).

std.date was pretty timezone agnostic.

It looks like the DateTime doesn't mess around with them, so as
long as I always ask for things in UTC, shouldn't be a problem, right?


There's some more, but I think I can make the rest work with
DateTimes by multiplying the numbers before input.


More information about the Digitalmars-d-learn mailing list