1 /* $Id$
2  *  Provides date format converters to and from FTN usable.
3  *
4  * HUSKYLIB: common defines, types and functions for HUSKY
5  *
6  * This is part of The HUSKY Fidonet Software project:
7  * see http://husky.sourceforge.net for details
8  *
9  *
10  * HUSKYLIB is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * HUSKYLIB is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; see file COPYING. If not, write to the
22  * Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  * See also http://www.gnu.org, license may be found here.
25  */
26 
27 #ifndef HUSKY_CVTDATE_H__
28 #define HUSKY_CVTDATE_H__
29 
30 #include "compiler.h"
31 #include "huskyext.h"  /* compiler see directory of this (cvtdate.h) file */
32 
33 #if defined(__WATCOMC__) || defined(__DJGPP__) || defined(__MSVC__)
34 /*typedef unsigned short bits;*/
35 #else
36 /*typedef unsigned bits;*/  /* AIX does not allow any modifier after unsigned */
37 #endif
38 typedef bit bits;
39 
40 /* DOS-style datestamp */
41 
42 struct _stamp
43 {
44     struct
45     {
46         bits da:5;
47         bits mo:4;
48         bits yr:7;
49     }
50     date;
51 
52     struct
53     {
54         bits ss:5;
55         bits mm:6;
56         bits hh:5;
57     }
58     time;
59 };
60 
61 struct _dos_st
62 {
63     word date;
64     word time;
65 };
66 
67 /* Union so we can access stamp as "int" or by individual components */
68 
69 union stamp_combo
70 {
71     dword ldate;
72     struct _stamp msg_st;
73     struct _dos_st dos_st;
74 };
75 
76 typedef union stamp_combo SCOMBO;
77 
78 HUSKYEXT int _fast
79               gettz(void);
80 HUSKYEXT void _fast
81               ASCII_Date_To_Binary(char *msgdate, union stamp_combo *d_written);
82 HUSKYEXT union stamp_combo *_fast
83               Get_Dos_Date(union stamp_combo *st);
84 HUSKYEXT struct tm *_fast
85               DosDate_to_TmDate(union stamp_combo *dosdate, struct tm *tmdate);
86 HUSKYEXT union stamp_combo *_fast
87               TmDate_to_DosDate(struct tm *tmdate, union stamp_combo *dosdate);
88 HUSKYEXT char *_fast
89               sc_time(union stamp_combo *sc, char *string);
90 HUSKYEXT char *_fast
91               fts_time(char *string, struct tm *tmdate);
92 
93 #endif
94