diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2014-10-26 12:33:50 +0400 |
commit | 47e6e7c84f008a53061e661f31ae96629bc694ef (patch) | |
tree | 648a07f3b5b9d67ce19b0fd72e8caa1175c98f1a /qa/src/xmktime.c | |
download | pcp-debian.tar.gz |
Debian 3.9.10debian/3.9.10debian
Diffstat (limited to 'qa/src/xmktime.c')
-rw-r--r-- | qa/src/xmktime.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/qa/src/xmktime.c b/qa/src/xmktime.c new file mode 100644 index 0000000..08aab4b --- /dev/null +++ b/qa/src/xmktime.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved. + */ + +#include <sys/types.h> +#include <time.h> +#include <stdio.h> +#include <pcp/pmapi.h> +#include <pcp/impl.h> + +time_t xx[] = { 8*60*60, 825042862, -1 }; + +char *tz[] = { + "EST-11EST-10,86/2:00,303/2:00", "UTC", "PST7PDT7", (char *)0 +}; + +int +main() +{ + struct tm *tmp; + struct tm mytm; + char buf[28]; + time_t ans; + int i; + int j; + int m; + + printf("standard libc routines\n"); + for (i = 0; xx[i] != -1; i++) { + tmp = localtime(&xx[i]); + ans = mktime(tmp); + printf("initial %d -> %d %s", (int)xx[i], (int)ans, ctime(&ans)); + for (m = -3; m < 4; m++) { + if (m == 0) continue; + tmp = localtime(&xx[i]); + tmp->tm_mon += m; + ans = mktime(tmp); + if (m < 0) + printf("%d months -> %d %s", m, (int)ans, ctime(&ans)); + else + printf("+%d months -> %d %s", m, (int)ans, ctime(&ans)); + } + printf("\n"); + } + + for (j = 0; tz[j] != (char *)0; j++) { + printf("pmNewZone(\"%s\")\n", tz[j]); + pmNewZone(tz[j]); + for (i = 0; xx[i] != -1; i++) { + tmp = pmLocaltime(&xx[i], &mytm); + ans = __pmMktime(tmp); + printf("initial %d -> %d %s", (int)xx[i], (int)ans, pmCtime(&ans, buf)); + for (m = -3; m < 4; m++) { + if (m == 0) continue; + tmp = pmLocaltime(&xx[i], &mytm); + tmp->tm_mon += m; + ans = __pmMktime(tmp); + if (m < 0) + printf("%d months -> %d %s", m, (int)ans, pmCtime(&ans, buf)); + else + printf("+%d months -> %d %s", m, (int)ans, pmCtime(&ans, buf)); + } + printf("\n"); + } + } + + exit(0); +} |