Warning: This file is not a C or C++ file. It does not have highlighting.
1 | //===---- TmHelper.h ------------------------------------------*- C++ -*-===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLVM_LIBC_TEST_SRC_TIME_TMHELPER_H |
10 | #define LLVM_LIBC_TEST_SRC_TIME_TMHELPER_H |
11 | |
12 | #include "hdr/types/struct_tm.h" |
13 | #include "src/__support/macros/config.h" |
14 | #include "src/time/time_constants.h" |
15 | |
16 | namespace LIBC_NAMESPACE_DECL { |
17 | namespace tmhelper { |
18 | namespace testing { |
19 | |
20 | // A helper function to initialize tm data structure. |
21 | static inline void initialize_tm_data(struct tm *tm_data, int year, int month, |
22 | int mday, int hour, int min, int sec, |
23 | int wday, int yday) { |
24 | struct tm temp = {.tm_sec = sec, |
25 | .tm_min = min, |
26 | .tm_hour = hour, |
27 | .tm_mday = mday, |
28 | .tm_mon = month - 1, // tm_mon starts with 0 for Jan |
29 | // years since 1900 |
30 | .tm_year = year - time_constants::TIME_YEAR_BASE, |
31 | .tm_wday = wday, |
32 | .tm_yday = yday, |
33 | .tm_isdst = 0}; |
34 | *tm_data = temp; |
35 | } |
36 | |
37 | } // namespace testing |
38 | } // namespace tmhelper |
39 | } // namespace LIBC_NAMESPACE_DECL |
40 | |
41 | #endif // LLVM_LIBC_TEST_SRC_TIME_TMHELPER_H |
42 |
Warning: This file is not a C or C++ file. It does not have highlighting.