Documentation ¶
Index ¶
- Constants
- Variables
- func Add_month_duration(year int, month time.Month, day int, month_duration int64) (result_year int, result_month time.Month, result_day int, rsql_err *rsql.Error)
- func Add_nanosecond_duration(mydatetime MyDatetime, nanosecond_duration int64) (result time.Time, rsql_err *rsql.Error)
- func Add_second_duration(mydatetime MyDatetime, second_duration int64) (result time.Time, rsql_err *rsql.Error)
- func DMY_from_style(style int64) (string, error)
- func Diff_sec_nsec_absolute(a time.Time, b time.Time) (delta_sec int64, delta_nsec int64, sign int)
- func Equal(a MyDatetime, b MyDatetime) bool
- func Get_time_UTC() (result time.Time, rsql_err *rsql.Error)
- func Last_day_of_month(year int, month time.Month) int
- func Nanoseconds_from_fractions(fractions int64, precision int64) (nanoseconds int64)
- func Parse(s []byte, DMY string, style int64, mode int) (res time.Time, err error)
- func UTC_to_local(a time.Time) (result time.Time, rsql_err *rsql.Error)
- type MyDatetime
Constants ¶
View Source
const ( SECONDS_PER_DAY = 24 * 3600 // 86400 SECONDS_PER_WEEK = 24 * 3600 * 7 // 604800 YEAR_LOWEST = 1 YEAR_MAX_SENTINEL = 10000 UNIX_SEC_LOWEST = -62135596800 // -719162 days * 24 * 3600 UNIX_SEC_1900_01_01 = -2208988800 // -25567 days * 24 * 3600 UNIX_SEC_1970_01_01 = 0 UNIX_SEC_UPPER_SENTINEL = 253402300800 // 2932897 days * 24 * 3600 NUMBER_OF_DAYS_FROM_1900_01_01_TO_LOWEST = -693595 // dateadd(dy, -693595, '19000101') = '0001-01-01' NUMBER_OF_DAYS_FROM_1900_01_01_TO_UPPER_SENTINEL = 2958464 // dateadd(dy, 2958464, '19000101') = '10000-01-01' NUMBER_OF_DAYS_FROM_LOWEST_TO_UPPER_SENTINEL = NUMBER_OF_DAYS_FROM_1900_01_01_TO_UPPER_SENTINEL - NUMBER_OF_DAYS_FROM_1900_01_01_TO_LOWEST )
View Source
const ( PARSE_MODE_DATE int = 1 // in this mode, time part is ignored and forced to 00:00:00.0 PARSE_MODE_TIME int = 2 // in this mode, date part is ignored and forced to 1900-01-01 PARSE_MODE_DATETIME int = 3 )
Variables ¶
Functions ¶
func Add_month_duration ¶
func Add_nanosecond_duration ¶
func Add_second_duration ¶
func DMY_from_style ¶
DMY_from_style is used for parsing date, to convert a style number into a year month day order.
func Diff_sec_nsec_absolute ¶
Diff_sec_nsec_absolute returns the difference in seconds and nanoseconds between two dates. delta_sec and delta_nsec are always positive or zero. If b >= a, sign is 1. Else, sign is -1.
func Equal ¶
func Equal(a MyDatetime, b MyDatetime) bool
func Nanoseconds_from_fractions ¶
Nanoseconds_from_fractions computes nanoseconds from fractions and precision values.
The following conditions must apply. Else -1 is returned, indicating an error. - fractions must be 0...999999999 - precision must be 0...9 - if precision == 0, fractions must be 0 - nanoseconds must be 0...999999999
func Parse ¶
Parse converts a string into a time.Time.
DMY : 3-letter string describing order of date parts. E.g. "MDY". style : if 0, order of date parts is given by DMY argument. Else, style will override DMY argument. See DMY_from_style(). mode : PARSE_MODE_DATE, PARSE_MODE_TIME, PARSE_MODE_DATETIME
Parse returns an 'error' type and not a *rsql.Error, because the caller will create a customized *rsql.Error.
Types ¶
type MyDatetime ¶
MyDatetime represents the value stored in DATE, TIME, and DATETIME datatypes.
Note: it has not been declared as "type MyDatetime time.Time" because we want to use the time.Time methods Equal(), After(), etc directly on MyDatetime. This way, we avoid type conversion syntax in our code, like time.Time(a) where a is of type MyDatetime.
func (MyDatetime) Has_no_time_part ¶
func (mydatetime MyDatetime) Has_no_time_part() bool
Has_no_time_part checks if time part is 00:00:00.0.
func (MyDatetime) String ¶
func (a MyDatetime) String() string
Click to show internal directories.
Click to hide internal directories.