Debian Codegraph @

intl/components/src/calendar/ISODate.h

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #ifndef intl_components_calendar_ISODate_h_
5 #define intl_components_calendar_ISODate_h_
6
7 #include "mozilla/intl/calendar/MonthCode.h"
8
9 #include <stdint.h>
10
11 namespace mozilla::intl::calendar {
12
13 struct ISODate final {
14 int32_t year = 0;
15 int32_t month = 0;
16 int32_t day = 0;
17 };
18
19 struct CalendarDate final {
20 int32_t year = 0;
21 MonthCode monthCode = {};
22 int32_t day = 0;
23 };
24
25 inline int32_t FloorDiv(int32_t dividend, int32_t divisor) {
26 int32_t quotient = dividend / divisor;
27 int32_t remainder = dividend % divisor;
28 if (remainder < 0) {
29 quotient -= 1;
30 }
31 return quotient;
32 }
33
34 /**
35 * Return the day relative to the Unix epoch, January 1 1970.
36 */
37 int32_t MakeDay(const ISODate& date);
38
39 } // namespace mozilla::intl::calendar
40
41 #endif