summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/libugly/mktime.c
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-05-14 13:47:49 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-05-14 13:47:49 +0000
commitf15aa3a552022743398a652165d76bf912c715e5 (patch)
treeb58f8b4c47fc571fbb498d83a4bd4fca226ac6c4 /mdk-stage1/dietlibc/libugly/mktime.c
parent189b01c358a1181ddc951adba97a0258d5fc2cf1 (diff)
downloaddrakx-f15aa3a552022743398a652165d76bf912c715e5.tar
drakx-f15aa3a552022743398a652165d76bf912c715e5.tar.gz
drakx-f15aa3a552022743398a652165d76bf912c715e5.tar.bz2
drakx-f15aa3a552022743398a652165d76bf912c715e5.tar.xz
drakx-f15aa3a552022743398a652165d76bf912c715e5.zip
Initial revision
Diffstat (limited to 'mdk-stage1/dietlibc/libugly/mktime.c')
-rw-r--r--mdk-stage1/dietlibc/libugly/mktime.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/mdk-stage1/dietlibc/libugly/mktime.c b/mdk-stage1/dietlibc/libugly/mktime.c
new file mode 100644
index 000000000..ee4dab6c1
--- /dev/null
+++ b/mdk-stage1/dietlibc/libugly/mktime.c
@@ -0,0 +1,21 @@
+#include <time.h>
+
+/* seconds per day */
+#define SPD 24*60*60
+
+extern unsigned int __spm[];
+
+time_t mktime(struct tm *t) {
+ time_t x=0;
+ unsigned int i;
+ if (t->tm_year<70) return (time_t)(-1);
+ for (i=70; i<t->tm_year; ++i) {
+ x+=__isleap(i+1900)?366:365;
+ }
+ t->tm_yday=__spm[t->tm_mon] + t->tm_mday-1 + ((t->tm_mon>2) && __isleap(t->tm_year)?1:0);
+ x+=t->tm_yday;
+ /* x is now the number of days since Jan 1 1970 */
+ t->tm_wday=(4+x)%7;
+ x = x*SPD + t->tm_hour*60*60 + t->tm_min*60 + t->tm_sec;
+ return x;
+}