php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
timelib.h File Reference
#include <stdlib.h>
#include <stdbool.h>
#include <limits.h>
#include <inttypes.h>

Go to the source code of this file.

Data Structures

struct  _tlocinfo
 
struct  _timelib_posix_trans_info
 
struct  _timelib_posix_str
 
struct  _timelib_posix_transitions
 
struct  _timelib_tzinfo
 
struct  _timelib_rel_time
 
struct  _timelib_time_offset
 
struct  _timelib_time
 
struct  _timelib_abbr_info
 
struct  _timelib_error_message
 
struct  _timelib_error_container
 
struct  _timelib_tz_lookup_table
 
struct  _timelib_tzdb_index_entry
 
struct  _timelib_tzdb
 
struct  _timelib_format_specifier
 
struct  _timelib_format_config
 

Macros

#define TIMELIB_VERSION   202212
 
#define TIMELIB_EXTENDED_VERSION   20221201
 
#define TIMELIB_ASCII_VERSION   "2022.12"
 
#define TIMELIB_LONG_MAX   INT32_MAX
 
#define TIMELIB_LONG_MIN   INT32_MIN
 
#define TIMELIB_ULONG_MAX   UINT32_MAX
 
#define TIMELIB_LONG_FMT   "%" PRId32
 
#define TIMELIB_ULONG_FMT   "%" PRIu32
 
#define TIMELIB_LL_CONST(n)
 
#define TIMELIB_POSIX_TRANS_TYPE_JULIAN_NO_FEB29   1
 
#define TIMELIB_POSIX_TRANS_TYPE_JULIAN_FEB29   2
 
#define TIMELIB_POSIX_TRANS_TYPE_MWD   3
 
#define TIMELIB_WARN_MASK   0x1ff
 
#define TIMELIB_ERR_MASK   0x2ff
 
#define TIMELIB_WARN_DOUBLE_TZ   0x101
 
#define TIMELIB_WARN_INVALID_TIME   0x102
 
#define TIMELIB_WARN_INVALID_DATE   0x103
 
#define TIMELIB_WARN_TRAILING_DATA   0x11a
 
#define TIMELIB_ERR_DOUBLE_TZ   0x201
 
#define TIMELIB_ERR_TZID_NOT_FOUND   0x202
 
#define TIMELIB_ERR_DOUBLE_TIME   0x203
 
#define TIMELIB_ERR_DOUBLE_DATE   0x204
 
#define TIMELIB_ERR_UNEXPECTED_CHARACTER   0x205
 
#define TIMELIB_ERR_EMPTY_STRING   0x206
 
#define TIMELIB_ERR_UNEXPECTED_DATA   0x207
 
#define TIMELIB_ERR_NO_TEXTUAL_DAY   0x208
 
#define TIMELIB_ERR_NO_TWO_DIGIT_DAY   0x209
 
#define TIMELIB_ERR_NO_THREE_DIGIT_DAY_OF_YEAR   0x20a
 
#define TIMELIB_ERR_NO_TWO_DIGIT_MONTH   0x20b
 
#define TIMELIB_ERR_NO_TEXTUAL_MONTH   0x20c
 
#define TIMELIB_ERR_NO_TWO_DIGIT_YEAR   0x20d
 
#define TIMELIB_ERR_NO_FOUR_DIGIT_YEAR   0x20e
 
#define TIMELIB_ERR_NO_TWO_DIGIT_HOUR   0x20f
 
#define TIMELIB_ERR_HOUR_LARGER_THAN_12   0x210
 
#define TIMELIB_ERR_MERIDIAN_BEFORE_HOUR   0x211
 
#define TIMELIB_ERR_NO_MERIDIAN   0x212
 
#define TIMELIB_ERR_NO_TWO_DIGIT_MINUTE   0x213
 
#define TIMELIB_ERR_NO_TWO_DIGIT_SECOND   0x214
 
#define TIMELIB_ERR_NO_SIX_DIGIT_MICROSECOND   0x215
 
#define TIMELIB_ERR_NO_SEP_SYMBOL   0x216
 
#define TIMELIB_ERR_EXPECTED_ESCAPE_CHAR   0x217
 
#define TIMELIB_ERR_NO_ESCAPED_CHAR   0x218
 
#define TIMELIB_ERR_WRONG_FORMAT_SEP   0x219
 
#define TIMELIB_ERR_TRAILING_DATA   0x21a
 
#define TIMELIB_ERR_DATA_MISSING   0x21b
 
#define TIMELIB_ERR_NO_THREE_DIGIT_MILLISECOND   0x21c
 
#define TIMELIB_ERR_NO_FOUR_DIGIT_YEAR_ISO   0x21d
 
#define TIMELIB_ERR_NO_TWO_DIGIT_WEEK   0x21e
 
#define TIMELIB_ERR_INVALID_WEEK   0x21f
 
#define TIMELIB_ERR_NO_DAY_OF_WEEK   0x220
 
#define TIMELIB_ERR_INVALID_DAY_OF_WEEK   0x221
 
#define TIMELIB_ERR_INVALID_SPECIFIER   0x222
 
#define TIMELIB_ERR_INVALID_TZ_OFFSET   0x223
 
#define TIMELIB_ERR_FORMAT_LITERAL_MISMATCH   0x224
 
#define TIMELIB_ERR_MIX_ISO_WITH_NATURAL   0x225
 
#define TIMELIB_ERR_NUMBER_OUT_OF_RANGE   0x226
 
#define TIMELIB_ZONETYPE_NONE   0
 
#define TIMELIB_ZONETYPE_OFFSET   1
 
#define TIMELIB_ZONETYPE_ABBR   2
 
#define TIMELIB_ZONETYPE_ID   3
 
#define timelib_malloc   malloc
 
#define timelib_realloc   realloc
 
#define timelib_calloc   calloc
 
#define timelib_strdup   strdup
 
#define timelib_free   free
 
#define TIMELIB_USE_BUILTIN_STRNDUP   0
 
#define timelib_strndup   strndup
 
#define TIMELIB_NONE   0x00
 
#define TIMELIB_OVERRIDE_TIME   0x01
 
#define TIMELIB_NO_CLONE   0x02
 
#define TIMELIB_UNSET   -9999999
 
#define TIMELIB_ERROR_NO_ERROR   0x00
 
#define TIMELIB_ERROR_CANNOT_ALLOCATE   0x01
 
#define TIMELIB_ERROR_CORRUPT_TRANSITIONS_DONT_INCREASE   0x02
 
#define TIMELIB_ERROR_CORRUPT_NO_64BIT_PREAMBLE   0x03
 
#define TIMELIB_ERROR_CORRUPT_NO_ABBREVIATION   0x04
 
#define TIMELIB_ERROR_UNSUPPORTED_VERSION   0x05
 
#define TIMELIB_ERROR_NO_SUCH_TIMEZONE   0x06
 
#define TIMELIB_ERROR_SLIM_FILE   0x07 /* Warns if the file is SLIM, but we can't read it */
 
#define TIMELIB_ERROR_CORRUPT_POSIX_STRING   0x08
 
#define TIMELIB_ERROR_EMPTY_POSIX_STRING   0x09 /* Warns if the POSIX string is empty, but still produces results */
 

Typedefs

typedef int32_t timelib_long
 
typedef uint32_t timelib_ulong
 
typedef unsigned long long timelib_ull
 
typedef signed long long timelib_sll
 
typedef struct _ttinfo ttinfo
 
typedef struct _tlinfo tlinfo
 
typedef struct _tlocinfo tlocinfo
 
typedef struct _timelib_posix_trans_info timelib_posix_trans_info
 
typedef struct _timelib_posix_str timelib_posix_str
 
typedef struct _timelib_posix_transitions timelib_posix_transitions
 
typedef struct _timelib_tzinfo timelib_tzinfo
 
typedef struct _timelib_rel_time timelib_rel_time
 
typedef struct _timelib_time_offset timelib_time_offset
 
typedef struct _timelib_time timelib_time
 
typedef struct _timelib_abbr_info timelib_abbr_info
 
typedef struct _timelib_error_message timelib_error_message
 
typedef struct _timelib_error_container timelib_error_container
 
typedef struct _timelib_tz_lookup_table timelib_tz_lookup_table
 
typedef struct _timelib_tzdb_index_entry timelib_tzdb_index_entry
 
typedef struct _timelib_tzdb timelib_tzdb
 
typedef enum _timelib_format_specifier_code timelib_format_specifier_code
 
typedef struct _timelib_format_specifier timelib_format_specifier
 
typedef struct _timelib_format_config timelib_format_config
 
typedef timelib_tzinfo *(* timelib_tz_get_wrapper) (const char *tzname, const timelib_tzdb *tzdb, int *error_code)
 

Enumerations

enum  _timelib_format_specifier_code {
  TIMELIB_FORMAT_ALLOW_EXTRA_CHARACTERS = 0 , TIMELIB_FORMAT_ANY_SEPARATOR , TIMELIB_FORMAT_DAY_TWO_DIGIT , TIMELIB_FORMAT_DAY_TWO_DIGIT_PADDED ,
  TIMELIB_FORMAT_DAY_OF_WEEK_ISO , TIMELIB_FORMAT_DAY_OF_WEEK , TIMELIB_FORMAT_DAY_OF_YEAR , TIMELIB_FORMAT_DAY_SUFFIX ,
  TIMELIB_FORMAT_END , TIMELIB_FORMAT_EPOCH_SECONDS , TIMELIB_FORMAT_ESCAPE , TIMELIB_FORMAT_HOUR_TWO_DIGIT_12_MAX ,
  TIMELIB_FORMAT_HOUR_TWO_DIGIT_12_MAX_PADDED , TIMELIB_FORMAT_HOUR_TWO_DIGIT_24_MAX , TIMELIB_FORMAT_HOUR_TWO_DIGIT_24_MAX_PADDED , TIMELIB_FORMAT_LITERAL ,
  TIMELIB_FORMAT_MERIDIAN , TIMELIB_FORMAT_MICROSECOND_SIX_DIGIT , TIMELIB_FORMAT_MILLISECOND_THREE_DIGIT , TIMELIB_FORMAT_MINUTE_TWO_DIGIT ,
  TIMELIB_FORMAT_MONTH_TWO_DIGIT , TIMELIB_FORMAT_MONTH_TWO_DIGIT_PADDED , TIMELIB_FORMAT_RANDOM_CHAR , TIMELIB_FORMAT_RESET_ALL ,
  TIMELIB_FORMAT_RESET_ALL_WHEN_NOT_SET , TIMELIB_FORMAT_SECOND_TWO_DIGIT , TIMELIB_FORMAT_SEPARATOR , TIMELIB_FORMAT_SKIP_TO_SEPARATOR ,
  TIMELIB_FORMAT_TEXTUAL_DAY_3_LETTER , TIMELIB_FORMAT_TEXTUAL_DAY_FULL , TIMELIB_FORMAT_TEXTUAL_MONTH_3_LETTER , TIMELIB_FORMAT_TEXTUAL_MONTH_FULL ,
  TIMELIB_FORMAT_TIMEZONE_OFFSET , TIMELIB_FORMAT_TIMEZONE_OFFSET_MINUTES , TIMELIB_FORMAT_WEEK_OF_YEAR_ISO , TIMELIB_FORMAT_WEEK_OF_YEAR ,
  TIMELIB_FORMAT_WHITESPACE , TIMELIB_FORMAT_YEAR_TWO_DIGIT , TIMELIB_FORMAT_YEAR_FOUR_DIGIT , TIMELIB_FORMAT_YEAR_EXPANDED ,
  TIMELIB_FORMAT_YEAR_ISO
}
 

Functions

timelib_sll timelib_day_of_week (timelib_sll y, timelib_sll m, timelib_sll d)
 
timelib_sll timelib_iso_day_of_week (timelib_sll y, timelib_sll m, timelib_sll d)
 
timelib_sll timelib_day_of_year (timelib_sll y, timelib_sll m, timelib_sll d)
 
timelib_sll timelib_daynr_from_weeknr (timelib_sll iy, timelib_sll iw, timelib_sll id)
 
timelib_sll timelib_days_in_month (timelib_sll y, timelib_sll m)
 
void timelib_isoweek_from_date (timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iw, timelib_sll *iy)
 
void timelib_isodate_from_date (timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iy, timelib_sll *iw, timelib_sll *id)
 
void timelib_date_from_isodate (timelib_sll iy, timelib_sll iw, timelib_sll id, timelib_sll *y, timelib_sll *m, timelib_sll *d)
 
int timelib_valid_time (timelib_sll h, timelib_sll i, timelib_sll s)
 
int timelib_valid_date (timelib_sll y, timelib_sll m, timelib_sll d)
 
timelib_timetimelib_strtotime (const char *s, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
 
timelib_timetimelib_parse_from_format (const char *format, const char *s, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
 
timelib_timetimelib_parse_from_format_with_map (const char *format, const char *s, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper, const timelib_format_config *format_config)
 
void timelib_fill_holes (timelib_time *parsed, timelib_time *now, int options)
 
const char * timelib_timezone_id_from_abbr (const char *abbr, timelib_long gmtoffset, int isdst)
 
const timelib_tz_lookup_tabletimelib_timezone_abbreviations_list (void)
 
timelib_long timelib_parse_zone (const char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_wrapper)
 
void timelib_strtointerval (const char *s, size_t len, timelib_time **begin, timelib_time **end, timelib_rel_time **period, int *recurrences, timelib_error_container **errors)
 
void timelib_update_ts (timelib_time *time, timelib_tzinfo *tzi)
 
timelib_sll timelib_epoch_days_from_time (timelib_time *time)
 
void timelib_do_normalize (timelib_time *base)
 
void timelib_do_rel_normalize (timelib_time *base, timelib_rel_time *rt)
 
void timelib_unixtime2date (timelib_sll ts, timelib_sll *y, timelib_sll *m, timelib_sll *d)
 
void timelib_unixtime2gmt (timelib_time *tm, timelib_sll ts)
 
void timelib_unixtime2local (timelib_time *tm, timelib_sll ts)
 
void timelib_update_from_sse (timelib_time *tm)
 
void timelib_set_timezone_from_offset (timelib_time *t, timelib_sll utc_offset)
 
void timelib_set_timezone_from_abbr (timelib_time *t, timelib_abbr_info abbr_info)
 
void timelib_set_timezone (timelib_time *t, timelib_tzinfo *tz)
 
int timelib_timezone_id_is_valid (const char *timezone, const timelib_tzdb *tzdb)
 
timelib_tzinfotimelib_parse_tzfile (const char *timezone, const timelib_tzdb *tzdb, int *error_code)
 
void timelib_tzinfo_dtor (timelib_tzinfo *tz)
 
timelib_tzinfotimelib_tzinfo_clone (timelib_tzinfo *tz)
 
int timelib_timestamp_is_in_dst (timelib_sll ts, timelib_tzinfo *tz)
 
timelib_time_offsettimelib_get_time_zone_info (timelib_sll ts, timelib_tzinfo *tz)
 
int timelib_get_time_zone_offset_info (timelib_sll ts, timelib_tzinfo *tz, int32_t *offset, timelib_sll *transition_time, unsigned int *is_dst)
 
timelib_sll timelib_get_current_offset (timelib_time *t)
 
int timelib_same_timezone (timelib_time *one, timelib_time *two)
 
void timelib_dump_tzinfo (timelib_tzinfo *tz)
 
const timelib_tzdbtimelib_builtin_db (void)
 
const timelib_tzdb_index_entrytimelib_timezone_identifiers_list (const timelib_tzdb *tzdb, int *count)
 
timelib_tzdbtimelib_zoneinfo (const char *directory)
 
void timelib_zoneinfo_dtor (timelib_tzdb *tzdb)
 
const char * timelib_get_error_message (int error_code)
 
timelib_rel_timetimelib_rel_time_ctor (void)
 
void timelib_rel_time_dtor (timelib_rel_time *t)
 
timelib_rel_timetimelib_rel_time_clone (timelib_rel_time *tz)
 
timelib_timetimelib_time_ctor (void)
 
void timelib_time_dtor (timelib_time *t)
 
timelib_timetimelib_time_clone (timelib_time *orig)
 
int timelib_time_compare (timelib_time *t1, timelib_time *t2)
 
timelib_time_offsettimelib_time_offset_ctor (void)
 
void timelib_time_offset_dtor (timelib_time_offset *t)
 
void timelib_error_container_dtor (timelib_error_container *errors)
 
timelib_long timelib_date_to_int (timelib_time *d, int *error)
 
void timelib_dump_date (timelib_time *d, int options)
 
void timelib_dump_rel_time (timelib_rel_time *d)
 
void timelib_decimal_hour_to_hms (double h, int *hour, int *min, int *sec)
 
void timelib_hms_to_decimal_hour (int hour, int min, int sec, double *h)
 
void timelib_hmsf_to_decimal_hour (int hour, int min, int sec, int us, double *h)
 
timelib_sll timelib_hms_to_seconds (timelib_sll h, timelib_sll m, timelib_sll s)
 
double timelib_ts_to_julianday (timelib_sll ts)
 
double timelib_ts_to_j2000 (timelib_sll ts)
 
int timelib_astro_rise_set_altitude (timelib_time *time, double lon, double lat, double altit, int upper_limb, double *h_rise, double *h_set, timelib_sll *ts_rise, timelib_sll *ts_set, timelib_sll *ts_transit)
 
timelib_rel_timetimelib_diff (timelib_time *one, timelib_time *two)
 
int timelib_diff_days (timelib_time *one, timelib_time *two)
 
timelib_timetimelib_add (timelib_time *t, timelib_rel_time *interval)
 
timelib_timetimelib_add_wall (timelib_time *t, timelib_rel_time *interval)
 
timelib_timetimelib_sub (timelib_time *t, timelib_rel_time *interval)
 
timelib_timetimelib_sub_wall (timelib_time *t, timelib_rel_time *interval)
 
void timelib_posix_str_dtor (timelib_posix_str *ps)
 
timelib_posix_strtimelib_parse_posix_str (const char *posix)
 
void timelib_get_transitions_for_year (timelib_tzinfo *tz, timelib_sll year, timelib_posix_transitions *transitions)
 

Macro Definition Documentation

◆ TIMELIB_ASCII_VERSION

#define TIMELIB_ASCII_VERSION   "2022.12"

Definition at line 35 of file timelib.h.

◆ timelib_calloc

#define timelib_calloc   calloc

Definition at line 367 of file timelib.h.

◆ TIMELIB_ERR_DATA_MISSING

#define TIMELIB_ERR_DATA_MISSING   0x21b

Definition at line 313 of file timelib.h.

◆ TIMELIB_ERR_DOUBLE_DATE

#define TIMELIB_ERR_DOUBLE_DATE   0x204

Definition at line 290 of file timelib.h.

◆ TIMELIB_ERR_DOUBLE_TIME

#define TIMELIB_ERR_DOUBLE_TIME   0x203

Definition at line 289 of file timelib.h.

◆ TIMELIB_ERR_DOUBLE_TZ

#define TIMELIB_ERR_DOUBLE_TZ   0x201

Definition at line 287 of file timelib.h.

◆ TIMELIB_ERR_EMPTY_STRING

#define TIMELIB_ERR_EMPTY_STRING   0x206

Definition at line 292 of file timelib.h.

◆ TIMELIB_ERR_EXPECTED_ESCAPE_CHAR

#define TIMELIB_ERR_EXPECTED_ESCAPE_CHAR   0x217

Definition at line 309 of file timelib.h.

◆ TIMELIB_ERR_FORMAT_LITERAL_MISMATCH

#define TIMELIB_ERR_FORMAT_LITERAL_MISMATCH   0x224

Definition at line 322 of file timelib.h.

◆ TIMELIB_ERR_HOUR_LARGER_THAN_12

#define TIMELIB_ERR_HOUR_LARGER_THAN_12   0x210

Definition at line 302 of file timelib.h.

◆ TIMELIB_ERR_INVALID_DAY_OF_WEEK

#define TIMELIB_ERR_INVALID_DAY_OF_WEEK   0x221

Definition at line 319 of file timelib.h.

◆ TIMELIB_ERR_INVALID_SPECIFIER

#define TIMELIB_ERR_INVALID_SPECIFIER   0x222

Definition at line 320 of file timelib.h.

◆ TIMELIB_ERR_INVALID_TZ_OFFSET

#define TIMELIB_ERR_INVALID_TZ_OFFSET   0x223

Definition at line 321 of file timelib.h.

◆ TIMELIB_ERR_INVALID_WEEK

#define TIMELIB_ERR_INVALID_WEEK   0x21f

Definition at line 317 of file timelib.h.

◆ TIMELIB_ERR_MASK

#define TIMELIB_ERR_MASK   0x2ff

Definition at line 280 of file timelib.h.

◆ TIMELIB_ERR_MERIDIAN_BEFORE_HOUR

#define TIMELIB_ERR_MERIDIAN_BEFORE_HOUR   0x211

Definition at line 303 of file timelib.h.

◆ TIMELIB_ERR_MIX_ISO_WITH_NATURAL

#define TIMELIB_ERR_MIX_ISO_WITH_NATURAL   0x225

Definition at line 323 of file timelib.h.

◆ TIMELIB_ERR_NO_DAY_OF_WEEK

#define TIMELIB_ERR_NO_DAY_OF_WEEK   0x220

Definition at line 318 of file timelib.h.

◆ TIMELIB_ERR_NO_ESCAPED_CHAR

#define TIMELIB_ERR_NO_ESCAPED_CHAR   0x218

Definition at line 310 of file timelib.h.

◆ TIMELIB_ERR_NO_FOUR_DIGIT_YEAR

#define TIMELIB_ERR_NO_FOUR_DIGIT_YEAR   0x20e

Definition at line 300 of file timelib.h.

◆ TIMELIB_ERR_NO_FOUR_DIGIT_YEAR_ISO

#define TIMELIB_ERR_NO_FOUR_DIGIT_YEAR_ISO   0x21d

Definition at line 315 of file timelib.h.

◆ TIMELIB_ERR_NO_MERIDIAN

#define TIMELIB_ERR_NO_MERIDIAN   0x212

Definition at line 304 of file timelib.h.

◆ TIMELIB_ERR_NO_SEP_SYMBOL

#define TIMELIB_ERR_NO_SEP_SYMBOL   0x216

Definition at line 308 of file timelib.h.

◆ TIMELIB_ERR_NO_SIX_DIGIT_MICROSECOND

#define TIMELIB_ERR_NO_SIX_DIGIT_MICROSECOND   0x215

Definition at line 307 of file timelib.h.

◆ TIMELIB_ERR_NO_TEXTUAL_DAY

#define TIMELIB_ERR_NO_TEXTUAL_DAY   0x208

Definition at line 294 of file timelib.h.

◆ TIMELIB_ERR_NO_TEXTUAL_MONTH

#define TIMELIB_ERR_NO_TEXTUAL_MONTH   0x20c

Definition at line 298 of file timelib.h.

◆ TIMELIB_ERR_NO_THREE_DIGIT_DAY_OF_YEAR

#define TIMELIB_ERR_NO_THREE_DIGIT_DAY_OF_YEAR   0x20a

Definition at line 296 of file timelib.h.

◆ TIMELIB_ERR_NO_THREE_DIGIT_MILLISECOND

#define TIMELIB_ERR_NO_THREE_DIGIT_MILLISECOND   0x21c

Definition at line 314 of file timelib.h.

◆ TIMELIB_ERR_NO_TWO_DIGIT_DAY

#define TIMELIB_ERR_NO_TWO_DIGIT_DAY   0x209

Definition at line 295 of file timelib.h.

◆ TIMELIB_ERR_NO_TWO_DIGIT_HOUR

#define TIMELIB_ERR_NO_TWO_DIGIT_HOUR   0x20f

Definition at line 301 of file timelib.h.

◆ TIMELIB_ERR_NO_TWO_DIGIT_MINUTE

#define TIMELIB_ERR_NO_TWO_DIGIT_MINUTE   0x213

Definition at line 305 of file timelib.h.

◆ TIMELIB_ERR_NO_TWO_DIGIT_MONTH

#define TIMELIB_ERR_NO_TWO_DIGIT_MONTH   0x20b

Definition at line 297 of file timelib.h.

◆ TIMELIB_ERR_NO_TWO_DIGIT_SECOND

#define TIMELIB_ERR_NO_TWO_DIGIT_SECOND   0x214

Definition at line 306 of file timelib.h.

◆ TIMELIB_ERR_NO_TWO_DIGIT_WEEK

#define TIMELIB_ERR_NO_TWO_DIGIT_WEEK   0x21e

Definition at line 316 of file timelib.h.

◆ TIMELIB_ERR_NO_TWO_DIGIT_YEAR

#define TIMELIB_ERR_NO_TWO_DIGIT_YEAR   0x20d

Definition at line 299 of file timelib.h.

◆ TIMELIB_ERR_NUMBER_OUT_OF_RANGE

#define TIMELIB_ERR_NUMBER_OUT_OF_RANGE   0x226

Definition at line 324 of file timelib.h.

◆ TIMELIB_ERR_TRAILING_DATA

#define TIMELIB_ERR_TRAILING_DATA   0x21a

Definition at line 312 of file timelib.h.

◆ TIMELIB_ERR_TZID_NOT_FOUND

#define TIMELIB_ERR_TZID_NOT_FOUND   0x202

Definition at line 288 of file timelib.h.

◆ TIMELIB_ERR_UNEXPECTED_CHARACTER

#define TIMELIB_ERR_UNEXPECTED_CHARACTER   0x205

Definition at line 291 of file timelib.h.

◆ TIMELIB_ERR_UNEXPECTED_DATA

#define TIMELIB_ERR_UNEXPECTED_DATA   0x207

Definition at line 293 of file timelib.h.

◆ TIMELIB_ERR_WRONG_FORMAT_SEP

#define TIMELIB_ERR_WRONG_FORMAT_SEP   0x219

Definition at line 311 of file timelib.h.

◆ TIMELIB_ERROR_CANNOT_ALLOCATE

#define TIMELIB_ERROR_CANNOT_ALLOCATE   0x01

Definition at line 388 of file timelib.h.

◆ TIMELIB_ERROR_CORRUPT_NO_64BIT_PREAMBLE

#define TIMELIB_ERROR_CORRUPT_NO_64BIT_PREAMBLE   0x03

Definition at line 390 of file timelib.h.

◆ TIMELIB_ERROR_CORRUPT_NO_ABBREVIATION

#define TIMELIB_ERROR_CORRUPT_NO_ABBREVIATION   0x04

Definition at line 391 of file timelib.h.

◆ TIMELIB_ERROR_CORRUPT_POSIX_STRING

#define TIMELIB_ERROR_CORRUPT_POSIX_STRING   0x08

Definition at line 395 of file timelib.h.

◆ TIMELIB_ERROR_CORRUPT_TRANSITIONS_DONT_INCREASE

#define TIMELIB_ERROR_CORRUPT_TRANSITIONS_DONT_INCREASE   0x02

Definition at line 389 of file timelib.h.

◆ TIMELIB_ERROR_EMPTY_POSIX_STRING

#define TIMELIB_ERROR_EMPTY_POSIX_STRING   0x09 /* Warns if the POSIX string is empty, but still produces results */

Definition at line 396 of file timelib.h.

◆ TIMELIB_ERROR_NO_ERROR

#define TIMELIB_ERROR_NO_ERROR   0x00

Definition at line 387 of file timelib.h.

◆ TIMELIB_ERROR_NO_SUCH_TIMEZONE

#define TIMELIB_ERROR_NO_SUCH_TIMEZONE   0x06

Definition at line 393 of file timelib.h.

◆ TIMELIB_ERROR_SLIM_FILE

#define TIMELIB_ERROR_SLIM_FILE   0x07 /* Warns if the file is SLIM, but we can't read it */

Definition at line 394 of file timelib.h.

◆ TIMELIB_ERROR_UNSUPPORTED_VERSION

#define TIMELIB_ERROR_UNSUPPORTED_VERSION   0x05

Definition at line 392 of file timelib.h.

◆ TIMELIB_EXTENDED_VERSION

#define TIMELIB_EXTENDED_VERSION   20221201

Definition at line 34 of file timelib.h.

◆ timelib_free

#define timelib_free   free

Definition at line 369 of file timelib.h.

◆ TIMELIB_LL_CONST

#define TIMELIB_LL_CONST ( n)
Value:
n ## ll
zend_long n
Definition ffi.c:4979

Definition at line 137 of file timelib.h.

◆ TIMELIB_LONG_FMT

#define TIMELIB_LONG_FMT   "%" PRId32

Definition at line 126 of file timelib.h.

◆ TIMELIB_LONG_MAX

#define TIMELIB_LONG_MAX   INT32_MAX

Definition at line 123 of file timelib.h.

◆ TIMELIB_LONG_MIN

#define TIMELIB_LONG_MIN   INT32_MIN

Definition at line 124 of file timelib.h.

◆ timelib_malloc

#define timelib_malloc   malloc

Definition at line 365 of file timelib.h.

◆ TIMELIB_NO_CLONE

#define TIMELIB_NO_CLONE   0x02

Definition at line 380 of file timelib.h.

◆ TIMELIB_NONE

#define TIMELIB_NONE   0x00

Definition at line 378 of file timelib.h.

◆ TIMELIB_OVERRIDE_TIME

#define TIMELIB_OVERRIDE_TIME   0x01

Definition at line 379 of file timelib.h.

◆ TIMELIB_POSIX_TRANS_TYPE_JULIAN_FEB29

#define TIMELIB_POSIX_TRANS_TYPE_JULIAN_FEB29   2

Definition at line 152 of file timelib.h.

◆ TIMELIB_POSIX_TRANS_TYPE_JULIAN_NO_FEB29

#define TIMELIB_POSIX_TRANS_TYPE_JULIAN_NO_FEB29   1

Definition at line 151 of file timelib.h.

◆ TIMELIB_POSIX_TRANS_TYPE_MWD

#define TIMELIB_POSIX_TRANS_TYPE_MWD   3

Definition at line 153 of file timelib.h.

◆ timelib_realloc

#define timelib_realloc   realloc

Definition at line 366 of file timelib.h.

◆ timelib_strdup

#define timelib_strdup   strdup

Definition at line 368 of file timelib.h.

◆ timelib_strndup

#define timelib_strndup   strndup

Definition at line 374 of file timelib.h.

◆ TIMELIB_ULONG_FMT

#define TIMELIB_ULONG_FMT   "%" PRIu32

Definition at line 127 of file timelib.h.

◆ TIMELIB_ULONG_MAX

#define TIMELIB_ULONG_MAX   UINT32_MAX

Definition at line 125 of file timelib.h.

◆ TIMELIB_UNSET

#define TIMELIB_UNSET   -9999999

Definition at line 382 of file timelib.h.

◆ TIMELIB_USE_BUILTIN_STRNDUP

#define TIMELIB_USE_BUILTIN_STRNDUP   0

Definition at line 373 of file timelib.h.

◆ TIMELIB_VERSION

#define TIMELIB_VERSION   202212

Definition at line 33 of file timelib.h.

◆ TIMELIB_WARN_DOUBLE_TZ

#define TIMELIB_WARN_DOUBLE_TZ   0x101

Definition at line 282 of file timelib.h.

◆ TIMELIB_WARN_INVALID_DATE

#define TIMELIB_WARN_INVALID_DATE   0x103

Definition at line 284 of file timelib.h.

◆ TIMELIB_WARN_INVALID_TIME

#define TIMELIB_WARN_INVALID_TIME   0x102

Definition at line 283 of file timelib.h.

◆ TIMELIB_WARN_MASK

#define TIMELIB_WARN_MASK   0x1ff

Definition at line 279 of file timelib.h.

◆ TIMELIB_WARN_TRAILING_DATA

#define TIMELIB_WARN_TRAILING_DATA   0x11a

Definition at line 285 of file timelib.h.

◆ TIMELIB_ZONETYPE_ABBR

#define TIMELIB_ZONETYPE_ABBR   2

Definition at line 328 of file timelib.h.

◆ TIMELIB_ZONETYPE_ID

#define TIMELIB_ZONETYPE_ID   3

Definition at line 329 of file timelib.h.

◆ TIMELIB_ZONETYPE_NONE

#define TIMELIB_ZONETYPE_NONE   0

Definition at line 326 of file timelib.h.

◆ TIMELIB_ZONETYPE_OFFSET

#define TIMELIB_ZONETYPE_OFFSET   1

Definition at line 327 of file timelib.h.

Typedef Documentation

◆ timelib_abbr_info

◆ timelib_error_container

◆ timelib_error_message

◆ timelib_format_config

◆ timelib_format_specifier

◆ timelib_format_specifier_code

◆ timelib_long

typedef int32_t timelib_long

Definition at line 121 of file timelib.h.

◆ timelib_posix_str

◆ timelib_posix_trans_info

◆ timelib_posix_transitions

◆ timelib_rel_time

◆ timelib_sll

typedef signed long long timelib_sll

Definition at line 136 of file timelib.h.

◆ timelib_time

typedef struct _timelib_time timelib_time

◆ timelib_time_offset

◆ timelib_tz_get_wrapper

typedef timelib_tzinfo *(* timelib_tz_get_wrapper) (const char *tzname, const timelib_tzdb *tzdb, int *error_code)

Definition at line 458 of file timelib.h.

◆ timelib_tz_lookup_table

◆ timelib_tzdb

typedef struct _timelib_tzdb timelib_tzdb

◆ timelib_tzdb_index_entry

◆ timelib_tzinfo

◆ timelib_ull

typedef unsigned long long timelib_ull

Definition at line 135 of file timelib.h.

◆ timelib_ulong

typedef uint32_t timelib_ulong

Definition at line 122 of file timelib.h.

◆ tlinfo

typedef struct _tlinfo tlinfo

Definition at line 141 of file timelib.h.

◆ tlocinfo

typedef struct _tlocinfo tlocinfo

◆ ttinfo

typedef struct _ttinfo ttinfo

Definition at line 140 of file timelib.h.

Enumeration Type Documentation

◆ _timelib_format_specifier_code

Enumerator
TIMELIB_FORMAT_ALLOW_EXTRA_CHARACTERS 
TIMELIB_FORMAT_ANY_SEPARATOR 
TIMELIB_FORMAT_DAY_TWO_DIGIT 
TIMELIB_FORMAT_DAY_TWO_DIGIT_PADDED 
TIMELIB_FORMAT_DAY_OF_WEEK_ISO 
TIMELIB_FORMAT_DAY_OF_WEEK 
TIMELIB_FORMAT_DAY_OF_YEAR 
TIMELIB_FORMAT_DAY_SUFFIX 
TIMELIB_FORMAT_END 
TIMELIB_FORMAT_EPOCH_SECONDS 
TIMELIB_FORMAT_ESCAPE 
TIMELIB_FORMAT_HOUR_TWO_DIGIT_12_MAX 
TIMELIB_FORMAT_HOUR_TWO_DIGIT_12_MAX_PADDED 
TIMELIB_FORMAT_HOUR_TWO_DIGIT_24_MAX 
TIMELIB_FORMAT_HOUR_TWO_DIGIT_24_MAX_PADDED 
TIMELIB_FORMAT_LITERAL 
TIMELIB_FORMAT_MERIDIAN 
TIMELIB_FORMAT_MICROSECOND_SIX_DIGIT 
TIMELIB_FORMAT_MILLISECOND_THREE_DIGIT 
TIMELIB_FORMAT_MINUTE_TWO_DIGIT 
TIMELIB_FORMAT_MONTH_TWO_DIGIT 
TIMELIB_FORMAT_MONTH_TWO_DIGIT_PADDED 
TIMELIB_FORMAT_RANDOM_CHAR 
TIMELIB_FORMAT_RESET_ALL 
TIMELIB_FORMAT_RESET_ALL_WHEN_NOT_SET 
TIMELIB_FORMAT_SECOND_TWO_DIGIT 
TIMELIB_FORMAT_SEPARATOR 
TIMELIB_FORMAT_SKIP_TO_SEPARATOR 
TIMELIB_FORMAT_TEXTUAL_DAY_3_LETTER 
TIMELIB_FORMAT_TEXTUAL_DAY_FULL 
TIMELIB_FORMAT_TEXTUAL_MONTH_3_LETTER 
TIMELIB_FORMAT_TEXTUAL_MONTH_FULL 
TIMELIB_FORMAT_TIMEZONE_OFFSET 
TIMELIB_FORMAT_TIMEZONE_OFFSET_MINUTES 
TIMELIB_FORMAT_WEEK_OF_YEAR_ISO 
TIMELIB_FORMAT_WEEK_OF_YEAR 
TIMELIB_FORMAT_WHITESPACE 
TIMELIB_FORMAT_YEAR_TWO_DIGIT 
TIMELIB_FORMAT_YEAR_FOUR_DIGIT 
TIMELIB_FORMAT_YEAR_EXPANDED 
TIMELIB_FORMAT_YEAR_ISO 

Definition at line 402 of file timelib.h.

Function Documentation

◆ timelib_add()

timelib_time * timelib_add ( timelib_time * t,
timelib_rel_time * interval )

Adds the relative time information 'interval' to the base time 't'.

This can be a relative time as created by 'timelib_diff', but also by more complex statements such as "next workday".

Definition at line 211 of file interval.c.

◆ timelib_add_wall()

timelib_time * timelib_add_wall ( timelib_time * t,
timelib_rel_time * interval )

Definition at line 284 of file interval.c.

◆ timelib_astro_rise_set_altitude()

int timelib_astro_rise_set_altitude ( timelib_time * t_loc,
double lon,
double lat,
double altit,
int upper_limb,
double * h_rise,
double * h_set,
timelib_sll * ts_rise,
timelib_sll * ts_set,
timelib_sll * ts_transit )

Calculates when the Sun is above a certain latitude.

Parameters:

  • time: A timelib_time time describing that needs to specific midnight for a specific day.
  • lon: The longitude of the observer (East positive, West negative).
  • lat: The latitude of the observer (North positive, South negative).
  • altit: The altitude. Set to -35/60 for rise/set, -6 for civil twilight, -12 for nautical, and -18 for astronomical twilight.
  • upper_limb: set to non-zero for rise/set calculations, and 0 for twilight calculations.

Out Parameters:

  • h_rise: The decimal hour when the Sun rises
  • h_set: The decimal hour when the Sun sets
  • ts_rise: The Unix timestamp of the Sun rising
  • ts_set: The Unix timestamp of the Sun setting
  • ts_transit: The Unix timestmap of the Sun transitting through South

Return Values:

  • 0: The Sun rises and sets.
  • +1: The Sun is always above the horizon. (ts_rise is set to ts_transit - (12 * 3600); ts_set is set to ts_transit + (12 * 3600).
  • -1: The Sun is awlays below the horizon. (ts_rise and ts_set are set to ts_transit)

Note: timestamp = unixtimestamp (NEEDS to be 00:00:00 UT) Eastern longitude positive, Western longitude negative Northern latitude positive, Southern latitude negative The longitude value IS critical in this function! altit = the altitude which the Sun should cross Set to -35/60 degrees for rise/set, -6 degrees for civil, -12 degrees for nautical and -18 degrees for astronomical twilight. upper_limb: non-zero -> upper limb, zero -> center Set to non-zero (e.g. 1) when computing rise/set times, and to zero when computing start/end of twilight. *rise = where to store the rise time *set = where to store the set time Both times are relative to the specified altitude, and thus this function can be used to compute various twilight times, as well as rise/set times Return value: 0 = sun rises/sets this day, times stored at *trise and *tset. +1 = sun above the specified "horizon" 24 hours. *trise set to time when the sun is at south, minus 12 hours while *tset is set to the south time plus 12 hours. "Day" length = 24 hours -1 = sun is below the specified "horizon" 24 hours "Day" length = 0 hours, *trise and *tset are both set to the time when the sun is at south.

Definition at line 212 of file astro.c.

◆ timelib_builtin_db()

const timelib_tzdb * timelib_builtin_db ( void )

Returns a pointer to the built-in time zone database.

You must not free the returned pointer as it is part of the text segment.

Definition at line 606 of file parse_tz.c.

◆ timelib_date_from_isodate()

void timelib_date_from_isodate ( timelib_sll iy,
timelib_sll iw,
timelib_sll id,
timelib_sll * y,
timelib_sll * m,
timelib_sll * d )

Definition at line 160 of file dow.c.

◆ timelib_date_to_int()

timelib_long timelib_date_to_int ( timelib_time * d,
int * error )

Converts the 'sse' value of 'd' to a timelib_long type.

If the value fits in the TIMELIB_LONG_MIN and TIMELIB_LONG_MAX range, the value is cast to (timelib_long) and returned. If *error is not a NULL pointer, it will be set to 0.

If the value does not fit in the range, the function returns 0 and if *error is not a NULL pointer, it will be set to 1.

timelib_long is a 32 bit signed long integer on 32 bit platforms, and a 64 bit signed long long integer on 64 bit platforms. In other words, it makes sure that the value in 'sse' (which is always a signed long long 64 bit integer) can be used safely outside of the library.

Definition at line 170 of file timelib.c.

◆ timelib_day_of_week()

timelib_sll timelib_day_of_week ( timelib_sll y,
timelib_sll m,
timelib_sll d )

Definition at line 67 of file dow.c.

◆ timelib_day_of_year()

timelib_sll timelib_day_of_year ( timelib_sll y,
timelib_sll m,
timelib_sll d )

Definition at line 83 of file dow.c.

◆ timelib_daynr_from_weeknr()

timelib_sll timelib_daynr_from_weeknr ( timelib_sll iy,
timelib_sll iw,
timelib_sll id )

Definition at line 147 of file dow.c.

◆ timelib_days_in_month()

timelib_sll timelib_days_in_month ( timelib_sll y,
timelib_sll m )

Definition at line 88 of file dow.c.

◆ timelib_decimal_hour_to_hms()

void timelib_decimal_hour_to_hms ( double h,
int * hour,
int * min,
int * sec )

Converts a decimal hour into hour/min/sec components

Definition at line 188 of file timelib.c.

◆ timelib_diff()

timelib_rel_time * timelib_diff ( timelib_time * one,
timelib_time * two )

Calculates the difference between two times

The result is a timelib_rel_time structure that describes how you can convert from 'one' to 'two' with 'timelib_add'. This does not necessarily mean that you can go from 'two' to 'one' by using 'timelib_sub' due to the way months and days are calculated.

Definition at line 146 of file interval.c.

◆ timelib_diff_days()

int timelib_diff_days ( timelib_time * one,
timelib_time * two )

Calculates the difference in full days between two times

The result is the number of full days between 'one' and 'two'. It does take into account 23 and 25 hour (and variants) days when the zone_type is TIMELIB_ZONETYPE_ID and have the same TZID for 'one' and 'two'.

Definition at line 181 of file interval.c.

◆ timelib_do_normalize()

void timelib_do_normalize ( timelib_time * base)

Takes the information from the y/m/d/h/i/s fields and makes sure their values are in the right range.

If a value under- or overflows it will adjust the larger measure up (or down). It also takes into account leap days.

Definition at line 226 of file tm2unixtime.c.

◆ timelib_do_rel_normalize()

void timelib_do_rel_normalize ( timelib_time * base,
timelib_rel_time * rt )

Takes the information from the y/m/d/h/i/s fields of 'rt' and makes sure their values are in the right range.

If a value under- or overflows it will adjust the larger measure up (or down). As this function operates on a relative date/time, it also takes into account leap days and correctly accounts for the difference depending on the base date/time in 'base'.

Definition at line 188 of file tm2unixtime.c.

◆ timelib_dump_date()

void timelib_dump_date ( timelib_time * d,
int options )

Displays debugging information about the date/time information stored in 'd'.

'options' is a bit field, where:

  • 1 controls whether the relative time portion is shown.
  • 2 controls whether the zone type is shown.

Definition at line 305 of file timelib.c.

◆ timelib_dump_rel_time()

void timelib_dump_rel_time ( timelib_rel_time * d)

Displays debugging information about the relative time information stored in 'd'.

Definition at line 376 of file timelib.c.

◆ timelib_dump_tzinfo()

void timelib_dump_tzinfo ( timelib_tzinfo * tz)

Displays debugging information about the time zone information in 'tz'.

Definition at line 510 of file parse_tz.c.

◆ timelib_epoch_days_from_time()

timelib_sll timelib_epoch_days_from_time ( timelib_time * time)

Returns the number of days from the y/m/d fields of 'time' since the Unix Epoch.

Definition at line 453 of file tm2unixtime.c.

◆ timelib_error_container_dtor()

void timelib_error_container_dtor ( timelib_error_container * errors)

Frees up the resources allocated while converting strings to timelib_time structures with the timelib_strtotime and timelib_strtointerval functions.

Definition at line 155 of file timelib.c.

◆ timelib_fill_holes()

void timelib_fill_holes ( timelib_time * parsed,
timelib_time * now,
int options )

Definition at line 25529 of file parse_date.c.

◆ timelib_get_current_offset()

timelib_sll timelib_get_current_offset ( timelib_time * t)

Returns the UTC offset currently applicable for the information stored in 't'.

The value returned is the UTC offset in seconds East.

Definition at line 937 of file parse_tz.c.

◆ timelib_get_error_message()

const char * timelib_get_error_message ( int error_code)

Returns a static string containing an error message belonging to a specific error code.

Definition at line 51 of file timelib.c.

◆ timelib_get_time_zone_info()

timelib_time_offset * timelib_get_time_zone_info ( timelib_sll ts,
timelib_tzinfo * tz )

Returns offset information with time zone 'tz' for the time stamp 'ts'.

The returned information contains: the offset in seconds East of UTC (in 'offset'), whether DST is active ('is_dst'), what the current time zone abbreviation is ('abbr') and the transition time that got to this state (in 'transition_time');

Definition at line 881 of file parse_tz.c.

◆ timelib_get_time_zone_offset_info()

int timelib_get_time_zone_offset_info ( timelib_sll ts,
timelib_tzinfo * tz,
int32_t * offset,
timelib_sll * transition_time,
unsigned int * is_dst )

Returns offset information with time zone 'tz' for the time stamp 'ts'.

The returned information contains: the offset in seconds East of UTC (in the output parameter 'offset'), whether DST is active (in the output parameter 'is_dst'), and the transition time that got to this state (in the output parameter 'transition_time'); if NULL is passed, the value is not retrieved

Returns 1 if successful, 0 for failure.

Definition at line 913 of file parse_tz.c.

◆ timelib_get_transitions_for_year()

void timelib_get_transitions_for_year ( timelib_tzinfo * tz,
timelib_sll year,
timelib_posix_transitions * transitions )

Calculate the two yearly to/from DST

Definition at line 500 of file parse_posix.c.

◆ timelib_hms_to_decimal_hour()

void timelib_hms_to_decimal_hour ( int hour,
int min,
int sec,
double * h )

Converts hour/min/sec values into a decimal hour

Definition at line 209 of file timelib.c.

◆ timelib_hms_to_seconds()

timelib_sll timelib_hms_to_seconds ( timelib_sll h,
timelib_sll m,
timelib_sll s )

Converts hour/min/sec values into seconds

Definition at line 227 of file timelib.c.

◆ timelib_hmsf_to_decimal_hour()

void timelib_hmsf_to_decimal_hour ( int hour,
int min,
int sec,
int us,
double * h )

Converts hour/min/sec/micro sec values into a decimal hour

Definition at line 218 of file timelib.c.

◆ timelib_iso_day_of_week()

timelib_sll timelib_iso_day_of_week ( timelib_sll y,
timelib_sll m,
timelib_sll d )

Definition at line 72 of file dow.c.

◆ timelib_isodate_from_date()

void timelib_isodate_from_date ( timelib_sll y,
timelib_sll m,
timelib_sll d,
timelib_sll * iy,
timelib_sll * iw,
timelib_sll * id )

Definition at line 141 of file dow.c.

◆ timelib_isoweek_from_date()

void timelib_isoweek_from_date ( timelib_sll y,
timelib_sll m,
timelib_sll d,
timelib_sll * iw,
timelib_sll * iy )

Definition at line 93 of file dow.c.

◆ timelib_parse_from_format()

timelib_time * timelib_parse_from_format ( const char * format,
const char * s,
size_t len,
timelib_error_container ** errors,
const timelib_tzdb * tzdb,
timelib_tz_get_wrapper tz_get_wrapper )

Definition at line 25032 of file parse_date.c.

◆ timelib_parse_from_format_with_map()

timelib_time * timelib_parse_from_format_with_map ( const char * format,
const char * s,
size_t len,
timelib_error_container ** errors,
const timelib_tzdb * tzdb,
timelib_tz_get_wrapper tz_get_wrapper,
const timelib_format_config * format_config )

Definition at line 25037 of file parse_date.c.

◆ timelib_parse_posix_str()

timelib_posix_str * timelib_parse_posix_str ( const char * posix)

Definition at line 323 of file parse_posix.c.

◆ timelib_parse_tzfile()

timelib_tzinfo * timelib_parse_tzfile ( const char * timezone,
const timelib_tzdb * tzdb,
int * error_code )

Converts the binary stored time zone information from 'tzdb' for the time zone 'timezone' into a structure the library can use for calculations.

The function can be used on both timelib_builtin_db as well as a time zone db as opened by timelib_zoneinfo.

'error_code' must not be a null pointer, and will always be written to. If the value is TIMELIB_ERROR_NO_ERROR then the file was parsed without problems.

The function will return null upon failure, and also set an error code through 'error_code'.

The error code is one of the TIMELIB_ERROR_* constants as listed above. These error constants can be converted into a string by timelib_get_error_message.

If the function returns not-null, the 'error_code' might have a non-null value that can be used to detect incompatibilities. The only one that is currently detected is whether the file is a 'slim' file, in which case 'error_code' will be set to TIMELIB_ERROR_SLIM_FILE.

This function allocates memory for the new time zone structure, which must be freed after use. Although it is recommended that a cache of each used time zone is kept.

Definition at line 662 of file parse_tz.c.

◆ timelib_parse_zone()

timelib_long timelib_parse_zone ( const char ** ptr,
int * dst,
timelib_time * t,
int * tz_not_found,
const timelib_tzdb * tzdb,
timelib_tz_get_wrapper tz_wrapper )

DEPRECATED, but still used by PHP.

Definition at line 940 of file parse_date.c.

◆ timelib_posix_str_dtor()

void timelib_posix_str_dtor ( timelib_posix_str * ps)

Definition at line 305 of file parse_posix.c.

◆ timelib_rel_time_clone()

timelib_rel_time * timelib_rel_time_clone ( timelib_rel_time * tz)

Creates a new timelib_rel_time resource and copies over the information from 'tz'.

Must be freed with 'timelib_rel_time_dtor'.

Definition at line 114 of file timelib.c.

◆ timelib_rel_time_ctor()

timelib_rel_time * timelib_rel_time_ctor ( void )

Allocates resources for the relative time structure.

Must be freed with 'timelib_rel_time_dtor'.

Definition at line 101 of file timelib.c.

◆ timelib_rel_time_dtor()

void timelib_rel_time_dtor ( timelib_rel_time * t)

Frees up the resources as allocated through 'timelib_rel_time_ctor'.

Definition at line 109 of file timelib.c.

◆ timelib_same_timezone()

int timelib_same_timezone ( timelib_time * one,
timelib_time * two )

Returns whether the timezone information in *one and *two are the same

A timezone is considered the same if:

  • the ->zone_type values are the same for *one and *two
  • for TYPE_ABBR and TYPE_OFFSET, ->z + (->dst * 3600), is the same
  • for TYPE_ID, the zone's names are the same

Definition at line 955 of file parse_tz.c.

◆ timelib_set_timezone()

void timelib_set_timezone ( timelib_time * t,
timelib_tzinfo * tz )

Attaches the time zone information in 'tz' to to 't'.

It fetches the right UTC offset that is currently stored in the time stamp field in 't' ('sse'), and assigns that to the 'z' field and 'dst' field (whether DST is in effect at the time). It also sets the current abbreviation to the 'tz_addr' field, making sure that if a value was already set it was freed.

The time zone information in 'tz' is not duplicated into the 't' field so it should not be freed until all timelib_time* variables have been freed as well.

Definition at line 191 of file unixtime2tm.c.

◆ timelib_set_timezone_from_abbr()

void timelib_set_timezone_from_abbr ( timelib_time * t,
timelib_abbr_info abbr_info )

Attaches the information from 'abbr_info' as time zone information to 't'.

The timelib_abbr_info struct contains an abbreviation ('abbr') which string value is duplicated, as well as a 'utc_offset' and 'dst' flag. It only supports a 'dst' change over of 1 hour.

Definition at line 177 of file unixtime2tm.c.

◆ timelib_set_timezone_from_offset()

void timelib_set_timezone_from_offset ( timelib_time * t,
timelib_sll utc_offset )

Attaches the UTC offset as time zone information to 't'.

'utc_offset' is in seconds East of UTC.

Definition at line 163 of file unixtime2tm.c.

◆ timelib_strtointerval()

void timelib_strtointerval ( const char * s,
size_t len,
timelib_time ** begin,
timelib_time ** end,
timelib_rel_time ** period,
int * recurrences,
timelib_error_container ** errors )

Parses a subset of an ISO 8601 intervals specification string into its constituent parts.

If the **errors points to a timelib_error_container variable, warnings and errors will be recorded. You are responsible for freeing the stored information with timelib_error_container_dtor(). To see whether errors have occurred, inspect errors->errors_count. To see whether warnings have occurred, inspect errors->warnings_count.

Definition at line 971 of file parse_iso_intervals.c.

◆ timelib_strtotime()

timelib_time * timelib_strtotime ( const char * s,
size_t len,
timelib_error_container ** errors,
const timelib_tzdb * tzdb,
timelib_tz_get_wrapper tz_get_wrapper )

Definition at line 24849 of file parse_date.c.

◆ timelib_sub()

timelib_time * timelib_sub ( timelib_time * t,
timelib_rel_time * interval )

Subtracts the relative time information 'interval' to the base time 't'.

This can be a relative time as created by 'timelib_diff'. Unlike with 'timelib_add', this does not support more complex statements such as "next workday".

Definition at line 242 of file interval.c.

◆ timelib_sub_wall()

timelib_time * timelib_sub_wall ( timelib_time * t,
timelib_rel_time * interval )

Definition at line 338 of file interval.c.

◆ timelib_time_clone()

timelib_time * timelib_time_clone ( timelib_time * orig)

Creates a new timelib_time resource and copies over the information from 'orig'.

Must be freed with 'timelib_time_dtor'.

Definition at line 88 of file timelib.c.

◆ timelib_time_compare()

int timelib_time_compare ( timelib_time * t1,
timelib_time * t2 )

Compares two timelib_time structures and returns which one is earlier in time.

To decide which comes earlier it uses the 'sse' (Seconds Since Epoch) and 'us' (microseconds) fields.

Returns -1 if t1 < t2, 0 if t1 == t2, and -1 if t1 > t2.

Definition at line 75 of file timelib.c.

◆ timelib_time_ctor()

timelib_time * timelib_time_ctor ( void )

Allocates resources for the time structure.

Must be freed with 'timelib_time_dtor'.

Definition at line 61 of file timelib.c.

◆ timelib_time_dtor()

void timelib_time_dtor ( timelib_time * t)

Frees up the resources as allocated through 'timelib_time_ctor'.

Definition at line 69 of file timelib.c.

◆ timelib_time_offset_ctor()

timelib_time_offset * timelib_time_offset_ctor ( void )

Allocates resources for the time offset structure.

Must be freed with 'timelib_time_offset_dtor'.

Definition at line 133 of file timelib.c.

◆ timelib_time_offset_dtor()

void timelib_time_offset_dtor ( timelib_time_offset * t)

Frees up the resources as allocated through 'timelib_time_offset_ctor'.

Definition at line 141 of file timelib.c.

◆ timelib_timestamp_is_in_dst()

int timelib_timestamp_is_in_dst ( timelib_sll ts,
timelib_tzinfo * tz )

Returns whether DST is active with time zone 'tz' for the time stamp 'ts'.

Returns 0 if DST is not active, 1 if DST is active, or -1 if no transitions were available through 'tz'.

Definition at line 870 of file parse_tz.c.

◆ timelib_timezone_abbreviations_list()

const timelib_tz_lookup_table * timelib_timezone_abbreviations_list ( void )

Definition at line 25586 of file parse_date.c.

◆ timelib_timezone_id_from_abbr()

const char * timelib_timezone_id_from_abbr ( const char * abbr,
timelib_long gmtoffset,
int isdst )

Definition at line 25574 of file parse_date.c.

◆ timelib_timezone_id_is_valid()

int timelib_timezone_id_is_valid ( const char * timezone,
const timelib_tzdb * tzdb )

Returns whether the time zone ID 'timezone' is available in the time zone database as pointed to be 'tzdb'.

Definition at line 617 of file parse_tz.c.

◆ timelib_timezone_identifiers_list()

const timelib_tzdb_index_entry * timelib_timezone_identifiers_list ( const timelib_tzdb * tzdb,
int * count )

Returns a pointer to the start of an array containing a list of timezone identifiers.

The amount of entries in the array is returned through the 'count' OUT parameter.

Each entry contains the time zone ID ('id' field), and the position within the time zone information ('pos' field). The pos field should not be used.

Definition at line 611 of file parse_tz.c.

◆ timelib_ts_to_j2000()

double timelib_ts_to_j2000 ( timelib_sll ts)

Converts the Unix Epoch time stamp 'ts' to the J2000 epoch

The value returned is the number of whole days since 2000-01-01T12:00:00 UTC: https://en.wikipedia.org/wiki/Epoch_(astronomy)#Julian_years_and_J2000

Definition at line 310 of file astro.c.

◆ timelib_ts_to_julianday()

double timelib_ts_to_julianday ( timelib_sll ts)

Converts the Unix Epoch time stamp 'ts' to a Julian Day

The value returned is the number of whole days since -4714-11-24T12:00:00 UTC (in the proleptic Gregorian calendar): https://en.wikipedia.org/wiki/Julian_day

Definition at line 299 of file astro.c.

◆ timelib_tzinfo_clone()

timelib_tzinfo * timelib_tzinfo_clone ( timelib_tzinfo * tz)

Deep-clones a timelib_tzinfo structure.

This allocates resources that need to be freed with 'timelib_tzinfo_dtor'

Definition at line 745 of file parse_tz.c.

◆ timelib_tzinfo_dtor()

void timelib_tzinfo_dtor ( timelib_tzinfo * tz)

Frees up the resources allocated by 'timelib_parse_tzfile'.

Definition at line 728 of file parse_tz.c.

◆ timelib_unixtime2date()

void timelib_unixtime2date ( timelib_sll ts,
timelib_sll * y,
timelib_sll * m,
timelib_sll * d )

Takes the unix timestamp in seconds from 'ts', and calculates y, m, and d, in the proleptic Gregorian calendar.

It uses the algorithm from howardhinnant.github.io/date_algorithms.html

Definition at line 29 of file unixtime2tm.c.

◆ timelib_unixtime2gmt()

void timelib_unixtime2gmt ( timelib_time * tm,
timelib_sll ts )

Takes the unix timestamp in seconds from 'ts' and populates the y/m/d/h/i/s fields of 'tm' without taking time zones into account

Definition at line 57 of file unixtime2tm.c.

◆ timelib_unixtime2local()

void timelib_unixtime2local ( timelib_time * tm,
timelib_sll ts )

Takes the Unix timestamp from 'ts', and calculates the y/m/d/h/i/s fields according to the time zone information attached to 'tm'.

Definition at line 120 of file unixtime2tm.c.

◆ timelib_update_from_sse()

void timelib_update_from_sse ( timelib_time * tm)

Takes the Unix timestamp stored in 'tm', and calculates the y/m/d/h/i/s fields according to the time zone information attached to 'tm'.

Definition at line 83 of file unixtime2tm.c.

◆ timelib_update_ts()

void timelib_update_ts ( timelib_time * time,
timelib_tzinfo * tzi )

Uses the y/m/d/h/i/s fields to calculate and store the equivalent timestamp in the sse field.

It uses the time zone information associated with 'time' to account for the right UTC offset and/or DST rules. You can associate time zone information with the timelib_set_timezone_* functions (see below).

If the type is 'TIMELIB_ZONETYPE_ID' and there is no associated tzinfo, it will use the second argument 'tzi' to provide the rules necessary to calculate the right timestamp.

Definition at line 467 of file tm2unixtime.c.

◆ timelib_valid_date()

int timelib_valid_date ( timelib_sll y,
timelib_sll m,
timelib_sll d )

Definition at line 203 of file dow.c.

◆ timelib_valid_time()

int timelib_valid_time ( timelib_sll h,
timelib_sll i,
timelib_sll s )

Definition at line 195 of file dow.c.

◆ timelib_zoneinfo()

timelib_tzdb * timelib_zoneinfo ( const char * directory)

Scans the directory and subdirectories of 'directory' for valid time zone files and builds a time zone database out of these files.

Typically, the directory should point to '/usr/share/zoneinfo'.

Unlike 'timelib_builtin_db', the return value of this function must be freed with the 'timelib_zoneinfo_dtor' function.

◆ timelib_zoneinfo_dtor()

void timelib_zoneinfo_dtor ( timelib_tzdb * tzdb)

Frees up the resources as created through 'timelib_zoneinfo'.

This function must be used to free up all the resources that have been allocated while calling 'timelib_zoneinfo'.