1. RE: datetime.e

i just tried a little program in C. here's the source:

#include <time.h>
#include <stdlib.h>
#include <stdio.h>

int main (int argc,char **argv) {
  struct tm *t;
  long thetime;
  if (argc==1) return 0;
  thetime=strtoul(argv[1],'\0',10);
  t=localtime(&thetime);
  printf("%d/%d/%d %d:%02d:%02d\n",t->tm_mon+1,t->tm_mday,t->tm_year,
                                   t->tm_hour,t->tm_min,t->tm_sec);
  return 0;
}

oddly enough, when you run it with the argument 0, it prints "1/1/1969 
19:00:00". call me crazy, but doesn't that sound like new year's day 
1969, 9 PM? either something is wrong with my linux box, or something is 
wrong with the docs where you got the exact date of the epoch

euphoria at carlw.legend.uk.com wrote:
> sephiroth _ wrote:
> Odd. Is it the same number of _seconds_ that it is incorrect by each 
> time or
> does it vary? It may well be that I've misjudged where the 1970 epoch 
> lies -
> I use 1970-1-1 0:00:00am - can someone confirm or deny this is the right
> date/time?

new topic     » topic index » view message » categorize

2. RE: datetime.e

tiny correction, it really prints 12/31/1969. and it does the same thing 
in windows, too

new topic     » goto parent     » topic index » view message » categorize

3. RE: datetime.e

>===== Original Message From sephiroth _ <euman2376 at yahoo.com> =====
>
>i just tried a little program in C. here's the source:
>
>#include <time.h>
>#include <stdlib.h>
>#include <stdio.h>
>
>int main (int argc,char **argv) {
>  struct tm *t;
>  long thetime;
>  if (argc==1) return 0;
>  thetime=strtoul(argv[1],'\0',10);
>  t=localtime(&thetime);
>  printf("%d/%d/%d %d:%02d:%02d\n",t->tm_mon+1,t->tm_mday,t->tm_year,
>                                   t->tm_hour,t->tm_min,t->tm_sec);
>  return 0;
>}
>
>oddly enough, when you run it with the argument 0, it prints "1/1/1969
>19:00:00". call me crazy, but doesn't that sound like new year's day
>1969, 9 PM? either something is wrong with my linux box, or something is
>wrong with the docs where you got the exact date of the epoch

Hi,

I compiled up this C program on HP-UX 10.20 and ran it with an argument of 0 
and got:

    1/1/70 0:00:00

But they I did this:

    TZ=EST5
    export TZ

and re-ran the program and got:

    12/31/69 19:00:00

I then tried:

    TZ=PDT7
    export TZ

and got:

    12/31/69 17:00:00

Finally setting back to:

    TZ=GMT0
    export TZ

gives:

    1/1/70 0:00:00

so the C program is getting the localtime by using the TZ (time zone) 
environment variable - does this explain the anomoly?  Can you try a similar 
test on Windows?

Regards,

FP.

new topic     » goto parent     » topic index » view message » categorize

4. RE: datetime.e

it could be added to windows and linux, but in DOS it's completely 
oblivious to time zones. the only kind of time correction it uses is 
daylight savings time. oh well...nobody really uses DOS anymore anyway 
:) well, i do, but i guess if robert does add this stuff i'll be using 
that slow windows console a lot more ;)

euphoria at carlw.legend.uk.com wrote:
> The downside is that there's no built-in facility for getting the 
> current
> timezone and daylight savings in Euphoria, so I can't add features to 
> the
> library to support it. :(

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu