FreeRDP
winpr/libwinpr/timezone/timezone.c File Reference
#include <winpr/config.h>
#include <winpr/environment.h>
#include <winpr/wtypes.h>
#include <winpr/timezone.h>
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/file.h>
#include "../log.h"
#include "TimeZoneNameMap.h"
#include "TimeZoneIanaAbbrevMap.h"
#include <time.h>
#include <unistd.h>

Macros

#define TAG   WINPR_TAG("timezone")
 
#define MIN(x, y)   (((x) < (y)) ? (x) : (y))
 
#define log_timezone(tzif, result)   log_timezone_((tzif), (result), __FILE__, __func__, __LINE__)
 

Enumerations

enum  dyn_transition_result { HAVE_TRANSITION_DATES = 0 , HAVE_NO_STANDARD_TRANSITION_DATE = 1 , HAVE_NO_DAYLIGHT_TRANSITION_DATE = 2 }
 

Functions

static char * winpr_read_unix_timezone_identifier_from_file (FILE *fp)
 
static char * winpr_get_timezone_from_link (const char *links[], size_t count)
 
static char * winpr_get_unix_timezone_identifier_from_file (void)
 
static char * winpr_time_zone_from_env (void)
 
static char * winpr_translate_time_zone (const char *tzid)
 
static char * winpr_guess_time_zone (void)
 
static SYSTEMTIME tm2systemtime (const struct tm *t)
 
static struct tm systemtime2tm (const SYSTEMTIME *st)
 
static LONG get_gmtoff_min (const struct tm *t)
 
static struct tm next_day (const struct tm *start)
 
static struct tm adjust_time (const struct tm *start, int hour, int minute)
 
static WORD get_transition_weekday_occurrence (const SYSTEMTIME *st)
 
static SYSTEMTIME tm2transitiontime (const struct tm *cur)
 
static SYSTEMTIME get_transition_time (const struct tm *start, BOOL toDst)
 
static BOOL get_transition_date (const struct tm *start, BOOL toDst, SYSTEMTIME *pdate)
 
static LONG get_bias (const struct tm *start, BOOL dstBias)
 
static BOOL map_iana_id (const char *iana, LPDYNAMIC_TIME_ZONE_INFORMATION tz)
 
static const char * weekday2str (WORD wDayOfWeek)
 
static char * systemtime2str (const SYSTEMTIME *t, char *buffer, size_t len)
 
static void log_print (wLog *log, DWORD level, const char *file, const char *fkt, size_t line,...)
 
static void log_timezone_ (const DYNAMIC_TIME_ZONE_INFORMATION *tzif, DWORD result, const char *file, const char *fkt, size_t line)
 
DWORD GetTimeZoneInformation (LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
 
BOOL SetTimeZoneInformation (const TIME_ZONE_INFORMATION *lpTimeZoneInformation)
 
BOOL SystemTimeToFileTime (const SYSTEMTIME *lpSystemTime, LPFILETIME lpFileTime)
 
BOOL FileTimeToSystemTime (const FILETIME *lpFileTime, LPSYSTEMTIME lpSystemTime)
 
BOOL SystemTimeToTzSpecificLocalTime (LPTIME_ZONE_INFORMATION lpTimeZone, LPSYSTEMTIME lpUniversalTime, LPSYSTEMTIME lpLocalTime)
 
BOOL TzSpecificLocalTimeToSystemTime (LPTIME_ZONE_INFORMATION lpTimeZoneInformation, LPSYSTEMTIME lpLocalTime, LPSYSTEMTIME lpUniversalTime)
 
static int dynamic_time_zone_from_localtime (const struct tm *local_time, PDYNAMIC_TIME_ZONE_INFORMATION tz)
 
DWORD GetDynamicTimeZoneInformation (PDYNAMIC_TIME_ZONE_INFORMATION tz)
 
BOOL SetDynamicTimeZoneInformation (const DYNAMIC_TIME_ZONE_INFORMATION *lpTimeZoneInformation)
 
BOOL GetTimeZoneInformationForYear (USHORT wYear, PDYNAMIC_TIME_ZONE_INFORMATION pdtzi, LPTIME_ZONE_INFORMATION ptzi)
 
BOOL SystemTimeToTzSpecificLocalTimeEx (const DYNAMIC_TIME_ZONE_INFORMATION *lpTimeZoneInformation, const SYSTEMTIME *lpUniversalTime, LPSYSTEMTIME lpLocalTime)
 
BOOL TzSpecificLocalTimeToSystemTimeEx (const DYNAMIC_TIME_ZONE_INFORMATION *lpTimeZoneInformation, const SYSTEMTIME *lpLocalTime, LPSYSTEMTIME lpUniversalTime)
 
DWORD EnumDynamicTimeZoneInformation (const DWORD dwIndex, PDYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation)
 
DWORD GetDynamicTimeZoneInformationEffectiveYears (const PDYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation, LPDWORD FirstYear, LPDWORD LastYear)
 

Macro Definition Documentation

◆ log_timezone

#define log_timezone (   tzif,
  result 
)    log_timezone_((tzif), (result), __FILE__, __func__, __LINE__)

◆ MIN

#define MIN (   x,
  y 
)    (((x) < (y)) ? (x) : (y))

◆ TAG

#define TAG   WINPR_TAG("timezone")

WinPR: Windows Portable Runtime Time Zone

Copyright 2012 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com Copyright 2024 Armin Novak anova.nosp@m.k@th.nosp@m.incas.nosp@m.t.co.nosp@m.m Copyright 2024 Thincast Technologies GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Enumeration Type Documentation

◆ dyn_transition_result

Enumerator
HAVE_TRANSITION_DATES 
HAVE_NO_STANDARD_TRANSITION_DATE 
HAVE_NO_DAYLIGHT_TRANSITION_DATE 

Function Documentation

◆ adjust_time()

static struct tm adjust_time ( const struct tm *  start,
int  hour,
int  minute 
)
static
Here is the caller graph for this function:

◆ dynamic_time_zone_from_localtime()

static int dynamic_time_zone_from_localtime ( const struct tm *  local_time,
PDYNAMIC_TIME_ZONE_INFORMATION  tz 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnumDynamicTimeZoneInformation()

DWORD EnumDynamicTimeZoneInformation ( const DWORD  dwIndex,
PDYNAMIC_TIME_ZONE_INFORMATION  lpTimeZoneInformation 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileTimeToSystemTime()

BOOL FileTimeToSystemTime ( const FILETIME *  lpFileTime,
LPSYSTEMTIME  lpSystemTime 
)

◆ get_bias()

static LONG get_bias ( const struct tm *  start,
BOOL  dstBias 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_gmtoff_min()

static LONG get_gmtoff_min ( const struct tm *  t)
static
Here is the caller graph for this function:

◆ get_transition_date()

static BOOL get_transition_date ( const struct tm *  start,
BOOL  toDst,
SYSTEMTIME *  pdate 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_transition_time()

static SYSTEMTIME get_transition_time ( const struct tm *  start,
BOOL  toDst 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_transition_weekday_occurrence()

static WORD get_transition_weekday_occurrence ( const SYSTEMTIME *  st)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDynamicTimeZoneInformation()

DWORD GetDynamicTimeZoneInformation ( PDYNAMIC_TIME_ZONE_INFORMATION  tz)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDynamicTimeZoneInformationEffectiveYears()

DWORD GetDynamicTimeZoneInformationEffectiveYears ( const PDYNAMIC_TIME_ZONE_INFORMATION  lpTimeZoneInformation,
LPDWORD  FirstYear,
LPDWORD  LastYear 
)

◆ GetTimeZoneInformation()

DWORD GetTimeZoneInformation ( LPTIME_ZONE_INFORMATION  lpTimeZoneInformation)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTimeZoneInformationForYear()

BOOL GetTimeZoneInformationForYear ( USHORT  wYear,
PDYNAMIC_TIME_ZONE_INFORMATION  pdtzi,
LPTIME_ZONE_INFORMATION  ptzi 
)

◆ log_print()

static void log_print ( wLog *  log,
DWORD  level,
const char *  file,
const char *  fkt,
size_t  line,
  ... 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_timezone_()

static void log_timezone_ ( const DYNAMIC_TIME_ZONE_INFORMATION tzif,
DWORD  result,
const char *  file,
const char *  fkt,
size_t  line 
)
static
Here is the call graph for this function:

◆ map_iana_id()

static BOOL map_iana_id ( const char *  iana,
LPDYNAMIC_TIME_ZONE_INFORMATION  tz 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ next_day()

static struct tm next_day ( const struct tm *  start)
static
Here is the caller graph for this function:

◆ SetDynamicTimeZoneInformation()

BOOL SetDynamicTimeZoneInformation ( const DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation)

◆ SetTimeZoneInformation()

BOOL SetTimeZoneInformation ( const TIME_ZONE_INFORMATION lpTimeZoneInformation)

◆ systemtime2str()

static char* systemtime2str ( const SYSTEMTIME *  t,
char *  buffer,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ systemtime2tm()

static struct tm systemtime2tm ( const SYSTEMTIME *  st)
static
Here is the caller graph for this function:

◆ SystemTimeToFileTime()

BOOL SystemTimeToFileTime ( const SYSTEMTIME *  lpSystemTime,
LPFILETIME  lpFileTime 
)

◆ SystemTimeToTzSpecificLocalTime()

BOOL SystemTimeToTzSpecificLocalTime ( LPTIME_ZONE_INFORMATION  lpTimeZone,
LPSYSTEMTIME  lpUniversalTime,
LPSYSTEMTIME  lpLocalTime 
)

◆ SystemTimeToTzSpecificLocalTimeEx()

BOOL SystemTimeToTzSpecificLocalTimeEx ( const DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation,
const SYSTEMTIME *  lpUniversalTime,
LPSYSTEMTIME  lpLocalTime 
)

◆ tm2systemtime()

static SYSTEMTIME tm2systemtime ( const struct tm *  t)
static
Here is the caller graph for this function:

◆ tm2transitiontime()

static SYSTEMTIME tm2transitiontime ( const struct tm *  cur)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TzSpecificLocalTimeToSystemTime()

BOOL TzSpecificLocalTimeToSystemTime ( LPTIME_ZONE_INFORMATION  lpTimeZoneInformation,
LPSYSTEMTIME  lpLocalTime,
LPSYSTEMTIME  lpUniversalTime 
)

◆ TzSpecificLocalTimeToSystemTimeEx()

BOOL TzSpecificLocalTimeToSystemTimeEx ( const DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation,
const SYSTEMTIME *  lpLocalTime,
LPSYSTEMTIME  lpUniversalTime 
)

◆ weekday2str()

static const char* weekday2str ( WORD  wDayOfWeek)
static
Here is the caller graph for this function:

◆ winpr_get_timezone_from_link()

static char* winpr_get_timezone_from_link ( const char *  links[],
size_t  count 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_get_unix_timezone_identifier_from_file()

static char* winpr_get_unix_timezone_identifier_from_file ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_guess_time_zone()

static char* winpr_guess_time_zone ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_read_unix_timezone_identifier_from_file()

static char* winpr_read_unix_timezone_identifier_from_file ( FILE *  fp)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_time_zone_from_env()

static char* winpr_time_zone_from_env ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ winpr_translate_time_zone()

static char* winpr_translate_time_zone ( const char *  tzid)
static
Here is the call graph for this function:
Here is the caller graph for this function: