Bell 32V development
authorTom London <tbl@research.uucp>
Wed, 13 Dec 1978 09:24:06 +0000 (04:24 -0500)
committerTom London <tbl@research.uucp>
Wed, 13 Dec 1978 09:24:06 +0000 (04:24 -0500)
Work on file usr/src/libc/gen/timezone.c

Co-Authored-By: John Reiser <jfr@research.uucp>
Synthesized-from: 32v

usr/src/libc/gen/timezone.c [new file with mode: 0644]

diff --git a/usr/src/libc/gen/timezone.c b/usr/src/libc/gen/timezone.c
new file mode 100644 (file)
index 0000000..c80ddd8
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * The arguments are the number of minutes of time
+ * you are westward from Greenwich and whether DST is in effect.
+ * It returns a string
+ * giving the name of the local timezone.
+ *
+ * Sorry, I don't know all the names.
+ */
+
+static struct zone {
+       int     offset;
+       char    *stdzone;
+       char    *dlzone;
+} zonetab[] = {
+       4*60, "AST", "ADT",             /* Atlantic */
+       5*60, "EST", "EDT",             /* Eastern */
+       6*60, "CST", "CDT",             /* Central */
+       7*60, "MST", "MDT",             /* Mountain */
+       8*60, "PST", "PDT",             /* Pacific */
+       0, "GMT", 0,                    /* Greenwich */
+       -1
+};
+
+char *timezone(zone, dst)
+{
+       register struct zone *zp;
+       static char czone[10];
+       char *sign;
+
+       for (zp=zonetab; zp->offset!=-1; zp++)
+               if (zp->offset==zone) {
+                       if (dst && zp->dlzone)
+                               return(zp->dlzone);
+                       if (!dst && zp->stdzone)
+                               return(zp->stdzone);
+               }
+       if (zone<0) {
+               zone = -zone;
+               sign = "+";
+       } else
+               sign = "-";
+       sprintf(czone, "GMT%s%d:%02d", sign, zone/60, zone%60);
+       return(czone);
+}