| 1 | /* $Id: 625main.c 1334 2004-04-05 19:45:58Z bird $
|
|---|
| 2 | *
|
|---|
| 3 | * TZ (tzset++) testcase.
|
|---|
| 4 | *
|
|---|
| 5 | * InnoTek Systemberatung GmbH confidential
|
|---|
| 6 | *
|
|---|
| 7 | * Copyright (c) 2003 InnoTek Systemberatung GmbH
|
|---|
| 8 | * Author: knut st. osmundsen <[email protected]>
|
|---|
| 9 | *
|
|---|
| 10 | * All Rights Reserved
|
|---|
| 11 | *
|
|---|
| 12 | */
|
|---|
| 13 | #include <time.h>
|
|---|
| 14 | #include <stdio.h>
|
|---|
| 15 | #include <stdlib.h>
|
|---|
| 16 | #include <string.h>
|
|---|
| 17 |
|
|---|
| 18 | static struct times
|
|---|
| 19 | {
|
|---|
| 20 | time_t time;
|
|---|
| 21 | } aTimes[7] =
|
|---|
| 22 | {
|
|---|
| 23 | 0, /* 1970-01-01 00:00:00 */
|
|---|
| 24 | 13046400, /* 1970-06-01 00:00:00 */
|
|---|
| 25 | -(10*365+3-31-29)*24*3600 - 12*3600, /* 1960-03-01 12:00:00 */
|
|---|
| 26 | -0x7fffffff + (365*24*60*60), /* 1901-12-14 20:45:52 */
|
|---|
| 27 | 0x7fffffff - (24*60*60), /* 2038-01-18 03:14:07 */
|
|---|
| 28 | 31*365*24*3600 + 132, /* 2000-12-23 16:01:12 */
|
|---|
| 29 | (33*365 + 172)*24*3600 + 132, /* 2000-12-23 16:01:12 */
|
|---|
| 30 | };
|
|---|
| 31 |
|
|---|
| 32 | static struct testcase
|
|---|
| 33 | {
|
|---|
| 34 | const char *pszTZ;
|
|---|
| 35 | const char *pszTZRes;
|
|---|
| 36 | const char *apszRes[9];
|
|---|
| 37 | } aTests[] =
|
|---|
| 38 | {
|
|---|
| 39 | {
|
|---|
| 40 | "TZ=PST8",
|
|---|
| 41 | "timezone=28800 daylight=0 tzname='PST','",
|
|---|
| 42 | {
|
|---|
| 43 | "1969-12-31 16:00:00 3 364 not-dst(0)",
|
|---|
| 44 | "1970-05-31 16:00:00 0 150 not-dst(0)",
|
|---|
| 45 | "1960-02-29 04:00:00 1 59 not-dst(0)",
|
|---|
| 46 | "1902-12-13 12:45:53 6 346 not-dst(0)",
|
|---|
| 47 | "2038-01-17 19:14:07 0 16 not-dst(0)",
|
|---|
| 48 | "2000-12-23 16:02:12 6 357 not-dst(0)",
|
|---|
| 49 | "2003-06-13 16:02:12 5 163 not-dst(0)",
|
|---|
| 50 | }
|
|---|
| 51 | },
|
|---|
| 52 | {
|
|---|
| 53 | "TZ=UCT0",
|
|---|
| 54 | "timezone=0 daylight=0 tzname='UCT','",
|
|---|
| 55 | {
|
|---|
| 56 | "1970-01-01 00:00:00 4 0 not-dst(0)",
|
|---|
| 57 | "1970-06-01 00:00:00 1 151 not-dst(0)",
|
|---|
| 58 | "1960-02-29 12:00:00 1 59 not-dst(0)",
|
|---|
| 59 | "1902-12-13 20:45:53 6 346 not-dst(0)",
|
|---|
| 60 | "2038-01-18 03:14:07 1 17 not-dst(0)",
|
|---|
| 61 | "2000-12-24 00:02:12 0 358 not-dst(0)",
|
|---|
| 62 | "2003-06-14 00:02:12 6 164 not-dst(0)",
|
|---|
| 63 | }
|
|---|
| 64 | },
|
|---|
| 65 | {
|
|---|
| 66 | "TZ=PST8PDT",
|
|---|
| 67 | "timezone=28800 daylight=1 tzname='PST','PDT'",
|
|---|
| 68 | {
|
|---|
| 69 | "1969-12-31 16:00:00 3 364 not-dst(0)",
|
|---|
| 70 | "1970-05-31 17:00:00 0 150 dst(1)",
|
|---|
| 71 | "1960-02-29 04:00:00 1 59 not-dst(0)",
|
|---|
| 72 | "1902-12-13 12:45:53 6 346 not-dst(0)",
|
|---|
| 73 | "2038-01-17 19:14:07 0 16 not-dst(0)",
|
|---|
| 74 | "2000-12-23 16:02:12 6 357 not-dst(0)",
|
|---|
| 75 | "2003-06-13 17:02:12 5 163 dst(1)",
|
|---|
| 76 | }
|
|---|
| 77 | },
|
|---|
| 78 | {
|
|---|
| 79 | "TZ=CET-1CDT",
|
|---|
| 80 | "timezone=-3600 daylight=1 tzname='CET','CDT'",
|
|---|
| 81 | {
|
|---|
| 82 | "1970-01-01 01:00:00 4 0 not-dst(0)",
|
|---|
| 83 | "1970-06-01 02:00:00 1 151 dst(1)",
|
|---|
| 84 | "1960-02-29 13:00:00 1 59 not-dst(0)",
|
|---|
| 85 | "1902-12-13 21:45:53 6 346 not-dst(0)",
|
|---|
| 86 | "2038-01-18 04:14:07 1 17 not-dst(0)",
|
|---|
| 87 | "2000-12-24 01:02:12 0 358 not-dst(0)",
|
|---|
| 88 | "2003-06-14 02:02:12 6 164 dst(1)",
|
|---|
| 89 | }
|
|---|
| 90 | },
|
|---|
| 91 | {
|
|---|
| 92 | #ifndef UNIX_TZ
|
|---|
| 93 | "TZ=CET-1CEDT,3,-1,0,7200,10,-1,0,10800,3600",
|
|---|
| 94 | #else
|
|---|
|
|---|