php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
timelib.c File Reference
#include "timelib.h"
#include "timelib_private.h"
#include <ctype.h>
#include <math.h>

Go to the source code of this file.

Macros

#define TIMELIB_LLABS(y)
 
#define timelib_tolower(c)
 
#define MAX(a, b)
 
#define MIN(a, b)
 

Functions

const char * timelib_get_error_message (int error_code)
 
timelib_timetimelib_time_ctor (void)
 
void timelib_time_dtor (timelib_time *t)
 
int timelib_time_compare (timelib_time *t1, timelib_time *t2)
 
timelib_timetimelib_time_clone (timelib_time *orig)
 
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 *rel)
 
void timelib_time_tz_abbr_update (timelib_time *tm, const char *tz_abbr)
 
timelib_time_offsettimelib_time_offset_ctor (void)
 
void timelib_time_offset_dtor (timelib_time_offset *t)
 
char * timelib_get_tz_abbr_ptr (timelib_time *t)
 
void timelib_error_container_dtor (timelib_error_container *errors)
 
timelib_long timelib_date_to_int (timelib_time *d, int *error)
 
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)
 
int timelib_strcasecmp (const char *s1, const char *s2)
 
int timelib_strncasecmp (const char *s1, const char *s2, size_t length)
 
void timelib_dump_date (timelib_time *d, int options)
 
void timelib_dump_rel_time (timelib_rel_time *d)
 

Variables

const char * timelib_error_messages [10]
 

Macro Definition Documentation

◆ MAX

#define MAX ( a,
b )
Value:
(((a)>(b))?(a):(b))
$obj a
Definition test.php:84

Definition at line 254 of file timelib.c.

◆ MIN

#define MIN ( a,
b )
Value:
(((a)<(b))?(a):(b))

Definition at line 255 of file timelib.c.

◆ TIMELIB_LLABS

#define TIMELIB_LLABS ( y)
Value:
(y < 0 ? (y * -1) : y)

Definition at line 36 of file timelib.c.

◆ timelib_tolower

#define timelib_tolower ( c)
Value:
(timelib_tolower_map[(unsigned char)(c)])

Definition at line 251 of file timelib.c.

Function Documentation

◆ 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_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_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_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_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_tz_abbr_ptr()

char * timelib_get_tz_abbr_ptr ( timelib_time * t)

Definition at line 147 of file timelib.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_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_strcasecmp()

int timelib_strcasecmp ( const char * s1,
const char * s2 )

Definition at line 257 of file timelib.c.

◆ timelib_strncasecmp()

int timelib_strncasecmp ( const char * s1,
const char * s2,
size_t length )

Definition at line 280 of file timelib.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_time_tz_abbr_update()

void timelib_time_tz_abbr_update ( timelib_time * tm,
const char * tz_abbr )

Definition at line 121 of file timelib.c.

Variable Documentation

◆ timelib_error_messages

const char* timelib_error_messages[10]
Initial value:
= {
"No error",
"Cannot allocate buffer for parsing",
"Corrupt tzfile: The transitions in the file don't always increase",
"Corrupt tzfile: The expected 64-bit preamble is missing",
"Corrupt tzfile: No abbreviation could be found for a transition",
"The version used in this timezone identifier is unsupported",
"No timezone with this name could be found",
"A 'slim' timezone file has been detected",
"The embedded POSIX string is not valid",
"The embedded POSIX string is empty"
}

Definition at line 38 of file timelib.c.