]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/btime.h
19July06
[bacula/bacula] / bacula / src / lib / btime.h
1
2 /*
3
4   See btime.c for defintions.
5
6      Version $Id$
7
8  */
9 /*
10    Copyright (C) 2000-2006 Kern Sibbald
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License
14    version 2 as amended with additional clauses defined in the
15    file LICENSE in the main source directory.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
20    the file LICENSE for additional details.
21
22  */
23
24
25 #ifndef __btime_INCLUDED
26 #define __btime_INCLUDED
27
28 /* New btime definition -- use this */
29 btime_t get_current_btime(void);
30 time_t btime_to_unix(btime_t bt);   /* bacula time to epoch time */
31 utime_t btime_to_utime(btime_t bt); /* bacula time to utime_t */
32
33 int tm_wom(int mday, int wday);
34 int tm_woy(time_t stime);
35
36 char *bstrutime(char *dt, int maxlen, utime_t tim);
37 char *bstrftime(char *dt, int maxlen, utime_t tim);
38 char *bstrftimes(char *dt, int maxlen, utime_t tim);
39 char *bstrftime_ny(char *dt, int maxlen, utime_t tim);
40 char *bstrftime_nc(char *dt, int maxlen, utime_t tim);
41 utime_t str_to_utime(char *str);
42
43
44 /* =========================================================== */
45 /*        old code deprecated below. Do not use.               */
46
47 typedef float64_t fdate_t;             /* Date type */
48 typedef float64_t ftime_t;             /* Time type */
49
50 struct date_time {
51     fdate_t julian_day_number;         /* Julian day number */
52     ftime_t julian_day_fraction;       /* Julian day fraction */
53 };
54
55 /*  In arguments and results of the following functions,
56     quantities are expressed as follows.
57
58         year    Year in the Common Era.  The canonical
59                 date of adoption of the Gregorian calendar
60                 (October 5, 1582 in the Julian calendar)
61                 is assumed.
62
63         month   Month index with January 0, December 11.
64
65         day     Day number of month, 1 to 31.
66
67 */
68
69
70 extern fdate_t date_encode(uint32_t year, uint8_t month, uint8_t day);
71 extern ftime_t time_encode(uint8_t hour, uint8_t minute, uint8_t second,
72                           float32_t second_fraction);
73 extern void date_time_encode(struct date_time *dt,
74                              uint32_t year, uint8_t month, uint8_t day,
75                              uint8_t hour, uint8_t minute, uint8_t second,
76                              float32_t second_fraction);
77
78 extern void date_decode(fdate_t date, uint32_t *year, uint8_t *month,
79                         uint8_t *day);
80 extern void time_decode(ftime_t time, uint8_t *hour, uint8_t *minute,
81                         uint8_t *second, float32_t *second_fraction);
82 extern void date_time_decode(struct date_time *dt,
83                              uint32_t *year, uint8_t *month, uint8_t *day,
84                              uint8_t *hour, uint8_t *minute, uint8_t *second,
85                              float32_t *second_fraction);
86
87 extern int date_time_compare(struct date_time *dt1, struct date_time *dt2);
88
89 extern void tm_encode(struct date_time *dt, struct tm *tm);
90 extern void tm_decode(struct date_time *dt, struct tm *tm);
91 extern void get_current_time(struct date_time *dt);
92
93
94 #endif /* __btime_INCLUDED */