test.c 538 B

123456789101112131415161718192021
  1. /* Testing localtime functionality */
  2. #include "localtime.c"
  3. #include <sys/time.h>
  4. #include <stdio.h>
  5. int main(int argc, char **argv) {
  6. struct timeval tv;
  7. struct tm tm;
  8. char *zone[4] = { "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles" };
  9. int i;
  10. gettimeofday(&tv,NULL);
  11. for (i=0;i<4;i++) {
  12. ast_localtime(&tv.tv_sec,&tm,zone[i]);
  13. printf("Localtime at %s is %04d/%02d/%02d %02d:%02d:%02d\n",zone[i],tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  14. }
  15. return 0;
  16. }