]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/btime.h
Change copyright as per agreement with FSFE
[bacula/bacula] / bacula / src / lib / btime.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2016 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    This notice must be preserved when any source code is 
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19
20 /*
21  * See btime.c for defintions.
22  *  Kern Sibbald, MM
23  */
24
25
26 #ifndef __btime_INCLUDED
27 #define __btime_INCLUDED
28
29 /* New btime definition -- use this */
30 btime_t get_current_btime(void);
31 time_t btime_to_unix(btime_t bt);   /* bacula time to epoch time */
32 utime_t btime_to_utime(btime_t bt); /* bacula time to utime_t */
33
34 int tm_wom(int mday, int wday);
35 int tm_woy(time_t stime);
36 int tm_ldom(int month, int year);
37
38 char *bstrutime(char *dt, int maxlen, utime_t tim);
39 char *bstrftime(char *dt, int maxlen, utime_t tim);
40 char *bstrftimes(char *dt, int maxlen, utime_t tim);
41 char *bstrftime_ny(char *dt, int maxlen, utime_t tim);
42 char *bstrftime_nc(char *dt, int maxlen, utime_t tim);
43 char *bstrftime_dn(char *dt, int maxlen, utime_t tim);
44 utime_t str_to_utime(char *str);
45
46
47 /* =========================================================== */
48 /*        old code deprecated below. Do not use.               */
49
50 typedef float64_t fdate_t;             /* Date type */
51 typedef float64_t ftime_t;             /* Time type */
52
53 struct date_time {
54     fdate_t julian_day_number;         /* Julian day number */
55     ftime_t julian_day_fraction;       /* Julian day fraction */
56 };
57
58 /*  In arguments and results of the following functions,
59     quantities are expressed as follows.
60
61         year    Year in the Common Era.  The canonical
62                 date of adoption of the Gregorian calendar
63                 (October 5, 1582 in the Julian calendar)
64                 is assumed.
65
66         month   Month index with January 0, December 11.
67
68         day     Day number of month, 1 to 31.
69
70 */
71
72
73 extern fdate_t date_encode(uint32_t year, uint8_t month, uint8_t day);
74 extern ftime_t time_encode(uint8_t hour, uint8_t minute, uint8_t second,
75                           float32_t second_fraction);
76 extern void date_time_encode(struct date_time *dt,
77                              uint32_t year, uint8_t month, uint8_t day,
78                              uint8_t hour, uint8_t minute, uint8_t second,
79                              float32_t second_fraction);
80
81 extern void date_decode(fdate_t date, uint32_t *year, uint8_t *month,
82                         uint8_t *day);
83 extern void time_decode(ftime_t time, uint8_t *hour, uint8_t *minute,
84                         uint8_t *second, float32_t *second_fraction);
85 extern void date_time_decode(struct date_time *dt,
86                              uint32_t *year, uint8_t *month, uint8_t *day,
87                              uint8_t *hour, uint8_t *minute, uint8_t *second,
88                              float32_t *second_fraction);
89
90 extern int date_time_compare(struct date_time *dt1, struct date_time *dt2);
91
92 extern void tm_encode(struct date_time *dt, struct tm *tm);
93 extern void tm_decode(struct date_time *dt, struct tm *tm);
94 extern void get_current_time(struct date_time *dt);
95
96
97 #endif /* __btime_INCLUDED */