| 1 | /**************************************************************************** |
|---|
| 2 | * NAME: DMW_SysTime.h |
|---|
| 3 | *---------------------------------------------------------------------------- |
|---|
| 4 | * Copyright (c) 2003 DST Inc. |
|---|
| 5 | *---------------------------------------------------------------------------- |
|---|
| 6 | * CREATED_BY: DIGITAL STREAM Technology Inc. |
|---|
| 7 | * CREATION_DATE: 2003/09/15 |
|---|
| 8 | * AUTHOR: Kyu-hong Park |
|---|
| 9 | * REVISION: Ver 1.001 |
|---|
| 10 | * DATE: |
|---|
| 11 | *---------------------------------------------------------------------------- |
|---|
| 12 | * PURPOSE: |
|---|
| 13 | * - Set System Time and Get System Time |
|---|
| 14 | *****************************************************************************/ |
|---|
| 15 | |
|---|
| 16 | #ifndef __DMW_SYSTIME_H |
|---|
| 17 | #define __DMW_SYSTIME_H |
|---|
| 18 | /* //////////////////////////////////////////////////////////////////////////// */ |
|---|
| 19 | |
|---|
| 20 | #include "DMW_Platform.h" |
|---|
| 21 | |
|---|
| 22 | /*_____ I N C L U D E S ____________________________________________________*/ |
|---|
| 23 | |
|---|
| 24 | /* #define SYSTIME_DEBUG 1 */ /* DMW_SysTime debugging. */ |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | #ifdef __cplusplus |
|---|
| 28 | extern "C"{ |
|---|
| 29 | #endif |
|---|
| 30 | |
|---|
| 31 | /*_____ T Y P E _ D E F I N I T I O N ______________________________________*/ |
|---|
| 32 | |
|---|
| 33 | typedef struct |
|---|
| 34 | { |
|---|
| 35 | BOOL bTimebaseAdjusted; |
|---|
| 36 | int nTimeSystemBase; |
|---|
| 37 | /* offset between UTC time and ANSI time() function result */ |
|---|
| 38 | |
|---|
| 39 | /* UTC <--> LocalTime conversion parameters */ |
|---|
| 40 | int nTimeZone; /* -12 ~ +12 */ |
|---|
| 41 | BOOL bDaylightSavingOn; /* 1: use day light saving , 0: not use day light saving */ |
|---|
| 42 | /* ÀÌ boolean º¯¼ö´Â daylight savingÀÇ "Áؼö(observe)" ¿©ºÎÀÌ´Ù. |
|---|
| 43 | ÀÌ ÆÄ¶ó¹ÌÅÍ´Â »ç¿ëÀÚ ¼±Åÿ¡ ÀÇÇØ ¼³Á¤µÈ´Ù. |
|---|
| 44 | |
|---|
| 45 | "µ¿ÀÛ" ¿©ºÎ¸¦ Áö½ÃÇÏ´Â DS_status ¿Í´Â È¥µ·ÇÏ¸é ¾ÈµÈ´Ù. |
|---|
| 46 | ¶ÇÇÑ ÇöÀçÀÇ "Àû¿ë »óÅÂ"¸¦ ¾Ë·ÁÁÖ´Â bDaylightSavingActive ¿Íµµ ±¸ºÐÇØ¾ß ÇÑ´Ù. |
|---|
| 47 | */ |
|---|
| 48 | |
|---|
| 49 | /* UTC, GPS offset parameter */ |
|---|
| 50 | int GPS_UTC_offset; |
|---|
| 51 | |
|---|
| 52 | /*------------------------------------------------------------*/ |
|---|
| 53 | /* belows are statistics variable, not parameters set by user */ |
|---|
| 54 | |
|---|
| 55 | UINT32 tickTimeAdjusted; |
|---|
| 56 | /* only used when DONT_USE_C_STD_LIB option enabled. |
|---|
| 57 | system time tick (got by OS_GetTickCount()) when last timebase adjusted. |
|---|
| 58 | */ |
|---|
| 59 | |
|---|
| 60 | BOOL bDaylightSavingActive; /* 1 if daylight saving is active now. */ |
|---|
| 61 | /* ÇöÀç daylight saving ±¸°£¿¡ µé¾î°¡ ÀÖ´ÂÁö¸¦ ¾Ë·ÁÁØ´Ù. |
|---|
| 62 | LocalTime º¯È¯ ÇÔ¼ö¸¦ È£Ãâ ÇØ¾ß ÀÌ Á¤º¸°¡ update µÈ´Ù. */ |
|---|
| 63 | |
|---|
| 64 | /* below fields have exactly same usage in PSIP stt or SCTE stt. */ |
|---|
| 65 | UINT8 DS_status; /* 1 if DS_day_of_month and DS_hour is valid. */ |
|---|
| 66 | UINT8 DS_day_of_month; /* 1~31. 0 if automatic DST in/out correction */ |
|---|
| 67 | UINT8 DS_hour; /* 0~23. usually 2 in United States. */ |
|---|
| 68 | /* ÀÌ °ªµéÀº stt section Á¤º¸·ÎºÎÅÍ °¡Á®¿Â´Ù. */ |
|---|
| 69 | } SysTimeContext; |
|---|
| 70 | |
|---|
| 71 | /* º¸Åë ApplicationÀº µÎ°³ÀÇ SysTime context¸¦ À¯Áö/°ü¸® ÇØ¾ß ÇÑ´Ù. |
|---|
| 72 | Çϳª´Â manual time contextÀ̰í, Çϳª´Â STT¿¡ ÀÇÇØ µ¿±âÈ µÇ´Â time contextÀÌ´Ù. |
|---|
| 73 | |
|---|
| 74 | ½ÇÁ¦·Î »ç¿ëÀÚ°¡ ¾î¶² °ÍÀ» »ç¿ëÇÏ´øÁö °£¿¡, |
|---|
| 75 | EPG¸¦ Ç¥½ÃÇϱâ À§ÇØ »ç¿ëµÇ´Â ±âÁØ ½Ã°£Àº STT time contextÀÌ´Ù. |
|---|
| 76 | */ |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | /* typedef struct timespec timespec_t; */ |
|---|
| 81 | |
|---|
| 82 | typedef struct { |
|---|
| 83 | |
|---|
| 84 | int year; /* xxxx (ex. 2003) */ |
|---|
| 85 | int month; /* 1-12 */ |
|---|
| 86 | int day; /* 0-31 */ |
|---|
| 87 | int wday; /* Day of Week -> 0: Sunday, 1: Monday, ... */ |
|---|
| 88 | int hour; /* 0-24 */ |
|---|
| 89 | int min; /* 0-59 */ |
|---|
| 90 | int sec; /* 0-59 */ |
|---|
| 91 | |
|---|
| 92 | } STime_t; /* Struct for Getting & Saving Date/Time Info. */ |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | /*_____ D E C L A R A T I O N ______________________________________________*/ |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | void DMW_SetUTCTime(SysTimeContext *stc, UINT32 utc); |
|---|
| 100 | STATUS DMW_GetUTCTime(SysTimeContext *stc, UINT32 *utc); |
|---|
| 101 | |
|---|
| 102 | UINT32 DMW_ConvertLocalTime2UTC(SysTimeContext *stc, STime_t *system_time); |
|---|
| 103 | void DMW_ConvertUTC2LocalTime(SysTimeContext *stc, UINT32 utc, STime_t *t); |
|---|
| 104 | |
|---|
| 105 | void DMW_SetLocalTime(SysTimeContext *stc, STime_t *t); |
|---|
| 106 | void DMW_SetLocalTime2(SysTimeContext *stc, int year, int month, int day, int hour, int min, int sec); |
|---|
| 107 | int DMW_GetLocalTime(SysTimeContext *stc, STime_t *sys_time); |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | void DMW_SetLocalTimeZone(SysTimeContext *stc, int time_zone); |
|---|
| 111 | int DMW_GetLocalTimeZone(SysTimeContext *stc); |
|---|
| 112 | |
|---|
| 113 | /* daylight saving Áؼö ¿©ºÎ¸¦ ¼³Á¤/Á¶È¸ ÇÑ´Ù. |
|---|
| 114 | daylight saving paramÀº °Çµå¸®Áö ¾ÊÀ½. |
|---|
| 115 | */ |
|---|
| 116 | void DMW_SetDayLightSaving(SysTimeContext *stc, BOOL dayLightSavingOn); |
|---|
| 117 | BOOL DMW_GetDayLightSaving(SysTimeContext *stc); |
|---|
| 118 | |
|---|
| 119 | /* daylight saving parameter¸¸ ¼³Á¤/Á¶È¸ ÇÑ´Ù. |
|---|
| 120 | daylight saving Áؼö ¿©ºÎ´Â °ü·Ã ¾øÀ½. |
|---|
| 121 | */ |
|---|
| 122 | void DMW_SetDayLightSavingParam(SysTimeContext *stc, int status, int day, int hour); |
|---|
| 123 | void DMW_GetDayLightSavingParam(SysTimeContext *stc, int *pStatus, int *pDay, int *pHour); |
|---|
| 124 | |
|---|
| 125 | /* ±âÁ¸ÀÇ ÄÚµåµé°úÀÇ backward compatibility |
|---|
| 126 | ±âÁ¸ ÄÚµåµéÀº ÀÌ ÇÔ¼ö¸¦ ºÎ¸£¸é parameter ¼³Á¤°ú ÇÔ²² Áؼö ¿©ºÎµµ °°ÀÌ ¼³Á¤À» Çß´Ù. |
|---|
| 127 | */ |
|---|
| 128 | #define DMW_SetDayLightSaving2(stc, status, day, hour) \ |
|---|
| 129 | do { \ |
|---|
| 130 | DMW_SetDayLightSavingParam(stc, status, day, hour); \ |
|---|
| 131 | DMW_SetDayLightSaving(stc, TRUE); \ |
|---|
| 132 | } while(0) |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | /* ÇöÀç stcÀÇ ½Ã°£ÀÌ daylight saving ±¸°£¿¡ µé¾î°¡ ÀÖ´ÂÁö¸¦ ¾Ë·ÁÁØ´Ù. |
|---|
| 136 | */ |
|---|
| 137 | BOOL DMW_CheckDayLightSavingActive(SysTimeContext *stc); |
|---|
| 138 | |
|---|
| 139 | int DMW_GetGPS_UTC_offset(SysTimeContext *stc); |
|---|
| 140 | void DMW_SetGPS_UTC_offset(SysTimeContext *stc, int offset); |
|---|
| 141 | |
|---|
| 142 | UINT32 DMW_ConvertUTC2GPS(SysTimeContext *stc, UINT32 UTC); |
|---|
| 143 | UINT32 DMW_ConvertGPS2UTC(SysTimeContext *stc, UINT32 GPS); |
|---|
| 144 | |
|---|
| 145 | void DMW_InvalidateSysTime(SysTimeContext *stc); /* cafrii 050725 add */ |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | void DMW_ChangedTimeInfo(STime_t *norm_time, int offset, STime_t *ret_time); |
|---|
| 149 | int DMW_GetTimeGap(STime_t *start_time, STime_t *end_time); |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | /* --------------------------------------------------------------------------------- |
|---|
| 153 | debugging util.. |
|---|
| 154 | */ |
|---|
| 155 | |
|---|
| 156 | extern const char *DayOfWeekString(int n); /* Sun, Mon.. µîÀÇ ¹®ÀÚ¿ ¸®ÅÏ.. 0 ~ 6 */ |
|---|
| 157 | extern const char *STimeString(STime_t *s, char *buf); |
|---|
| 158 | |
|---|
| 159 | /* many codes uses wrong spelling. so, keep compatibility */ |
|---|
| 160 | #define DayOfWeakString(n) DayOfWeekString(n) |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | void DMW_RegisterSysTimeSymbols(void); |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | #ifdef __cplusplus |
|---|
| 168 | } |
|---|
| 169 | #endif |
|---|
| 170 | |
|---|
| 171 | /*=========================================================================== */ |
|---|
| 172 | #endif /* __DMW_SYSTIME_H */ |
|---|
| 173 | |
|---|
| 174 | /* Revision History ///////////////////////////////////////////////////////// |
|---|
| 175 | |
|---|
| 176 | 2005/3/15 Standard API, °ü·Ã structure ¸ðµÎ »èÁ¦ |
|---|
| 177 | DMW_TIME_T µµ »èÁ¦µÇ¾úÀ½. App °èÃþ¿¡¼ Ãß°¡ ¿ä¸Á.. |
|---|
| 178 | |
|---|
| 179 | 2004/12/20 cafrii, DMW_SYS_GetCurUtcTime Ãß°¡ |
|---|
| 180 | |
|---|
| 181 | ver 1.001 - Date : 2003/09/15 |
|---|
| 182 | WHO : K.H. Park |
|---|
| 183 | To Do : Added UTC time related functions |
|---|
| 184 | |
|---|
| 185 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 186 | */ |
|---|