Deleted Added
full compact
cdf_time.c (191739) cdf_time.c (192348)
1/*-
2 * Copyright (c) 2008 Christos Zoulas
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 * POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "file.h"
28
29#ifndef lint
1/*-
2 * Copyright (c) 2008 Christos Zoulas
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 * POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "file.h"
28
29#ifndef lint
30FILE_RCSID("@(#)$File: cdf_time.c,v 1.5 2009/02/03 20:27:51 christos Exp $")
30FILE_RCSID("@(#)$File: cdf_time.c,v 1.6 2009/03/10 11:44:29 christos Exp $")
31#endif
32
33#include <time.h>
34#ifdef TEST
35#include <err.h>
36#endif
37#include <string.h>
38

--- 58 unchanged lines hidden (view full) ---

97
98int
99cdf_timestamp_to_timespec(struct timespec *ts, cdf_timestamp_t t)
100{
101 struct tm tm;
102#ifdef HAVE_STRUCT_TM_TM_ZONE
103 static char UTC[] = "UTC";
104#endif
31#endif
32
33#include <time.h>
34#ifdef TEST
35#include <err.h>
36#endif
37#include <string.h>
38

--- 58 unchanged lines hidden (view full) ---

97
98int
99cdf_timestamp_to_timespec(struct timespec *ts, cdf_timestamp_t t)
100{
101 struct tm tm;
102#ifdef HAVE_STRUCT_TM_TM_ZONE
103 static char UTC[] = "UTC";
104#endif
105 int rdays;
105
106 /* Unit is 100's of nanoseconds */
107 ts->tv_nsec = (t % CDF_TIME_PREC) * 100;
108
109 t /= CDF_TIME_PREC;
110 tm.tm_sec = t % 60;
111 t /= 60;
112
113 tm.tm_min = t % 60;
114 t /= 60;
115
116 tm.tm_hour = t % 24;
117 t /= 24;
118
119 // XXX: Approx
120 tm.tm_year = CDF_BASE_YEAR + (t / 365);
121
106
107 /* Unit is 100's of nanoseconds */
108 ts->tv_nsec = (t % CDF_TIME_PREC) * 100;
109
110 t /= CDF_TIME_PREC;
111 tm.tm_sec = t % 60;
112 t /= 60;
113
114 tm.tm_min = t % 60;
115 t /= 60;
116
117 tm.tm_hour = t % 24;
118 t /= 24;
119
120 // XXX: Approx
121 tm.tm_year = CDF_BASE_YEAR + (t / 365);
122
122 int rdays = cdf_getdays(tm.tm_year);
123 rdays = cdf_getdays(tm.tm_year);
123 t -= rdays;
124 tm.tm_mday = cdf_getday(tm.tm_year, t);
125 tm.tm_mon = cdf_getmonth(tm.tm_year, t);
126 tm.tm_wday = 0;
127 tm.tm_yday = 0;
128 tm.tm_isdst = 0;
129#ifdef HAVE_STRUCT_TM_TM_GMTOFF
130 tm.tm_gmtoff = 0;

--- 52 unchanged lines hidden ---
124 t -= rdays;
125 tm.tm_mday = cdf_getday(tm.tm_year, t);
126 tm.tm_mon = cdf_getmonth(tm.tm_year, t);
127 tm.tm_wday = 0;
128 tm.tm_yday = 0;
129 tm.tm_isdst = 0;
130#ifdef HAVE_STRUCT_TM_TM_GMTOFF
131 tm.tm_gmtoff = 0;

--- 52 unchanged lines hidden ---