/**************************************************************************** * NAME: DMW_SysTime.h *---------------------------------------------------------------------------- * Copyright (c) 2003 DST Inc. *---------------------------------------------------------------------------- * CREATED_BY: DIGITAL STREAM Technology Inc. * CREATION_DATE: 2003/09/15 * AUTHOR: Kyu-hong Park * REVISION: Ver 1.001 * DATE: *---------------------------------------------------------------------------- * PURPOSE: * - Set System Time and Get System Time *****************************************************************************/ #ifndef __DMW_SYSTIME_H #define __DMW_SYSTIME_H /* //////////////////////////////////////////////////////////////////////////// */ #include "DMW_Platform.h" /*_____ I N C L U D E S ____________________________________________________*/ /* #define SYSTIME_DEBUG 1 */ /* DMW_SysTime debugging. */ #ifdef __cplusplus extern "C"{ #endif /*_____ T Y P E _ D E F I N I T I O N ______________________________________*/ typedef struct { BOOL bTimebaseAdjusted; int nTimeSystemBase; /* offset between UTC time and ANSI time() function result */ /* UTC <--> LocalTime conversion parameters */ int nTimeZone; /* -12 ~ +12 */ BOOL bDaylightSavingOn; /* 1: use day light saving , 0: not use day light saving */ /* ÀÌ boolean º¯¼ö´Â daylight savingÀÇ "Áؼö(observe)" ¿©ºÎÀÌ´Ù. ÀÌ ÆÄ¶ó¹ÌÅÍ´Â »ç¿ëÀÚ ¼±Åÿ¡ ÀÇÇØ ¼³Á¤µÈ´Ù. "µ¿ÀÛ" ¿©ºÎ¸¦ Áö½ÃÇÏ´Â DS_status ¿Í´Â È¥µ·ÇÏ¸é ¾ÈµÈ´Ù. ¶ÇÇÑ ÇöÀçÀÇ "Àû¿ë »óÅÂ"¸¦ ¾Ë·ÁÁÖ´Â bDaylightSavingActive ¿Íµµ ±¸ºÐÇØ¾ß ÇÑ´Ù. */ /* UTC, GPS offset parameter */ int GPS_UTC_offset; /*------------------------------------------------------------*/ /* belows are statistics variable, not parameters set by user */ UINT32 tickTimeAdjusted; /* only used when DONT_USE_C_STD_LIB option enabled. system time tick (got by OS_GetTickCount()) when last timebase adjusted. */ BOOL bDaylightSavingActive; /* 1 if daylight saving is active now. */ /* ÇöÀç daylight saving ±¸°£¿¡ µé¾î°¡ ÀÖ´ÂÁö¸¦ ¾Ë·ÁÁØ´Ù. LocalTime º¯È¯ ÇÔ¼ö¸¦ È£Ãâ ÇØ¾ß ÀÌ Á¤º¸°¡ update µÈ´Ù. */ /* below fields have exactly same usage in PSIP stt or SCTE stt. */ UINT8 DS_status; /* 1 if DS_day_of_month and DS_hour is valid. */ UINT8 DS_day_of_month; /* 1~31. 0 if automatic DST in/out correction */ UINT8 DS_hour; /* 0~23. usually 2 in United States. */ /* ÀÌ °ªµéÀº stt section Á¤º¸·ÎºÎÅÍ °¡Á®¿Â´Ù. */ } SysTimeContext; /* º¸Åë ApplicationÀº µÎ°³ÀÇ SysTime context¸¦ À¯Áö/°ü¸® ÇØ¾ß ÇÑ´Ù. Çϳª´Â manual time contextÀ̰í, Çϳª´Â STT¿¡ ÀÇÇØ µ¿±âÈ­ µÇ´Â time contextÀÌ´Ù. ½ÇÁ¦·Î »ç¿ëÀÚ°¡ ¾î¶² °ÍÀ» »ç¿ëÇÏ´øÁö °£¿¡, EPG¸¦ Ç¥½ÃÇϱâ À§ÇØ »ç¿ëµÇ´Â ±âÁØ ½Ã°£Àº STT time contextÀÌ´Ù. */ /* typedef struct timespec timespec_t; */ typedef struct { int year; /* xxxx (ex. 2003) */ int month; /* 1-12 */ int day; /* 0-31 */ int wday; /* Day of Week -> 0: Sunday, 1: Monday, ... */ int hour; /* 0-24 */ int min; /* 0-59 */ int sec; /* 0-59 */ } STime_t; /* Struct for Getting & Saving Date/Time Info. */ /*_____ D E C L A R A T I O N ______________________________________________*/ void DMW_SetUTCTime(SysTimeContext *stc, UINT32 utc); STATUS DMW_GetUTCTime(SysTimeContext *stc, UINT32 *utc); UINT32 DMW_ConvertLocalTime2UTC(SysTimeContext *stc, STime_t *system_time); void DMW_ConvertUTC2LocalTime(SysTimeContext *stc, UINT32 utc, STime_t *t); void DMW_SetLocalTime(SysTimeContext *stc, STime_t *t); void DMW_SetLocalTime2(SysTimeContext *stc, int year, int month, int day, int hour, int min, int sec); int DMW_GetLocalTime(SysTimeContext *stc, STime_t *sys_time); void DMW_SetLocalTimeZone(SysTimeContext *stc, int time_zone); int DMW_GetLocalTimeZone(SysTimeContext *stc); /* daylight saving Áؼö ¿©ºÎ¸¦ ¼³Á¤/Á¶È¸ ÇÑ´Ù. daylight saving paramÀº °Çµå¸®Áö ¾ÊÀ½. */ void DMW_SetDayLightSaving(SysTimeContext *stc, BOOL dayLightSavingOn); BOOL DMW_GetDayLightSaving(SysTimeContext *stc); /* daylight saving parameter¸¸ ¼³Á¤/Á¶È¸ ÇÑ´Ù. daylight saving Áؼö ¿©ºÎ´Â °ü·Ã ¾øÀ½. */ void DMW_SetDayLightSavingParam(SysTimeContext *stc, int status, int day, int hour); void DMW_GetDayLightSavingParam(SysTimeContext *stc, int *pStatus, int *pDay, int *pHour); /* ±âÁ¸ÀÇ ÄÚµåµé°úÀÇ backward compatibility ±âÁ¸ ÄÚµåµéÀº ÀÌ ÇÔ¼ö¸¦ ºÎ¸£¸é parameter ¼³Á¤°ú ÇÔ²² Áؼö ¿©ºÎµµ °°ÀÌ ¼³Á¤À» Çß´Ù. */ #define DMW_SetDayLightSaving2(stc, status, day, hour) \ do { \ DMW_SetDayLightSavingParam(stc, status, day, hour); \ DMW_SetDayLightSaving(stc, TRUE); \ } while(0) /* ÇöÀç stcÀÇ ½Ã°£ÀÌ daylight saving ±¸°£¿¡ µé¾î°¡ ÀÖ´ÂÁö¸¦ ¾Ë·ÁÁØ´Ù. */ BOOL DMW_CheckDayLightSavingActive(SysTimeContext *stc); int DMW_GetGPS_UTC_offset(SysTimeContext *stc); void DMW_SetGPS_UTC_offset(SysTimeContext *stc, int offset); UINT32 DMW_ConvertUTC2GPS(SysTimeContext *stc, UINT32 UTC); UINT32 DMW_ConvertGPS2UTC(SysTimeContext *stc, UINT32 GPS); void DMW_InvalidateSysTime(SysTimeContext *stc); /* cafrii 050725 add */ void DMW_ChangedTimeInfo(STime_t *norm_time, int offset, STime_t *ret_time); int DMW_GetTimeGap(STime_t *start_time, STime_t *end_time); /* --------------------------------------------------------------------------------- debugging util.. */ extern const char *DayOfWeekString(int n); /* Sun, Mon.. µîÀÇ ¹®ÀÚ¿­ ¸®ÅÏ.. 0 ~ 6 */ extern const char *STimeString(STime_t *s, char *buf); /* many codes uses wrong spelling. so, keep compatibility */ #define DayOfWeakString(n) DayOfWeekString(n) void DMW_RegisterSysTimeSymbols(void); #ifdef __cplusplus } #endif /*=========================================================================== */ #endif /* __DMW_SYSTIME_H */ /* Revision History ///////////////////////////////////////////////////////// 2005/3/15 Standard API, °ü·Ã structure ¸ðµÎ »èÁ¦ DMW_TIME_T µµ »èÁ¦µÇ¾úÀ½. App °èÃþ¿¡¼­ Ãß°¡ ¿ä¸Á.. 2004/12/20 cafrii, DMW_SYS_GetCurUtcTime Ãß°¡ ver 1.001 - Date : 2003/09/15 WHO : K.H. Park To Do : Added UTC time related functions ////////////////////////////////////////////////////////////////////////// */