]> git.sur5r.net Git - cc65/commitdiff
New module time-test.c
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 12 Nov 2002 22:01:17 +0000 (22:01 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 12 Nov 2002 22:01:17 +0000 (22:01 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1505 b7a2c559-68d2-44c3-8de9-860c34a00d81

testcode/lib/files.txt
testcode/lib/time-test.c [new file with mode: 0644]

index b5195609ae064f91dfdff61cdb6c74786596a242..210d17291549e0f1c9ad292f0a3396a447348d78 100644 (file)
@@ -2,13 +2,12 @@
 Test programs for the runtime lib:
 ----------------------------------
 
+clock.c                -       test program for clock() and CLOCKS_PER_SEC
+cprintf.c      -       test program for cprintf \n and \r operators
+deb.c          -       test program for the library debugger
+div-test.c      -       test division/modulus and the div() routine
 ft.c           -       File I/O test program (open + read functions)
 getsp.s                -       Helper routine for ft.c
-
 joytest.c      -       readjoy function test program
+time-test.c     -       Test the time/mktime/gmtime/asctime functions
 
-cprintf.c      -       test program for cprintf \n and \r operators
-
-deb.c          -       test program for the library debugger
-
-clock.c                -       test program for clock() and CLOCKS_PER_SEC
diff --git a/testcode/lib/time-test.c b/testcode/lib/time-test.c
new file mode 100644 (file)
index 0000000..ab473b3
--- /dev/null
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <time.h>
+
+
+
+int main (void)
+{
+    struct tm tm;
+    time_t t;
+
+    tm.tm_sec   = 9;
+    tm.tm_min   = 34;
+    tm.tm_hour  = 21;
+    tm.tm_mday  = 12;
+    tm.tm_mon   = 10;   /* 0..11, so this is november */
+    tm.tm_year  = 102;  /* year - 1900, so this is 2002 */
+    tm.tm_wday  = 2;    /* Tuesday */
+    tm.tm_isdst = 0;
+
+    /* Convert this broken down time into a time_t and back */
+    t = mktime (&tm);
+    printf ("Test passes if the following lines are\n"
+            "identical:\n");
+    printf ("3DD173D1 - Tue Nov 12 21:34:09 2002\n");
+    printf ("%08lX - %s", t, asctime (&tm));
+    printf ("%08lX - %s", t, asctime (gmtime (&t)));
+
+    return 0;
+}
+
+
+