Thread overview | |||||
---|---|---|---|---|---|
|
April 20, 2007 convert d_time to Date without timezone conversion? | ||||
---|---|---|---|---|
| ||||
I want to read Unix time stamps from a file and convert them to a human readable date. However, I want to leave them in UTC. Is there a D function that just returns the d_time string AS-IS without the UTC -> local timezone conversion? for example: d_time dtime = rndtol(unixtime * TicksPerSecond); // convert Unix timestamp char[] time = toTimeString(dtime); // WRONG! converts UTC to local time zone I am not sure about the other string conversion functions like YearFromTime, etc. but I suspect they are doing time zone conversions also. |
April 20, 2007 Re: convert d_time to Date without timezone conversion? | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Finlayson | David Finlayson schrieb:
> I want to read Unix time stamps from a file and convert them to a human readable date. However, I want to leave them in UTC. Is there a D function that just returns the d_time string AS-IS without the UTC -> local timezone conversion?
>
> for example:
>
> d_time dtime = rndtol(unixtime * TicksPerSecond); // convert Unix timestamp
> char[] time = toTimeString(dtime); // WRONG! converts UTC to local time zone
>
> I am not sure about the other string conversion functions like YearFromTime, etc. but I suspect they are doing time zone conversions also.
>
>
char[] toUTCString(d_time t) ?
(see in your local dmd\src\phobos\std\date.d that it adds no local offset)
david
|
April 22, 2007 Re: convert d_time to Date without timezone conversion? | ||||
---|---|---|---|---|
| ||||
Posted in reply to david | Thanks, I'll take another look. I was confused by the documentation and forgot that I can peek under the hood.
David
david Wrote:
> David Finlayson schrieb:
> > I want to read Unix time stamps from a file and convert them to a human readable date. However, I want to leave them in UTC. Is there a D function that just returns the d_time string AS-IS without the UTC -> local timezone conversion?
> >
> > for example:
> >
> > d_time dtime = rndtol(unixtime * TicksPerSecond); // convert Unix timestamp
> > char[] time = toTimeString(dtime); // WRONG! converts UTC to local time zone
> >
> > I am not sure about the other string conversion functions like YearFromTime, etc. but I suspect they are doing time zone conversions also.
> >
> >
>
> char[] toUTCString(d_time t) ?
>
> (see in your local dmd\src\phobos\std\date.d that it adds no local offset)
>
> david
|
Copyright © 1999-2021 by the D Language Foundation