|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef prmjtime_h |
|
8 #define prmjtime_h |
|
9 |
|
10 #include <stddef.h> |
|
11 #include <stdint.h> |
|
12 |
|
13 /* |
|
14 * Broken down form of 64 bit time value. |
|
15 */ |
|
16 struct PRMJTime { |
|
17 int32_t tm_usec; /* microseconds of second (0-999999) */ |
|
18 int8_t tm_sec; /* seconds of minute (0-59) */ |
|
19 int8_t tm_min; /* minutes of hour (0-59) */ |
|
20 int8_t tm_hour; /* hour of day (0-23) */ |
|
21 int8_t tm_mday; /* day of month (1-31) */ |
|
22 int8_t tm_mon; /* month of year (0-11) */ |
|
23 int8_t tm_wday; /* 0=sunday, 1=monday, ... */ |
|
24 int32_t tm_year; /* absolute year, AD */ |
|
25 int16_t tm_yday; /* day of year (0 to 365) */ |
|
26 int8_t tm_isdst; /* non-zero if DST in effect */ |
|
27 }; |
|
28 |
|
29 /* Some handy constants */ |
|
30 #define PRMJ_USEC_PER_SEC 1000000L |
|
31 #define PRMJ_USEC_PER_MSEC 1000L |
|
32 |
|
33 /* Return the current local time in micro-seconds */ |
|
34 extern int64_t |
|
35 PRMJ_Now(void); |
|
36 |
|
37 /* Release the resources associated with PRMJ_Now; don't call PRMJ_Now again */ |
|
38 #if defined(JS_THREADSAFE) && defined(XP_WIN) |
|
39 extern void |
|
40 PRMJ_NowShutdown(void); |
|
41 #else |
|
42 #define PRMJ_NowShutdown() |
|
43 #endif |
|
44 |
|
45 /* Format a time value into a buffer. Same semantics as strftime() */ |
|
46 extern size_t |
|
47 PRMJ_FormatTime(char *buf, int buflen, const char *fmt, PRMJTime *tm); |
|
48 |
|
49 #endif /* prmjtime_h */ |