File db_date.c
FileList > compat > db_date.c
Go to the source code of this file
#include <stdio.h>
#include <math.h>
#include <time.h>
#include "system.h"
#include "tz_support.h"
#include "db_date.h"
#include <assert.h>
#include "error_manager.h"
#include "chartype.h"
#include "numeric_opfunc.h"
#include "object_representation.h"
#include "dbtype.h"
#include "string_opfunc.h"
#include "memory_wrapper.hpp"
Classes
Public Types
Public Static Attributes
Public Functions
| Type |
Name |
| int |
day_of_week (int jul_day)
|
| int |
db_add_int_to_datetime (DB_DATETIME * datetime, DB_BIGINT bi2, DB_DATETIME * result_datetime)
|
| int |
db_add_weeks_and_days_to_date (int * day, int * month, int * year, int weeks, int day_week)
|
| int |
db_check_time_date_format (const char * format_s)
|
| void |
db_date_decode (const DB_DATE * date, int * monthp, int * dayp, int * yearp)
|
| int |
db_date_encode (DB_DATE * date, int month, int day, int year)
|
| void |
db_date_locale_init (void)
|
| int |
db_date_parse_date (char const * str, int str_len, DB_DATE * date)
|
| int |
db_date_parse_datetime (char const * str, int str_len, DB_DATETIME * datetime)
|
| int |
db_date_parse_datetime_parts (char const * str, int str_len, DB_DATETIME * datetime, bool * has_explicit_time, bool * has_explicit_msec, bool * fits_as_timestamp, char const ** endp)
|
| int |
db_date_parse_time (char const * str, int str_len, DB_TIME * time, int * millisecond)
|
| int |
db_date_parse_timestamp (char const * str, int str_len, DB_TIMESTAMP * utime)
|
| int |
db_date_to_string (char * buf, int bufsize, DB_DATE * date)
|
| int |
db_date_weekday (DB_DATE * date)
|
| int |
db_datetime_decode (const DB_DATETIME * datetime, int * month, int * day, int * year, int * hour, int * minute, int * second, int * millisecond)
|
| int |
db_datetime_encode (DB_DATETIME * datetime, int month, int day, int year, int hour, int minute, int second, int millisecond)
|
| int |
db_datetime_to_string (char * buf, int bufsize, DB_DATETIME * datetime)
|
| int |
db_datetime_to_string2 (char * buf, int bufsize, DB_DATETIME * datetime)
|
| int |
db_datetimeltz_to_string (char * buf, int bufsize, DB_DATETIME * dt)
|
| int |
db_datetimetz_to_string (char * buf, int bufsize, DB_DATETIME * dt, const TZ_ID * tz_id)
|
| int |
db_get_day_of_week (int year, int month, int day)
|
| int |
db_get_day_of_year (int year, int month, int day)
|
| int |
db_get_week_of_year (int year, int month, int day, int mode)
|
| void |
db_localdatetime (time_t * epoch_time, DB_DATETIME * datetime)
|
| void |
db_localdatetime_msec (time_t * epoch_time, int millisecond, DB_DATETIME * datetime)
|
| void |
db_localtime (time_t * epoch_time, DB_DATE * date, DB_TIME * timeval)
|
| time_t |
db_mktime (DB_DATE * date, DB_TIME * timeval)
|
| int |
db_strftime (char * s, int smax, const char * fmt, DB_DATE * date, DB_TIME * timeval)
|
| bool |
db_string_check_explicit_date (const char * str, int str_len)
|
| bool |
db_string_check_explicit_time (const char * str, int str_len)
|
| int |
db_string_to_date (const char * str, DB_DATE * date)
|
| int |
db_string_to_date_ex (const char * str, int str_len, DB_DATE * date)
|
| int |
db_string_to_datetime (const char * str, DB_DATETIME * datetime)
|
| int |
db_string_to_datetime_ex (const char * str, int str_len, DB_DATETIME * datetime)
|
| int |
db_string_to_datetimeltz (const char * str, DB_DATETIME * datetime)
|
| int |
db_string_to_datetimeltz_ex (const char * str, int str_len, DB_DATETIME * datetime)
|
| int |
db_string_to_datetimetz (const char * str, DB_DATETIMETZ * dt_tz, bool * has_zone)
|
| int |
db_string_to_datetimetz_ex (const char * str, int str_len, DB_DATETIMETZ * dt_tz, bool * has_zone)
|
| int |
db_string_to_time (const char * str, DB_TIME * time)
|
| int |
db_string_to_time_ex (const char * str, int str_len, DB_TIME * time)
|
| int |
db_string_to_timestamp (const char * str, DB_TIMESTAMP * utime)
|
| int |
db_string_to_timestamp_ex (const char * str, int str_len, DB_TIMESTAMP * utime)
|
| int |
db_string_to_timestampltz (const char * str, DB_TIMESTAMP * ts)
|
| int |
db_string_to_timestampltz_ex (const char * str, int str_len, DB_TIMESTAMP * ts)
|
| int |
db_string_to_timestamptz (const char * str, DB_TIMESTAMPTZ * ts_tz, bool * has_zone)
|
| int |
db_string_to_timestamptz_ex (const char * str, int str_len, DB_TIMESTAMPTZ * ts_tz, bool * has_zone, bool is_cast)
|
| int |
db_subtract_int_from_datetime (DB_DATETIME * dt1, DB_BIGINT bi2, DB_DATETIME * result_datetime)
|
| void |
db_time_decode (DB_TIME * timeval, int * hourp, int * minutep, int * secondp)
|
| int |
db_time_encode (DB_TIME * timeval, int hour, int minute, int second)
|
| int |
db_time_to_string (char * buf, int bufsize, DB_TIME * time)
|
| int |
db_timestamp_decode_ses (const DB_TIMESTAMP * utime, DB_DATE * date, DB_TIME * timeval)
|
| void |
db_timestamp_decode_utc (const DB_TIMESTAMP * utime, DB_DATE * date, DB_TIME * timeval)
|
| int |
db_timestamp_decode_w_reg (const DB_TIMESTAMP * utime, const TZ_REGION * tz_region, DB_DATE * date, DB_TIME * timeval)
|
| int |
db_timestamp_decode_w_tz_id (const DB_TIMESTAMP * utime, const TZ_ID * tz_id, DB_DATE * date, DB_TIME * timeval)
|
| int |
db_timestamp_encode (DB_TIMESTAMP * utime, DB_DATE * date, DB_TIME * timeval)
|
| int |
db_timestamp_encode_ses (const DB_DATE * date, const DB_TIME * timeval, DB_TIMESTAMP * utime, TZ_ID * dest_tz_id)
|
| int |
db_timestamp_encode_sys (const DB_DATE * date, const DB_TIME * timeval, DB_TIMESTAMP * utime, TZ_ID * dest_tz_id)
|
| int |
db_timestamp_encode_utc (const DB_DATE * date, const DB_TIME * timeval, DB_TIMESTAMP * utime)
|
| int |
db_timestamp_to_string (char * buf, int bufsize, DB_TIMESTAMP * utime)
|
| int |
db_timestampltz_to_string (char * buf, int bufsize, DB_TIMESTAMP * utime)
|
| int |
db_timestamptz_to_string (char * buf, int bufsize, DB_TIMESTAMP * utime, const TZ_ID * tz_id)
|
| int |
db_tm_encode (struct tm * c_time_struct, DB_DATE * date, DB_TIME * timeval)
|
| void |
julian_decode (int jul, int * monthp, int * dayp, int * yearp, int * weekp)
|
| int |
julian_encode (int m, int d, int y)
|
Public Static Functions
| Type |
Name |
| int |
db_timestamp_encode_w_reg (const DB_DATE * date, const DB_TIME * timeval, const TZ_REGION * tz_region, DB_TIMESTAMP * utime, TZ_ID * dest_tz_id)
|
| void |
decode_mtime (int mtimeval, int * hourp, int * minutep, int * secondp, int * millisecondp)
|
| void |
decode_time (int timeval, int * hourp, int * minutep, int * secondp)
|
| unsigned int |
encode_mtime (int hour, int minute, int second, int millisecond)
|
| int |
encode_time (int hour, int minute, int second)
|
| void |
fill_local_ampm_str (char str, bool am)
|
| int |
get_current_year (void)
|
| int |
get_end_of_week_one_of_year (int year, int mode)
|
| int |
init_tm (struct tm * tm)
|
| bool |
is_local_am_str (const char * p, const char * p_end)
|
| bool |
is_local_pm_str (const char * p, const char * p_end)
|
| const char * |
parse_date (const char * buf, int buf_len, DB_DATE * date)
|
| char const * |
parse_date_separated (char const * str, char const * strend, DB_DATE * date, char const ** syntax_check, int * year_digits, char * sep_ch)
|
| const char * |
parse_datetime (const char * buf, int buf_len, DB_DATETIME * datetime)
|
| char const * |
parse_explicit_mtime_compact (char const * str, char const * strend, unsigned int * mtime)
|
| char const * |
parse_explicit_mtime_separated (char const * str, char const * strend, unsigned int * mtime, char const ** syntax_check, bool * has_explicit_msec)
|
| const char * |
parse_for_timestamp (const char * buf, int buf_len, DB_DATE * date, DB_TIME * time, bool allow_msec)
|
| const char * |
parse_mtime (const char * buf, int buf_len, unsigned int * mtime, bool * is_msec, bool * is_explicit)
|
| char const * |
parse_mtime_separated (char const * str, char const * strend, unsigned int * mtime, char const ** syntax_check, int * time_parts, char * sep_ch, bool * has_explicit_msec, bool is_datetime)
|
| const char * |
parse_time (const char * buf, int buf_len, DB_TIME * mtime)
|
| char const * |
parse_timedate_separated (char const * str, char const * strend, DB_DATE * date, unsigned int * mtime, char const ** syntax_check, bool * has_explicit_msec)
|
| char const * |
parse_timestamp_compact (char const * str, char const * strend, DB_DATE * date, unsigned int * mtime, bool * has_explicit_time, bool * has_explicit_msec)
|
| int |
tm_encode (struct tm * c_time_struct, time_t * retval, DB_DATE * date, DB_TIME * timeval)
|
Macros
| Type |
Name |
| define |
DATETIME_FIELD_LIMIT 1000000
|
| define |
FLOOR (d1) ([**int**](broker__monitor_8c.md#function-timeout)) ([**d1**](mprec_8c.md#define-d1) + 4000000.0) - 4000000
|
| define |
IGREG1 (15 + 31[**L**](broker__monitor_8c.md#function-timeout) \* (10 + 12[**L**](broker__monitor_8c.md#function-timeout) \* 1582))
|
| define |
IGREG2 2299161 /\* 10/15/1582 \*/
|
| define |
IGREG_SPECIAL 0 /\* 01/01/-4713 [**DATE**](broker__monitor_8c.md#function-timeout) \|\| 01/01/1970 00:00:00 [**TIMESTAMP**](broker__monitor_8c.md#function-timeout) \*/
|
| define |
MMDDYYYY 0
|
| define |
YBIAS 1900
|
Public Types Documentation
typedef AMPM_BUF
typedef struct ampm_buf AMPM_BUF;
Public Static Attributes Documentation
variable local_am_str
variable local_am_strlen
variable local_pm_str
variable local_pm_strlen
Public Functions Documentation
function day_of_week
int day_of_week (
int jul_day
)
function db_add_int_to_datetime
int db_add_int_to_datetime (
DB_DATETIME * datetime,
DB_BIGINT bi2,
DB_DATETIME * result_datetime
)
function db_add_weeks_and_days_to_date
int db_add_weeks_and_days_to_date (
int * day,
int * month,
int * year,
int weeks,
int day_week
)
int db_check_time_date_format (
const char * format_s
)
function db_date_decode
void db_date_decode (
const DB_DATE * date,
int * monthp,
int * dayp,
int * yearp
)
function db_date_encode
int db_date_encode (
DB_DATE * date,
int month,
int day,
int year
)
function db_date_locale_init
void db_date_locale_init (
void
)
function db_date_parse_date
int db_date_parse_date (
char const * str,
int str_len,
DB_DATE * date
)
function db_date_parse_datetime
int db_date_parse_datetime (
char const * str,
int str_len,
DB_DATETIME * datetime
)
function db_date_parse_datetime_parts
int db_date_parse_datetime_parts (
char const * str,
int str_len,
DB_DATETIME * datetime,
bool * has_explicit_time,
bool * has_explicit_msec,
bool * fits_as_timestamp,
char const ** endp
)
function db_date_parse_time
int db_date_parse_time (
char const * str,
int str_len,
DB_TIME * time,
int * millisecond
)
function db_date_parse_timestamp
int db_date_parse_timestamp (
char const * str,
int str_len,
DB_TIMESTAMP * utime
)
function db_date_to_string
int db_date_to_string (
char * buf,
int bufsize,
DB_DATE * date
)
function db_date_weekday
int db_date_weekday (
DB_DATE * date
)
function db_datetime_decode
int db_datetime_decode (
const DB_DATETIME * datetime,
int * month,
int * day,
int * year,
int * hour,
int * minute,
int * second,
int * millisecond
)
function db_datetime_encode
int db_datetime_encode (
DB_DATETIME * datetime,
int month,
int day,
int year,
int hour,
int minute,
int second,
int millisecond
)
function db_datetime_to_string
int db_datetime_to_string (
char * buf,
int bufsize,
DB_DATETIME * datetime
)
function db_datetime_to_string2
int db_datetime_to_string2 (
char * buf,
int bufsize,
DB_DATETIME * datetime
)
function db_datetimeltz_to_string
int db_datetimeltz_to_string (
char * buf,
int bufsize,
DB_DATETIME * dt
)
function db_datetimetz_to_string
int db_datetimetz_to_string (
char * buf,
int bufsize,
DB_DATETIME * dt,
const TZ_ID * tz_id
)
function db_get_day_of_week
int db_get_day_of_week (
int year,
int month,
int day
)
function db_get_day_of_year
int db_get_day_of_year (
int year,
int month,
int day
)
function db_get_week_of_year
int db_get_week_of_year (
int year,
int month,
int day,
int mode
)
function db_localdatetime
void db_localdatetime (
time_t * epoch_time,
DB_DATETIME * datetime
)
function db_localdatetime_msec
void db_localdatetime_msec (
time_t * epoch_time,
int millisecond,
DB_DATETIME * datetime
)
function db_localtime
void db_localtime (
time_t * epoch_time,
DB_DATE * date,
DB_TIME * timeval
)
function db_mktime
time_t db_mktime (
DB_DATE * date,
DB_TIME * timeval
)
function db_strftime
int db_strftime (
char * s,
int smax,
const char * fmt,
DB_DATE * date,
DB_TIME * timeval
)
function db_string_check_explicit_date
bool db_string_check_explicit_date (
const char * str,
int str_len
)
function db_string_check_explicit_time
bool db_string_check_explicit_time (
const char * str,
int str_len
)
function db_string_to_date
int db_string_to_date (
const char * str,
DB_DATE * date
)
function db_string_to_date_ex
int db_string_to_date_ex (
const char * str,
int str_len,
DB_DATE * date
)
function db_string_to_datetime
int db_string_to_datetime (
const char * str,
DB_DATETIME * datetime
)
function db_string_to_datetime_ex
int db_string_to_datetime_ex (
const char * str,
int str_len,
DB_DATETIME * datetime
)
function db_string_to_datetimeltz
int db_string_to_datetimeltz (
const char * str,
DB_DATETIME * datetime
)
function db_string_to_datetimeltz_ex
int db_string_to_datetimeltz_ex (
const char * str,
int str_len,
DB_DATETIME * datetime
)
function db_string_to_datetimetz
int db_string_to_datetimetz (
const char * str,
DB_DATETIMETZ * dt_tz,
bool * has_zone
)
function db_string_to_datetimetz_ex
int db_string_to_datetimetz_ex (
const char * str,
int str_len,
DB_DATETIMETZ * dt_tz,
bool * has_zone
)
function db_string_to_time
int db_string_to_time (
const char * str,
DB_TIME * time
)
function db_string_to_time_ex
int db_string_to_time_ex (
const char * str,
int str_len,
DB_TIME * time
)
function db_string_to_timestamp
int db_string_to_timestamp (
const char * str,
DB_TIMESTAMP * utime
)
function db_string_to_timestamp_ex
int db_string_to_timestamp_ex (
const char * str,
int str_len,
DB_TIMESTAMP * utime
)
function db_string_to_timestampltz
int db_string_to_timestampltz (
const char * str,
DB_TIMESTAMP * ts
)
function db_string_to_timestampltz_ex
int db_string_to_timestampltz_ex (
const char * str,
int str_len,
DB_TIMESTAMP * ts
)
function db_string_to_timestamptz
int db_string_to_timestamptz (
const char * str,
DB_TIMESTAMPTZ * ts_tz,
bool * has_zone
)
function db_string_to_timestamptz_ex
int db_string_to_timestamptz_ex (
const char * str,
int str_len,
DB_TIMESTAMPTZ * ts_tz,
bool * has_zone,
bool is_cast
)
function db_subtract_int_from_datetime
int db_subtract_int_from_datetime (
DB_DATETIME * dt1,
DB_BIGINT bi2,
DB_DATETIME * result_datetime
)
function db_time_decode
void db_time_decode (
DB_TIME * timeval,
int * hourp,
int * minutep,
int * secondp
)
function db_time_encode
int db_time_encode (
DB_TIME * timeval,
int hour,
int minute,
int second
)
function db_time_to_string
int db_time_to_string (
char * buf,
int bufsize,
DB_TIME * time
)
function db_timestamp_decode_ses
int db_timestamp_decode_ses (
const DB_TIMESTAMP * utime,
DB_DATE * date,
DB_TIME * timeval
)
function db_timestamp_decode_utc
void db_timestamp_decode_utc (
const DB_TIMESTAMP * utime,
DB_DATE * date,
DB_TIME * timeval
)
function db_timestamp_decode_w_reg
int db_timestamp_decode_w_reg (
const DB_TIMESTAMP * utime,
const TZ_REGION * tz_region,
DB_DATE * date,
DB_TIME * timeval
)
function db_timestamp_decode_w_tz_id
int db_timestamp_decode_w_tz_id (
const DB_TIMESTAMP * utime,
const TZ_ID * tz_id,
DB_DATE * date,
DB_TIME * timeval
)
function db_timestamp_encode
int db_timestamp_encode (
DB_TIMESTAMP * utime,
DB_DATE * date,
DB_TIME * timeval
)
function db_timestamp_encode_ses
int db_timestamp_encode_ses (
const DB_DATE * date,
const DB_TIME * timeval,
DB_TIMESTAMP * utime,
TZ_ID * dest_tz_id
)
function db_timestamp_encode_sys
int db_timestamp_encode_sys (
const DB_DATE * date,
const DB_TIME * timeval,
DB_TIMESTAMP * utime,
TZ_ID * dest_tz_id
)
function db_timestamp_encode_utc
int db_timestamp_encode_utc (
const DB_DATE * date,
const DB_TIME * timeval,
DB_TIMESTAMP * utime
)
function db_timestamp_to_string
int db_timestamp_to_string (
char * buf,
int bufsize,
DB_TIMESTAMP * utime
)
function db_timestampltz_to_string
int db_timestampltz_to_string (
char * buf,
int bufsize,
DB_TIMESTAMP * utime
)
function db_timestamptz_to_string
int db_timestamptz_to_string (
char * buf,
int bufsize,
DB_TIMESTAMP * utime,
const TZ_ID * tz_id
)
function db_tm_encode
int db_tm_encode (
struct tm * c_time_struct,
DB_DATE * date,
DB_TIME * timeval
)
function julian_decode
void julian_decode (
int jul,
int * monthp,
int * dayp,
int * yearp,
int * weekp
)
function julian_encode
int julian_encode (
int m,
int d,
int y
)
Public Static Functions Documentation
function db_timestamp_encode_w_reg
static int db_timestamp_encode_w_reg (
const DB_DATE * date,
const DB_TIME * timeval,
const TZ_REGION * tz_region,
DB_TIMESTAMP * utime,
TZ_ID * dest_tz_id
)
function decode_mtime
static void decode_mtime (
int mtimeval,
int * hourp,
int * minutep,
int * secondp,
int * millisecondp
)
function decode_time
static void decode_time (
int timeval,
int * hourp,
int * minutep,
int * secondp
)
function encode_mtime
static unsigned int encode_mtime (
int hour,
int minute,
int second,
int millisecond
)
function encode_time
static int encode_time (
int hour,
int minute,
int second
)
function fill_local_ampm_str
static void fill_local_ampm_str (
char str,
bool am
)
function get_current_year
static int get_current_year (
void
)
function get_end_of_week_one_of_year
static int get_end_of_week_one_of_year (
int year,
int mode
)
function init_tm
static int init_tm (
struct tm * tm
)
function is_local_am_str
static bool is_local_am_str (
const char * p,
const char * p_end
)
function is_local_pm_str
static bool is_local_pm_str (
const char * p,
const char * p_end
)
function parse_date
static const char * parse_date (
const char * buf,
int buf_len,
DB_DATE * date
)
function parse_date_separated
static char const * parse_date_separated (
char const * str,
char const * strend,
DB_DATE * date,
char const ** syntax_check,
int * year_digits,
char * sep_ch
)
function parse_datetime
static const char * parse_datetime (
const char * buf,
int buf_len,
DB_DATETIME * datetime
)
function parse_explicit_mtime_compact
static char const * parse_explicit_mtime_compact (
char const * str,
char const * strend,
unsigned int * mtime
)
function parse_explicit_mtime_separated
static char const * parse_explicit_mtime_separated (
char const * str,
char const * strend,
unsigned int * mtime,
char const ** syntax_check,
bool * has_explicit_msec
)
function parse_for_timestamp
static const char * parse_for_timestamp (
const char * buf,
int buf_len,
DB_DATE * date,
DB_TIME * time,
bool allow_msec
)
function parse_mtime
static const char * parse_mtime (
const char * buf,
int buf_len,
unsigned int * mtime,
bool * is_msec,
bool * is_explicit
)
function parse_mtime_separated
static char const * parse_mtime_separated (
char const * str,
char const * strend,
unsigned int * mtime,
char const ** syntax_check,
int * time_parts,
char * sep_ch,
bool * has_explicit_msec,
bool is_datetime
)
function parse_time
static const char * parse_time (
const char * buf,
int buf_len,
DB_TIME * mtime
)
function parse_timedate_separated
static char const * parse_timedate_separated (
char const * str,
char const * strend,
DB_DATE * date,
unsigned int * mtime,
char const ** syntax_check,
bool * has_explicit_msec
)
function parse_timestamp_compact
static char const * parse_timestamp_compact (
char const * str,
char const * strend,
DB_DATE * date,
unsigned int * mtime,
bool * has_explicit_time,
bool * has_explicit_msec
)
function tm_encode
static int tm_encode (
struct tm * c_time_struct,
time_t * retval,
DB_DATE * date,
DB_TIME * timeval
)
Macro Definition Documentation
define DATETIME_FIELD_LIMIT
#define DATETIME_FIELD_LIMIT `1000000`
define FLOOR
#define FLOOR (
d1
) `( int ) ( d1 + 4000000.0) - 4000000`
define IGREG1
#define IGREG1 `(15 + 31 L * (10 + 12 L * 1582))`
define IGREG2
#define IGREG2 `2299161 /* 10/15/1582 */`
define IGREG_SPECIAL
#define IGREG_SPECIAL `0 /* 01/01/-4713 DATE || 01/01/1970 00:00:00 TIMESTAMP */`
define MMDDYYYY
define YBIAS
The documentation for this class was generated from the following file cubrid/src/compat/db_date.c