Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 16, 2004 std.date still wrong | ||||
---|---|---|---|---|
| ||||
std.date is still buggy (at least on Windows). Check this: C:\DevTools\d>type datetime.d import std.date; void main() { printf("%.*s\n", toString( getUTCtime() ) ); } C:\DevTools\d>dmd datetime.d C:\DevTools\dmd\bin\..\..\dm\bin\link.exe datetime,,,user32+kernel32/noi; C:\DevTools\d>datetime Sun May 16 21:42:51 GMT+0000 2004 C:\DevTools\d>date /t & time /t 2004-05-16 16:42 In case you don't remember, I'm on GMT-0500 (SA Pacific). ----------------------- Carlos Santander Bernal |
May 17, 2004 Re: std.date still wrong | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | On Sun, 16 May 2004 16:46:53 -0500, Carlos Santander B. wrote:
> std.date is still buggy (at least on Windows). Check this:
>
>
> C:\DevTools\d>type datetime.d
> import std.date;
>
> void main()
> {
> printf("%.*s\n", toString( getUTCtime() ) );
> }
>
> C:\DevTools\d>dmd datetime.d
> C:\DevTools\dmd\bin\..\..\dm\bin\link.exe datetime,,,user32+kernel32/noi;
>
> C:\DevTools\d>datetime
> Sun May 16 21:42:51 GMT+0000 2004
>
> C:\DevTools\d>date /t & time /t
> 2004-05-16
> 16:42
>
>
> In case you don't remember, I'm on GMT-0500 (SA Pacific).
>
> -----------------------
> Carlos Santander Bernal
funny, it works fine for me
on linux
and several times zones (including +0000)
on windows 2000
Ant
|
May 17, 2004 Re: std.date still wrong | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | "Carlos Santander B." <carlos8294@msn.com> wrote in message news:c88niq$51b$1@digitaldaemon.com... > std.date is still buggy (at least on Windows). Check this: > > > C:\DevTools\d>type datetime.d > import std.date; > > void main() > { > printf("%.*s\n", toString( getUTCtime() ) ); > } > > C:\DevTools\d>dmd datetime.d > C:\DevTools\dmd\bin\..\..\dm\bin\link.exe datetime,,,user32+kernel32/noi; > > C:\DevTools\d>datetime > Sun May 16 21:42:51 GMT+0000 2004 > > C:\DevTools\d>date /t & time /t > 2004-05-16 > 16:42 > > > In case you don't remember, I'm on GMT-0500 (SA Pacific). I don't understand what the problem is. The program prints UTC, not local time. |
May 18, 2004 Re: std.date still wrong | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <newshound@digitalmars.com> escribió en el mensaje news:c8bgfe$1ap3$2@digitaldaemon.com | "Carlos Santander B." <carlos8294@msn.com> wrote in message | news:c88niq$51b$1@digitaldaemon.com... || std.date is still buggy (at least on Windows). Check this: || || || C:\DevTools\d>type datetime.d || import std.date; || || void main() || { || printf("%.*s\n", toString( getUTCtime() ) ); || } || || C:\DevTools\d>dmd datetime.d || C:\DevTools\dmd\bin\..\..\dm\bin\link.exe datetime,,,user32+kernel32/noi; || || C:\DevTools\d>datetime || Sun May 16 21:42:51 GMT+0000 2004 || || C:\DevTools\d>date /t & time /t || 2004-05-16 || 16:42 || || || In case you don't remember, I'm on GMT-0500 (SA Pacific). | | I don't understand what the problem is. The program prints UTC, not local | time. Ok, but then how do I get to print local time? ----------------------- Carlos Santander Bernal |
May 18, 2004 Re: std.date still wrong | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | On Mon, 17 May 2004 19:35:13 -0500, Carlos Santander B. wrote: > "Walter" <newshound@digitalmars.com> escribió en el mensaje news:c8bgfe$1ap3$2@digitaldaemon.com >| "Carlos Santander B." <carlos8294@msn.com> wrote in message >| news:c88niq$51b$1@digitaldaemon.com... >|| std.date is still buggy (at least on Windows). Check this: >|| >|| >|| C:\DevTools\d>type datetime.d >|| import std.date; >|| >|| void main() >|| { >|| printf("%.*s\n", toString( getUTCtime() ) ); >|| } >|| >|| C:\DevTools\d>dmd datetime.d >|| C:\DevTools\dmd\bin\..\..\dm\bin\link.exe datetime,,,user32+kernel32/noi; >|| >|| C:\DevTools\d>datetime >|| Sun May 16 21:42:51 GMT+0000 2004 >|| >|| C:\DevTools\d>date /t & time /t >|| 2004-05-16 >|| 16:42 >|| >|| >|| In case you don't remember, I'm on GMT-0500 (SA Pacific). >| >| I don't understand what the problem is. The program prints UTC, not local >| time. > > Ok, but then how do I get to print local time? > > ----------------------- > Carlos Santander Bernal I think there is a problem here too. On my system, getUTCTime() returns the local time and NOT the UTC. Here is my test code... //------------------------- import std.date; void main() { d_time lLocalTime; d_time lUTC; lUTC = getUTCtime(); lLocalTime = UTCtoLocalTime(lUTC); printf("UTC %.*s\n", toString( lUTC ) ); printf("Local %.*s\n", toString( lLocalTime ) ); printf(">UTC %.*s\n", toString( LocalTimetoUTC(lLocalTime) )); } //------------------------ and here are the results... c:\temp>date /t & time /t Tue 18/05/2004 11:18a c:\temp>datetime UTC Tue May 18 11:18:40 GMT+1000 2004 Local Tue May 18 21:18:40 GMT+1000 2004 >UTC Tue May 18 11:18:40 GMT+1000 2004 I expected that the UTC would read as "Tue May 18 01:18:40 GMT+0000 2004" which is 10 hours behind local time. Instead the getUTCTime() function returns what looks exactly like the local time! The conversion routines, UTCtoLocalTime() and LocalTimetoUTC() seem to work okay. -- Derek 18/May/04 11:19:11 AM |
May 18, 2004 Re: std.date still wrong | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | On Mon, 17 May 2004 19:35:13 -0500, Carlos Santander B. <carlos8294@msn.com> wrote: > "Walter" <newshound@digitalmars.com> escribió en el mensaje > news:c8bgfe$1ap3$2@digitaldaemon.com > | "Carlos Santander B." <carlos8294@msn.com> wrote in message > | news:c88niq$51b$1@digitaldaemon.com... > || std.date is still buggy (at least on Windows). Check this: > || > || > || C:\DevTools\d>type datetime.d > || import std.date; > || > || void main() > || { > || printf("%.*s\n", toString( getUTCtime() ) ); > || } > || > || C:\DevTools\d>dmd datetime.d > || C:\DevTools\dmd\bin\..\..\dm\bin\link.exe datetime,,,user32+kernel32/noi; > || > || C:\DevTools\d>datetime > || Sun May 16 21:42:51 GMT+0000 2004 > || > || C:\DevTools\d>date /t & time /t > || 2004-05-16 > || 16:42 > || > || > || In case you don't remember, I'm on GMT-0500 (SA Pacific). > | > | I don't understand what the problem is. The program prints UTC, not local > | time. > > Ok, but then how do I get to print local time? This function gets/prints a local time for me. i.e. import std.date; int main () { d_time t; t = getUTCtime(); printf("%.*s\n",toString(t)); t = UTCtoLocalTime(t); printf("%.*s\n",toString(t)); t = LocalTimetoUTC(t); printf("%.*s\n",toString(t)); return 0; } Outputs: Tue May 18 13:32:05 GMT+1200 2004 Wed May 19 01:32:05 GMT+1200 2004 Tue May 18 13:32:05 GMT+1200 2004 The first and last times are correct 'localtime's whereas they are supposed to be UTC times, it gets the timezone correct, and adds it for the 'localtime' call but is adding it to an already localtime value so it gets a time 12 hours into the future. I'm in New Zealand. :) Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ |
May 18, 2004 Re: std.date still wrong | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Maybe getUTCTime() should be renamed as getLocalTime() and then define
getUTCTime() as ...
d_time getUTCTime()
{
return getLocalTime() - getLocalTZA();
}
--
Derek
18/May/04 11:39:03 AM
|
May 18, 2004 Re: std.date still wrong | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | "Regan Heath" <regan@netwin.co.nz> escribió en el mensaje news:opr759e8yn5a2sq9@digitalmars.com | This function gets/prints a local time for me. i.e. | | import std.date; | | int main () { | d_time t; | | t = getUTCtime(); | printf("%.*s\n",toString(t)); | t = UTCtoLocalTime(t); | printf("%.*s\n",toString(t)); | t = LocalTimetoUTC(t); | printf("%.*s\n",toString(t)); | return 0; | } | | Outputs: | | Tue May 18 13:32:05 GMT+1200 2004 | Wed May 19 01:32:05 GMT+1200 2004 | Tue May 18 13:32:05 GMT+1200 2004 | | The first and last times are correct 'localtime's whereas they are | supposed to be UTC times, it gets the timezone correct, and adds it for | the 'localtime' call but is adding it to an already localtime value so it | gets a time 12 hours into the future. | | I'm in New Zealand. :) | | Regan. | | -- | Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ Derek, Regan, thanks. I didn't know those functions before. ----------------------- Carlos Santander Bernal |
May 18, 2004 Re: std.date still wrong | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | On Mon, 17 May 2004 21:33:18 -0500, Carlos Santander B. <carlos8294@msn.com> wrote: > "Regan Heath" <regan@netwin.co.nz> escribió en el mensaje > news:opr759e8yn5a2sq9@digitalmars.com > | This function gets/prints a local time for me. i.e. > | > | import std.date; > | > | int main () { > | d_time t; > | > | t = getUTCtime(); > | printf("%.*s\n",toString(t)); > | t = UTCtoLocalTime(t); > | printf("%.*s\n",toString(t)); > | t = LocalTimetoUTC(t); > | printf("%.*s\n",toString(t)); > | return 0; > | } > | > | Outputs: > | > | Tue May 18 13:32:05 GMT+1200 2004 > | Wed May 19 01:32:05 GMT+1200 2004 > | Tue May 18 13:32:05 GMT+1200 2004 > | > | The first and last times are correct 'localtime's whereas they are > | supposed to be UTC times, it gets the timezone correct, and adds it for > | the 'localtime' call but is adding it to an already localtime value so it > | gets a time 12 hours into the future. > | > | I'm in New Zealand. :) > | > | Regan. > | > | -- > | Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ > > Derek, Regan, thanks. I didn't know those functions before. Have you tried DIDE, it has some phobos docs in it. I found the functions using that. http://www.atari-soldiers.com/dide.html Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ |
May 18, 2004 Re: std.date still wrong | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Regan Heath wrote: > On Mon, 17 May 2004 21:33:18 -0500, Carlos Santander B. <carlos8294@msn.com> wrote: > >> "Regan Heath" <regan@netwin.co.nz> escribió en el mensaje >> news:opr759e8yn5a2sq9@digitalmars.com >> | This function gets/prints a local time for me. i.e. >> | >> | import std.date; >> | >> | int main () { >> | d_time t; >> | >> | t = getUTCtime(); >> | printf("%.*s\n",toString(t)); >> | t = UTCtoLocalTime(t); >> | printf("%.*s\n",toString(t)); >> | t = LocalTimetoUTC(t); >> | printf("%.*s\n",toString(t)); >> | return 0; >> | } >> | >> | Outputs: >> | >> | Tue May 18 13:32:05 GMT+1200 2004 >> | Wed May 19 01:32:05 GMT+1200 2004 >> | Tue May 18 13:32:05 GMT+1200 2004 >> | >> | The first and last times are correct 'localtime's whereas they are >> | supposed to be UTC times, it gets the timezone correct, and adds it for >> | the 'localtime' call but is adding it to an already localtime value so it >> | gets a time 12 hours into the future. >> | >> | I'm in New Zealand. :) >> | >> | Regan. >> | >> | -- >> | Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ >> >> Derek, Regan, thanks. I didn't know those functions before. > > > Have you tried DIDE, it has some phobos docs in it. I found the functions using that. > http://www.atari-soldiers.com/dide.html > > Regan. > It's available online as well: http://www.digitalmars.com/d/phobos.html -- -Anderson: http://badmama.com.au/~anderson/ |
Copyright © 1999-2021 by the D Language Foundation