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

Go to the source code of this file.

Data Structures

struct  _timelib_elems
 
struct  _Scanner
 
struct  _timelib_lookup_table
 
struct  _timelib_relunit
 

Macros

#define strtoll(s, f, b)
 
#define EOI   257
 
#define TIME   258
 
#define DATE   259
 
#define TIMELIB_XMLRPC_SOAP   260
 
#define TIMELIB_TIME12   261
 
#define TIMELIB_TIME24   262
 
#define TIMELIB_GNU_NOCOLON   263
 
#define TIMELIB_GNU_NOCOLON_TZ   264
 
#define TIMELIB_ISO_NOCOLON   265
 
#define TIMELIB_AMERICAN   266
 
#define TIMELIB_ISO_DATE   267
 
#define TIMELIB_DATE_FULL   268
 
#define TIMELIB_DATE_TEXT   269
 
#define TIMELIB_DATE_NOCOLON   270
 
#define TIMELIB_PG_YEARDAY   271
 
#define TIMELIB_PG_TEXT   272
 
#define TIMELIB_PG_REVERSE   273
 
#define TIMELIB_CLF   274
 
#define TIMELIB_DATE_NO_DAY   275
 
#define TIMELIB_SHORTDATE_WITH_TIME   276
 
#define TIMELIB_DATE_FULL_POINTED   277
 
#define TIMELIB_TIME24_WITH_ZONE   278
 
#define TIMELIB_ISO_WEEK   279
 
#define TIMELIB_LF_DAY_OF_MONTH   280
 
#define TIMELIB_WEEK_DAY_OF_MONTH   281
 
#define TIMELIB_TIMEZONE   300
 
#define TIMELIB_AGO   301
 
#define TIMELIB_RELATIVE   310
 
#define TIMELIB_ERROR   999
 
#define BSIZE   8192
 
#define YYCTYPE   uchar
 
#define YYCURSOR   cursor
 
#define YYLIMIT   s->lim
 
#define YYMARKER   s->ptr
 
#define YYFILL(n)
 
#define RET(i)
 
#define timelib_string_free   timelib_free
 
#define TIMELIB_HAVE_TIME()
 
#define TIMELIB_UNHAVE_TIME()
 
#define TIMELIB_HAVE_DATE()
 
#define TIMELIB_UNHAVE_DATE()
 
#define TIMELIB_HAVE_RELATIVE()
 
#define TIMELIB_HAVE_WEEKDAY_RELATIVE()
 
#define TIMELIB_HAVE_SPECIAL_RELATIVE()
 
#define TIMELIB_HAVE_TZ()
 
#define TIMELIB_INIT   s->cur = cursor; str = timelib_string(s); ptr = str
 
#define TIMELIB_DEINIT   timelib_string_free(str)
 
#define TIMELIB_ADJUST_RELATIVE_WEEKDAY()
 
#define TIMELIB_PROCESS_YEAR(x, l)
 
#define DEBUG_OUTPUT(s)
 
#define YYDEBUG(s, c)
 
#define MAX_ABBR_LEN   6
 
#define sHOUR(a)
 
#define sMIN(a)
 
#define timelib_split_free(arg)
 
#define YYMAXFILL   36
 
#define TIMELIB_CHECK_NUMBER
 
#define TIMELIB_CHECK_SIGNED_NUMBER
 

Typedefs

typedef unsigned char uchar
 
typedef struct _timelib_elems timelib_elems
 
typedef struct _Scanner Scanner
 
typedef struct _timelib_lookup_table timelib_lookup_table
 
typedef struct _timelib_relunit timelib_relunit
 

Functions

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)
 
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 *string, 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 *string, 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)
 

Macro Definition Documentation

◆ BSIZE

#define BSIZE   8192

Definition at line 86 of file parse_date.c.

◆ DATE

#define DATE   259

Definition at line 49 of file parse_date.c.

◆ DEBUG_OUTPUT

#define DEBUG_OUTPUT ( s)

Definition at line 127 of file parse_date.c.

◆ EOI

#define EOI   257

Definition at line 47 of file parse_date.c.

◆ MAX_ABBR_LEN

#define MAX_ABBR_LEN   6

Definition at line 178 of file parse_date.c.

◆ RET

#define RET ( i)
Value:
{s->cur = cursor; return i;}
char s[4]
Definition cdf.c:77

Definition at line 94 of file parse_date.c.

◆ sHOUR

#define sHOUR ( a)
Value:
(int)(a * 3600)
$obj a
Definition test.php:84

Definition at line 845 of file parse_date.c.

◆ sMIN

#define sMIN ( a)
Value:
(int)(a * 60)

Definition at line 846 of file parse_date.c.

◆ strtoll

#define strtoll ( s,
f,
b )
Value:
strtol(s, f, b)

Definition at line 43 of file parse_date.c.

◆ TIME

#define TIME   258

Definition at line 48 of file parse_date.c.

◆ TIMELIB_ADJUST_RELATIVE_WEEKDAY

#define TIMELIB_ADJUST_RELATIVE_WEEKDAY ( )
Value:
if (in->time.have_weekday_relative && (in.rel.d > 0)) { in.rel.d -= 7; }

Definition at line 109 of file parse_date.c.

◆ TIMELIB_AGO

#define TIMELIB_AGO   301

Definition at line 76 of file parse_date.c.

◆ TIMELIB_AMERICAN

#define TIMELIB_AMERICAN   266

Definition at line 58 of file parse_date.c.

◆ TIMELIB_CHECK_NUMBER

#define TIMELIB_CHECK_NUMBER
Value:
if (strchr("0123456789", *ptr) == NULL) \
{ \
add_pbf_error(s, TIMELIB_ERR_UNEXPECTED_DATA, "Unexpected data found.", string, begin); \
}
strchr(string $haystack, string $needle, bool $before_needle=false)
int begin
Definition eaw_table.h:20
void * ptr
Definition ffi.c:3814
#define NULL
Definition gdcache.h:45
#define TIMELIB_ERR_UNEXPECTED_DATA
Definition timelib.h:293

Definition at line 24929 of file parse_date.c.

◆ TIMELIB_CHECK_SIGNED_NUMBER

#define TIMELIB_CHECK_SIGNED_NUMBER
Value:
if (strchr("+-0123456789", *ptr) == NULL) \
{ \
add_pbf_error(s, TIMELIB_ERR_UNEXPECTED_DATA, "Unexpected data found.", string, begin); \
}

Definition at line 24934 of file parse_date.c.

◆ TIMELIB_CLF

#define TIMELIB_CLF   274

Definition at line 66 of file parse_date.c.

◆ TIMELIB_DATE_FULL

#define TIMELIB_DATE_FULL   268

Definition at line 60 of file parse_date.c.

◆ TIMELIB_DATE_FULL_POINTED

#define TIMELIB_DATE_FULL_POINTED   277

Definition at line 69 of file parse_date.c.

◆ TIMELIB_DATE_NO_DAY

#define TIMELIB_DATE_NO_DAY   275

Definition at line 67 of file parse_date.c.

◆ TIMELIB_DATE_NOCOLON

#define TIMELIB_DATE_NOCOLON   270

Definition at line 62 of file parse_date.c.

◆ TIMELIB_DATE_TEXT

#define TIMELIB_DATE_TEXT   269

Definition at line 61 of file parse_date.c.

◆ TIMELIB_DEINIT

#define TIMELIB_DEINIT   timelib_string_free(str)

Definition at line 108 of file parse_date.c.

◆ TIMELIB_ERROR

#define TIMELIB_ERROR   999

Definition at line 80 of file parse_date.c.

◆ TIMELIB_GNU_NOCOLON

#define TIMELIB_GNU_NOCOLON   263

Definition at line 54 of file parse_date.c.

◆ TIMELIB_GNU_NOCOLON_TZ

#define TIMELIB_GNU_NOCOLON_TZ   264

Definition at line 55 of file parse_date.c.

◆ TIMELIB_HAVE_DATE

#define TIMELIB_HAVE_DATE ( )
Value:
{ if (s->time->have_date) { add_error(s, TIMELIB_ERR_DOUBLE_DATE, "Double date specification"); timelib_string_free(str); return TIMELIB_ERROR; } else { s->time->have_date = 1; } }
#define TIMELIB_ERROR
Definition parse_date.c:80
#define timelib_string_free
Definition parse_date.c:96
#define TIMELIB_ERR_DOUBLE_DATE
Definition timelib.h:290

Definition at line 100 of file parse_date.c.

◆ TIMELIB_HAVE_RELATIVE

#define TIMELIB_HAVE_RELATIVE ( )
Value:
{ s->time->have_relative = 1; }

Definition at line 102 of file parse_date.c.

◆ TIMELIB_HAVE_SPECIAL_RELATIVE

#define TIMELIB_HAVE_SPECIAL_RELATIVE ( )
Value:
{ s->time->have_relative = 1; s->time->relative.have_special_relative = 1; }

Definition at line 104 of file parse_date.c.

◆ TIMELIB_HAVE_TIME

#define TIMELIB_HAVE_TIME ( )
Value:
{ if (s->time->have_time) { add_error(s, TIMELIB_ERR_DOUBLE_TIME, "Double time specification"); timelib_string_free(str); return TIMELIB_ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->us = 0; } }
#define TIMELIB_ERR_DOUBLE_TIME
Definition timelib.h:289

Definition at line 98 of file parse_date.c.

◆ TIMELIB_HAVE_TZ

#define TIMELIB_HAVE_TZ ( )
Value:
{ s->cur = cursor; if (s->time->have_zone) { s->time->have_zone > 1 ? add_error(s, TIMELIB_ERR_DOUBLE_TZ, "Double timezone specification") : add_warning(s, TIMELIB_WARN_DOUBLE_TZ, "Double timezone specification"); timelib_string_free(str); s->time->have_zone++; return TIMELIB_ERROR; } else { s->time->have_zone++; } }
#define TIMELIB_ERR_DOUBLE_TZ
Definition timelib.h:287
#define TIMELIB_WARN_DOUBLE_TZ
Definition timelib.h:282

Definition at line 105 of file parse_date.c.

◆ TIMELIB_HAVE_WEEKDAY_RELATIVE

#define TIMELIB_HAVE_WEEKDAY_RELATIVE ( )
Value:
{ s->time->have_relative = 1; s->time->relative.have_weekday_relative = 1; }

Definition at line 103 of file parse_date.c.

◆ TIMELIB_INIT

#define TIMELIB_INIT   s->cur = cursor; str = timelib_string(s); ptr = str

Definition at line 107 of file parse_date.c.

◆ TIMELIB_ISO_DATE

#define TIMELIB_ISO_DATE   267

Definition at line 59 of file parse_date.c.

◆ TIMELIB_ISO_NOCOLON

#define TIMELIB_ISO_NOCOLON   265

Definition at line 56 of file parse_date.c.

◆ TIMELIB_ISO_WEEK

#define TIMELIB_ISO_WEEK   279

Definition at line 71 of file parse_date.c.

◆ TIMELIB_LF_DAY_OF_MONTH

#define TIMELIB_LF_DAY_OF_MONTH   280

Definition at line 72 of file parse_date.c.

◆ TIMELIB_PG_REVERSE

#define TIMELIB_PG_REVERSE   273

Definition at line 65 of file parse_date.c.

◆ TIMELIB_PG_TEXT

#define TIMELIB_PG_TEXT   272

Definition at line 64 of file parse_date.c.

◆ TIMELIB_PG_YEARDAY

#define TIMELIB_PG_YEARDAY   271

Definition at line 63 of file parse_date.c.

◆ TIMELIB_PROCESS_YEAR

#define TIMELIB_PROCESS_YEAR ( x,
l )
Value:
{ \
if (((x) == TIMELIB_UNSET) || ((l) >= 4)) { \
/* (x) = 0; */ \
} else if ((x) < 100) { \
if ((x) < 70) { \
(x) += 2000; \
} else { \
(x) += 1900; \
} \
} \
}
#define TIMELIB_UNSET
Definition timelib.h:382

Definition at line 111 of file parse_date.c.

◆ TIMELIB_RELATIVE

#define TIMELIB_RELATIVE   310

Definition at line 78 of file parse_date.c.

◆ TIMELIB_SHORTDATE_WITH_TIME

#define TIMELIB_SHORTDATE_WITH_TIME   276

Definition at line 68 of file parse_date.c.

◆ timelib_split_free

#define timelib_split_free ( arg)
Value:
{ \
int i; \
for (i = 0; i < arg.c; i++) { \
timelib_free(arg.v[i]); \
} \
if (arg.v) { \
timelib_free(arg.v); \
} \
}
zval * arg
Definition ffi.c:3975

Definition at line 1002 of file parse_date.c.

◆ timelib_string_free

#define timelib_string_free   timelib_free

Definition at line 96 of file parse_date.c.

◆ TIMELIB_TIME12

#define TIMELIB_TIME12   261

Definition at line 52 of file parse_date.c.

◆ TIMELIB_TIME24

#define TIMELIB_TIME24   262

Definition at line 53 of file parse_date.c.

◆ TIMELIB_TIME24_WITH_ZONE

#define TIMELIB_TIME24_WITH_ZONE   278

Definition at line 70 of file parse_date.c.

◆ TIMELIB_TIMEZONE

#define TIMELIB_TIMEZONE   300

Definition at line 75 of file parse_date.c.

◆ TIMELIB_UNHAVE_DATE

#define TIMELIB_UNHAVE_DATE ( )
Value:
{ s->time->have_date = 0; s->time->d = 0; s->time->m = 0; s->time->y = 0; }

Definition at line 101 of file parse_date.c.

◆ TIMELIB_UNHAVE_TIME

#define TIMELIB_UNHAVE_TIME ( )
Value:
{ s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->us = 0; }

Definition at line 99 of file parse_date.c.

◆ TIMELIB_WEEK_DAY_OF_MONTH

#define TIMELIB_WEEK_DAY_OF_MONTH   281

Definition at line 73 of file parse_date.c.

◆ TIMELIB_XMLRPC_SOAP

#define TIMELIB_XMLRPC_SOAP   260

Definition at line 51 of file parse_date.c.

◆ YYCTYPE

#define YYCTYPE   uchar

Definition at line 88 of file parse_date.c.

◆ YYCURSOR

#define YYCURSOR   cursor

Definition at line 89 of file parse_date.c.

◆ YYDEBUG

#define YYDEBUG ( s,
c )

Definition at line 128 of file parse_date.c.

◆ YYFILL

#define YYFILL ( n)
Value:
return EOI;
#define EOI
Definition parse_date.c:47

Definition at line 92 of file parse_date.c.

◆ YYLIMIT

#define YYLIMIT   s->lim

Definition at line 90 of file parse_date.c.

◆ YYMARKER

#define YYMARKER   s->ptr

Definition at line 91 of file parse_date.c.

◆ YYMAXFILL

#define YYMAXFILL   36

Definition at line 24846 of file parse_date.c.

Typedef Documentation

◆ Scanner

typedef struct _Scanner Scanner

◆ timelib_elems

typedef struct _timelib_elems timelib_elems

◆ timelib_lookup_table

◆ timelib_relunit

◆ uchar

typedef unsigned char uchar

Definition at line 84 of file parse_date.c.

Function Documentation

◆ 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_parse_from_format()

timelib_time * timelib_parse_from_format ( const char * format,
const char * string,
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 * string,
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_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_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_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.