]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/btime.h
Convert to pure GPL v2 license.
[bacula/bacula] / bacula / src / lib / btime.h
1
2 /*
3
4   See btime.c for defintions.
5
6      Version $Id$
7
8  */
9 /*
10    Bacula® - The Network Backup Solution
11
12    Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
13
14    The main author of Bacula is Kern Sibbald, with contributions from
15    many others, a complete list can be found in the file AUTHORS.
16    This program is Free Software; you can redistribute it and/or
17    modify it under the terms of version two of the GNU General Public
18    License as published by the Free Software Foundation and included
19    in the file LICENSE.
20
21    This program is distributed in the hope that it will be useful, but
22    WITHOUT ANY WARRANTY; without even the implied warranty of
23    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24    General Public License for more details.
25
26    You should have received a copy of the GNU General Public License
27    along with this program; if not, write to the Free Software
28    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29    02110-1301, USA.
30
31    Bacula® is a registered trademark of John Walker.
32    The licensor of Bacula is the Free Software Foundation Europe
33    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
34    Switzerland, email:ftf@fsfeurope.org.
35 */
36
37
38 #ifndef __btime_INCLUDED
39 #define __btime_INCLUDED
40
41 /* New btime definition -- use this */
42 btime_t get_current_btime(void);
43 time_t btime_to_unix(btime_t bt);   /* bacula time to epoch time */
44 utime_t btime_to_utime(btime_t bt); /* bacula time to utime_t */
45
46 int tm_wom(int mday, int wday);
47 int tm_woy(time_t stime);
48
49 char *bstrutime(char *dt, int maxlen, utime_t tim);
50 char *bstrftime(char *dt, int maxlen, utime_t tim);
51 char *bstrftimes(char *dt, int maxlen, utime_t tim);
52 char *bstrftime_ny(char *dt, int maxlen, utime_t tim);
53 char *bstrftime_nc(char *dt, int maxlen, utime_t tim);
54 utime_t str_to_utime(char *str);
55
56
57 /* =========================================================== */
58 /*        old code deprecated below. Do not use.               */
59
60 typedef float64_t fdate_t;             /* Date type */
61 typedef float64_t ftime_t;             /* Time type */
62
63 struct date_time {
64     fdate_t julian_day_number;         /* Julian day number */
65     ftime_t julian_day_fraction;       /* Julian day fraction */
66 };
67
68 /*  In arguments and results of the following functions,
69     quantities are expressed as follows.
70
71         year    Year in the Common Era.  The canonical
72                 date of adoption of the Gregorian calendar
73                 (October 5, 1582 in the Julian calendar)
74                 is assumed.
75
76         month   Month index with January 0, December 11.
77
78         day     Day number of month, 1 to 31.
79
80 */
81
82
83 extern fdate_t date_encode(uint32_t year, uint8_t month, uint8_t day);
84 extern ftime_t time_encode(uint8_t hour, uint8_t minute, uint8_t second,
85                           float32_t second_fraction);
86 extern void date_time_encode(struct date_time *dt,
87                              uint32_t year, uint8_t month, uint8_t day,
88                              uint8_t hour, uint8_t minute, uint8_t second,
89                              float32_t second_fraction);
90
91 extern void date_decode(fdate_t date, uint32_t *year, uint8_t *month,
92                         uint8_t *day);
93 extern void time_decode(ftime_t time, uint8_t *hour, uint8_t *minute,
94                         uint8_t *second, float32_t *second_fraction);
95 extern void date_time_decode(struct date_time *dt,
96                              uint32_t *year, uint8_t *month, uint8_t *day,
97                              uint8_t *hour, uint8_t *minute, uint8_t *second,
98                              float32_t *second_fraction);
99
100 extern int date_time_compare(struct date_time *dt1, struct date_time *dt2);
101
102 extern void tm_encode(struct date_time *dt, struct tm *tm);
103 extern void tm_decode(struct date_time *dt, struct tm *tm);
104 extern void get_current_time(struct date_time *dt);
105
106
107 #endif /* __btime_INCLUDED */