Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
timezone.h
Go to the documentation of this file.
1/*
2 * This file is part of the Ultibo project, https://ultibo.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2026 Garry Wood <garry@softoz.com.au>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26#ifndef _ULTIBO_TIMEZONE_H
27#define _ULTIBO_TIMEZONE_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/globaltypes.h"
34#include "ultibo/globalconst.h"
35#include "ultibo/sysutils.h"
36
38#define TIME_ZONE_ID_UNKNOWN 0
39#define TIME_ZONE_ID_STANDARD 1
40#define TIME_ZONE_ID_DAYLIGHT 2
41#define TIME_ZONE_ID_INVALID (DWORD)0xFFFFFFFF
42
44#define TIMEZONE_SIGNATURE 0xED9A1BC3
45
47#define TIMEZONE_NAME_LENGTH SIZE_64
48#define TIMEZONE_DESC_LENGTH SIZE_128
49
51
64
68{
69 char name[33]; //NOT null terminated, index 0 is the length
70 char description[65]; //NOT null terminated, index 0 is the length
71 int32_t bias;
72 char standardname[33]; //NOT null terminated, index 0 is the length
73 int32_t standardbias;
75 char daylightname[33]; //NOT null terminated, index 0 is the length
76 int32_t daylightbias;
78};
79
81
83typedef uint32_t STDCALL (*timezone_enumerate_cb)(TIMEZONE_ENTRY *timezone, void *data);
84
103
105
109uint32_t STDCALL timezone_add(TIMEZONE_DATA *data, BOOL _default);
111
112uint32_t STDCALL timezone_get_name(TIMEZONE_ENTRY *timezone, char *name, uint32_t len);
113uint32_t STDCALL timezone_get_description(TIMEZONE_ENTRY *timezone, char *description, uint32_t len);
114
116
123
130uint32_t STDCALL timezone_get_state_ex(TIMEZONE_ENTRY *timezone, double_t datetime);
131
138
145int32_t STDCALL timezone_get_active_bias_ex(TIMEZONE_ENTRY *timezone, double_t datetime);
146
147uint32_t STDCALL timezone_get_standard_name(TIMEZONE_ENTRY *timezone, char *name, uint32_t len);
151
152uint32_t STDCALL timezone_get_daylight_name(TIMEZONE_ENTRY *timezone, char *name, uint32_t len);
156
160
161uint32_t STDCALL timezone_enumerate(timezone_enumerate_cb callback, void *data);
162
164
169
174
179
184
186
192
200uint32_t STDCALL timezone_calculate_offset(double_t datetime, int32_t *offset, BOOL *daylight);
201
205double_t STDCALL timezone_start_to_date_time(SYSTEMTIME *start, uint16_t year);
206
210uint32_t STDCALL timezone_start_to_description(SYSTEMTIME *start, char *description, uint32_t len);
211
212#ifdef __cplusplus
213}
214#endif
215
216#endif // _ULTIBO_TIMEZONE_H
#define STDCALL
Definition globaltypes.h:45
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
wchar_t WCHAR
Standard WideChar type (2 bytes) (Redeclared here for flexibility).
Definition globaltypes.h:58
Definition timezone.h:68
int32_t daylightbias
Definition timezone.h:76
int32_t bias
Definition timezone.h:71
char standardname[33]
Definition timezone.h:72
char name[33]
Definition timezone.h:69
SYSTEMTIME standardstart
Definition timezone.h:74
char description[65]
Definition timezone.h:70
SYSTEMTIME daylightstart
Definition timezone.h:77
int32_t standardbias
Definition timezone.h:73
char daylightname[33]
Definition timezone.h:75
Definition timezone.h:87
char daylightname[TIMEZONE_NAME_LENGTH]
Daylight name.
Definition timezone.h:96
TIMEZONE_ENTRY * next
Next entry in Timezone table.
Definition timezone.h:101
int32_t daylightbias
Definition timezone.h:97
char description[TIMEZONE_DESC_LENGTH]
Timezone description.
Definition timezone.h:91
int32_t bias
Definition timezone.h:92
SYSTEMTIME standardstart
Definition timezone.h:95
char standardname[TIMEZONE_NAME_LENGTH]
Standard name.
Definition timezone.h:93
uint32_t signature
Signature for entry validation.
Definition timezone.h:89
SYSTEMTIME daylightstart
Definition timezone.h:98
TIMEZONE_ENTRY * prev
Previous entry in Timezone table.
Definition timezone.h:100
int32_t standardbias
Definition timezone.h:94
char name[TIMEZONE_NAME_LENGTH]
Timezone name.
Definition timezone.h:90
Definition timezone.h:55
long daylightbias
Definition timezone.h:62
long bias
Definition timezone.h:56
long standardbias
Definition timezone.h:59
SYSTEMTIME standarddate
Definition timezone.h:58
WCHAR standardname[32]
Definition timezone.h:57
WCHAR daylightname[32]
Definition timezone.h:60
SYSTEMTIME daylightdate
Definition timezone.h:61
struct _SYSTEMTIME SYSTEMTIME
struct _TIME_ZONE_INFORMATION TIME_ZONE_INFORMATION
Definition timezone.h:53
int32_t STDCALL timezone_get_daylight_bias(TIMEZONE_ENTRY *timezone)
TIMEZONE_ENTRY *STDCALL timezone_get_default(void)
Get the current default timezone.
uint32_t STDCALL timezone_get_state(TIMEZONE_ENTRY *timezone)
Get the state of the supplied Timezone at the current date and time.
uint32_t STDCALL timezone_add(TIMEZONE_DATA *data, BOOL _default)
Add a Timezone from a timezone data block and to the Timezone table.
uint32_t STDCALL timezone_calculate_offset(double_t datetime, int32_t *offset, BOOL *daylight)
Calculate the Timezone Offset at the given date and time in the current timezone.
uint32_t STDCALL timezone_enumerate(timezone_enumerate_cb callback, void *data)
uint32_t STDCALL timezone_update_offset(void)
uint32_t STDCALL timezone_get_daylight_name(TIMEZONE_ENTRY *timezone, char *name, uint32_t len)
uint32_t STDCALL timezone_get_state_ex(TIMEZONE_ENTRY *timezone, double_t datetime)
Get the state of the supplied Timezone at the specified date and time.
#define TIMEZONE_NAME_LENGTH
Length of timezone name.
Definition timezone.h:47
uint32_t STDCALL timezone_get_name(TIMEZONE_ENTRY *timezone, char *name, uint32_t len)
double_t STDCALL timezone_get_standard_date(TIMEZONE_ENTRY *timezone, BOOL next)
uint32_t STDCALL(* timezone_enumerate_cb)(TIMEZONE_ENTRY *timezone, void *data)
Definition timezone.h:83
uint32_t STDCALL timezone_start_to_description(SYSTEMTIME *start, char *description, uint32_t len)
Get the description of the start date of a timezone.
uint32_t STDCALL timezone_update_environment(void)
Update the TZ environment variable to represent the current timezone.
struct _TIMEZONE_DATA TIMEZONE_DATA
Definition timezone.h:66
uint32_t STDCALL timezone_get_count(void)
Get the current timezone count.
int32_t STDCALL timezone_get_active_bias_ex(TIMEZONE_ENTRY *timezone, double_t datetime)
Get the bias (offset between UTC and Local) of the supplied Timezone at the specified date and time.
uint32_t STDCALL timezone_delete(TIMEZONE_ENTRY *timezone)
SYSTEMTIME STDCALL timezone_get_daylight_start(TIMEZONE_ENTRY *timezone)
uint32_t STDCALL timezone_set_default(TIMEZONE_ENTRY *timezone)
Set the current default timezone.
double_t STDCALL timezone_start_to_date_time(SYSTEMTIME *start, uint16_t year)
Calculate the start date and time from the start date of a timezone.
uint32_t STDCALL timezone_get_standard_name(TIMEZONE_ENTRY *timezone, char *name, uint32_t len)
TIMEZONE_ENTRY *STDCALL timezone_check(TIMEZONE_ENTRY *timezone)
Check if the supplied Timezone is in the Timezone table.
int32_t STDCALL timezone_get_standard_bias(TIMEZONE_ENTRY *timezone)
int32_t STDCALL timezone_get_bias(TIMEZONE_ENTRY *timezone)
TIMEZONE_ENTRY *STDCALL timezone_find(const char *name)
#define TIMEZONE_DESC_LENGTH
Length of timezone description.
Definition timezone.h:48
int32_t STDCALL timezone_get_active_bias(TIMEZONE_ENTRY *timezone)
Get the bias (offset between UTC and Local) of the supplied Timezone at the current date and time.
struct _TIMEZONE_ENTRY TIMEZONE_ENTRY
Definition timezone.h:80
TIMEZONE_ENTRY *STDCALL timezone_find_by_standard(const char *standardname)
TIMEZONE_ENTRY *STDCALL timezone_find_by_daylight(const char *daylightname)
SYSTEMTIME STDCALL timezone_get_standard_start(TIMEZONE_ENTRY *timezone)
double_t STDCALL timezone_get_daylight_date(TIMEZONE_ENTRY *timezone, BOOL next)
uint32_t STDCALL timezone_get_description(TIMEZONE_ENTRY *timezone, char *description, uint32_t len)