Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / test / src / time / TmHelper.h
blobd8e638d8dbaffbcb6330e7555cfdf1b1b0a63eba
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_TEST_SRC_TIME_TM_HELPER_H
10 #define LLVM_LIBC_TEST_SRC_TIME_TM_HELPER_H
12 #include <time.h>
14 #include "src/time/time_utils.h"
16 using LIBC_NAMESPACE::time_utils::TimeConstants;
18 namespace LIBC_NAMESPACE {
19 namespace tmhelper {
20 namespace testing {
22 // A helper function to initialize tm data structure.
23 static inline void initialize_tm_data(struct tm *tm_data, int year, int month,
24 int mday, int hour, int min, int sec,
25 int wday, int yday) {
26 struct tm temp = {.tm_sec = sec,
27 .tm_min = min,
28 .tm_hour = hour,
29 .tm_mday = mday,
30 .tm_mon = month - 1, // tm_mon starts with 0 for Jan
31 // years since 1900
32 .tm_year = year - TimeConstants::TIME_YEAR_BASE,
33 .tm_wday = wday,
34 .tm_yday = yday,
35 .tm_isdst = 0};
36 *tm_data = temp;
39 } // namespace testing
40 } // namespace tmhelper
41 } // namespace LIBC_NAMESPACE
43 #endif // LLVM_LIBC_TEST_SRC_TIME_TM_HELPER_H