1f9f848faSopenharmony_ci/* 2f9f848faSopenharmony_ci * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved. 3f9f848faSopenharmony_ci * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved. 4f9f848faSopenharmony_ci * 5f9f848faSopenharmony_ci * Redistribution and use in source and binary forms, with or without modification, 6f9f848faSopenharmony_ci * are permitted provided that the following conditions are met: 7f9f848faSopenharmony_ci * 8f9f848faSopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, this list of 9f9f848faSopenharmony_ci * conditions and the following disclaimer. 10f9f848faSopenharmony_ci * 11f9f848faSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, this list 12f9f848faSopenharmony_ci * of conditions and the following disclaimer in the documentation and/or other materials 13f9f848faSopenharmony_ci * provided with the distribution. 14f9f848faSopenharmony_ci * 15f9f848faSopenharmony_ci * 3. Neither the name of the copyright holder nor the names of its contributors may be used 16f9f848faSopenharmony_ci * to endorse or promote products derived from this software without specific prior written 17f9f848faSopenharmony_ci * permission. 18f9f848faSopenharmony_ci * 19f9f848faSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20f9f848faSopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21f9f848faSopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22f9f848faSopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23f9f848faSopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24f9f848faSopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25f9f848faSopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26f9f848faSopenharmony_ci * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27f9f848faSopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28f9f848faSopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29f9f848faSopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30f9f848faSopenharmony_ci */ 31f9f848faSopenharmony_ci 32f9f848faSopenharmony_ci#ifndef __LINUX_TZDST_H__ 33f9f848faSopenharmony_ci#define __LINUX_TZDST_H__ 34f9f848faSopenharmony_ci 35f9f848faSopenharmony_ci#include "time.h" 36f9f848faSopenharmony_ci 37f9f848faSopenharmony_ci#ifdef __cplusplus 38f9f848faSopenharmony_ciextern "C" { 39f9f848faSopenharmony_ci#endif 40f9f848faSopenharmony_ci 41f9f848faSopenharmony_ci#ifdef __LITEOS__ 42f9f848faSopenharmony_ci 43f9f848faSopenharmony_ci#define SECSPERMIN 60 44f9f848faSopenharmony_ci#define MINSPERHOUR 60 45f9f848faSopenharmony_ci#define HOURSPERDAY 24 46f9f848faSopenharmony_ci#define DAYSPERWEEK 7 47f9f848faSopenharmony_ci#define DAYSPERNYEAR 365 48f9f848faSopenharmony_ci#define DAYSPERLYEAR 366 49f9f848faSopenharmony_ci#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) 50f9f848faSopenharmony_ci#define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY) 51f9f848faSopenharmony_ci#define MONSPERYEAR 12 52f9f848faSopenharmony_ci 53f9f848faSopenharmony_ci#define TM_YEAR_BASE 1900 54f9f848faSopenharmony_ci 55f9f848faSopenharmony_ci#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) 56f9f848faSopenharmony_ci 57f9f848faSopenharmony_ci/** 58f9f848faSopenharmony_ci * @ingroup localtime 59f9f848faSopenharmony_ci * @brief Set Time Zone. 60f9f848faSopenharmony_ci * 61f9f848faSopenharmony_ci * @par Description: 62f9f848faSopenharmony_ci * This API is used to set the time zone. 63f9f848faSopenharmony_ci * 64f9f848faSopenharmony_ci * @attention 65f9f848faSopenharmony_ci * <ul> 66f9f848faSopenharmony_ci * <li>When setting time zones, format is required to be "tzn[+/-]hh[:mm[:ss]][dzn]" .</li> 67f9f848faSopenharmony_ci * </ul> 68f9f848faSopenharmony_ci * 69f9f848faSopenharmony_ci * @param buff The string point to the time zone going to be setting. 70f9f848faSopenharmony_ci * 71f9f848faSopenharmony_ci * @retval None 72f9f848faSopenharmony_ci */ 73f9f848faSopenharmony_civoid settimezone(const char *); 74f9f848faSopenharmony_ci 75f9f848faSopenharmony_ci/** 76f9f848faSopenharmony_ci * @ingroup localtime 77f9f848faSopenharmony_ci * @brief Disable daylight saving time. 78f9f848faSopenharmony_ci * 79f9f848faSopenharmony_ci * @par Description: 80f9f848faSopenharmony_ci * This API is used to make daylight saving time useless. 81f9f848faSopenharmony_ci * 82f9f848faSopenharmony_ci * @param None. 83f9f848faSopenharmony_ci * 84f9f848faSopenharmony_ci * @retval None 85f9f848faSopenharmony_ci */ 86f9f848faSopenharmony_ciint dst_disable(void); 87f9f848faSopenharmony_ci 88f9f848faSopenharmony_ci/** 89f9f848faSopenharmony_ci * @ingroup localtime 90f9f848faSopenharmony_ci * @brief Enable daylight saving time.. 91f9f848faSopenharmony_ci * 92f9f848faSopenharmony_ci * @par Description: 93f9f848faSopenharmony_ci * This API is used to configure daylight saving time. 94f9f848faSopenharmony_ci * 95f9f848faSopenharmony_ci * @attention 96f9f848faSopenharmony_ci * <ul> 97f9f848faSopenharmony_ci * <li>When config dst, The configuration format has strict requirements.</li> 98f9f848faSopenharmony_ci * <li>The first configuration format for example "Feb-03 03:00:00"</li> 99f9f848faSopenharmony_ci * <li>The second configuration format for example "Oct-1st-Fri 03:00:00"</li> 100f9f848faSopenharmony_ci * <li>The abbreviations for the months are "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", 101f9f848faSopenharmony_ci * "Sep", "Oct", "Nov", and "Dec".</li> 102f9f848faSopenharmony_ci * <li>The abbreviations for the days of the week are "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", and "Sat".</li> 103f9f848faSopenharmony_ci * <li>The abbreviations for the weeks of the month are "1st", "2nd", "3rd", "4th", "5th"</li> 104f9f848faSopenharmony_ci * <li>When it's only four weekdays this month, the effect of "5th" is the same as "Last"</li> 105f9f848faSopenharmony_ci * </ul> 106f9f848faSopenharmony_ci * 107f9f848faSopenharmony_ci * @param dstStartTime The string point to the DST start going to be setting. 108f9f848faSopenharmony_ci * @param dstEndTime The string point to the DST end going to be setting. 109f9f848faSopenharmony_ci * @param forwardSeconds Indicates the number of seconds that time is allocated when entering DST interval. 110f9f848faSopenharmony_ci * 111f9f848faSopenharmony_ci * @retval 0 Succeed. 112f9f848faSopenharmony_ci * @retval -1 Failed. 113f9f848faSopenharmony_ci */ 114f9f848faSopenharmony_ciint dst_enable(const char *dstStartTime, const char *dstEndTime, int forwardSeconds); 115f9f848faSopenharmony_ci 116f9f848faSopenharmony_ci/** 117f9f848faSopenharmony_ci * @ingroup localtime 118f9f848faSopenharmony_ci * @brief Inquire daylight saving time. 119f9f848faSopenharmony_ci * 120f9f848faSopenharmony_ci * @par Description: 121f9f848faSopenharmony_ci * This API is used to inquire daylight saving time. 122f9f848faSopenharmony_ci * 123f9f848faSopenharmony_ci * @param year Represents the year to query start from 1900. 124f9f848faSopenharmony_ci * @param dstStart Used to store daylight savings time start time 125f9f848faSopenharmony_ci * @param dstEnd Used to store daylight savings time end time 126f9f848faSopenharmony_ci * 127f9f848faSopenharmony_ci * @retval 0 Succeed. 128f9f848faSopenharmony_ci * @retval -1 Failed. 129f9f848faSopenharmony_ci */ 130f9f848faSopenharmony_ciint dst_inquire(int year, struct tm *dstStart, struct tm *dstEnd); 131f9f848faSopenharmony_ci 132f9f848faSopenharmony_ci#endif /* __LITEOS__ */ 133f9f848faSopenharmony_ci#ifdef __cplusplus 134f9f848faSopenharmony_ci} 135f9f848faSopenharmony_ci#endif 136f9f848faSopenharmony_ci 137f9f848faSopenharmony_ci#endif /* __LINUX_TZDST_H__ */