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_TM_HELPER_H 10 #define LLVM_LIBC_TEST_SRC_TIME_TM_HELPER_H 11 12 #include <time.h> 13 14 #include "src/time/time_utils.h" 15 16 using __llvm_libc::time_utils::TimeConstants; 17 18 namespace __llvm_libc { 19 namespace tmhelper { 20 namespace testing { 21 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_data = temp; 36 } 37 38 } // namespace testing 39 } // namespace tmhelper 40 } // namespace __llvm_libc 41 42 #endif // LLVM_LIBC_TEST_SRC_TIME_TM_HELPER_H 43