monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] Re: cvs_import and timezones


From: Zack Weinberg
Subject: Re: [Monotone-devel] Re: cvs_import and timezones
Date: Tue, 17 Oct 2006 23:12:03 -0700

Oh, right, the test program.  Note further unlikely-but-potential
portability problems: use of putenv() and assumption that the system
has the Olson timezone database ("America/CITY" for TZ and tm_zone).

zw

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

int main(int argc, char **argv)
{
 struct tm T;
 memset(&T, 0, sizeof T);

 /* 00:00:00 on the feast of All Fools, 2006 */
 T.tm_year = 106;
 T.tm_mon = 3;
 T.tm_mday = 1;

#ifndef NO_GMTOFF
 if (argc != 2)
   return 1;
 switch (argv[1][0] - '0')
   {
   case 0: /* specify neither tm_gmtoff nor tm_zone */ break;
   case 1: T.tm_gmtoff = 57600; break;
   case 2: T.tm_zone = "America/Los_Angeles"; break;
   case 3: T.tm_gmtoff = 57600; T.tm_zone = "America/Los_Angeles"; break;
   default: return 1;
   }
#endif

 putenv("TZ=America/New_York");

 printf("%lu\n", (unsigned long) mktime(&T));
 tzset();
 printf("%lu\n", (unsigned long) mktime(&T));
 return 0;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]