Initial revision
[sbcl.git] / src / runtime / time.c
1 /*
2  * time support routines that are easier to do in C than in Lisp
3  */
4
5 /*
6  * This software is part of the SBCL system. See the README file for
7  * more information.
8  *
9  * This software is derived from the CMU CL system, which was
10  * written at Carnegie Mellon University and released into the
11  * public domain. The software is in the public domain and is
12  * provided with absolutely no warranty. See the COPYING and CREDITS
13  * files for more information.
14  */
15
16 /*
17  * $Header$
18  */
19
20 #include <stdio.h>
21 #include <time.h>
22 #include "runtime.h"
23
24 void get_timezone(time_t when, int *minwest, boolean *dst)
25 {
26     struct tm ltm, gtm;
27     int mw;
28
29     ltm = *localtime(&when);
30     gtm = *gmtime(&when);
31
32     mw = ((gtm.tm_hour*60)+gtm.tm_min) - ((ltm.tm_hour*60)+ltm.tm_min);
33     if ((gtm.tm_wday + 1) % 7 == ltm.tm_wday)
34         mw -= 24*60;
35     else if (gtm.tm_wday == (ltm.tm_wday + 1) % 7)
36         mw += 24*60;
37     *minwest = mw;
38     *dst = ltm.tm_isdst;
39 }