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