GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
defs/datetime.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int datetime_is_between (int x, int a, int b)
 
int datetime_change_from_to (DateTime *dt, int from, int to, int round)
 Changes the from/to of the type for dt. The 'from/to' must be legal values for the mode of dt; (if they are not legal, then the original values are preserved, dt is not changed). Returns: 0 OK -1 invalid 'dt' -2 invalid 'from/to'
More...
 
void datetime_copy (DateTime *src, const DateTime *dst)
 Copies the DateTime [into/from ???] src. More...
 
int datetime_difference (const DateTime *a, const DateTime *b, DateTime *result)
 This performs the formula: result = a - b;. More...
 
int datetime_error (int code, char *msg)
 record 'code' and 'msg' as error code/msg (in static variables) code==0 will clear the error (ie set msg=NULL) returns 'code' so that it can be used like: More...
 
int datetime_error_code (void)
 returns an error code More...
 
char * datetime_error_msg (void)
 returns an error message More...
 
void datetime_clear_error (void)
 clears error code and message More...
 
int datetime_format (const DateTime *dt, char *buf)
 formats DateTime structure as a human-readable string returns 0 when successful and 'buf' is filled with the string returns a negative number on error More...
 
int datetime_increment (DateTime *src, DateTime *incr)
 This function changes the 'src' date/time data based on the 'incr' The type (mode/from/to) of the 'src' can be anything. The mode of the 'incr' must be RELATIVE, and the type (mode/from/to) for 'incr' must be a valid increment for 'src'. See datetime_is_valid_increment(), datetime_check_increment() Returns: 0: OK -1: 'incr' is invalid increment for 'src' For src.mode ABSOLUTE,. More...
 
int datetime_is_valid_increment (const DateTime *src, const DateTime *incr)
 Returns: datetime_check_increment(src, incr) == 0. More...
 
int datetime_check_increment (const DateTime *src, const DateTime *incr)
 This checks if the type of 'incr' is valid for incrementing/decrementing 'src'. The type (mode/from/to) of the 'src' can be anything. The incr.mode must be RELATIVE A timezone in 'src' is allowed - it's presence is ignored. To aid in setting the 'incr' type, see datetime_get_increment_type(). Returns: More...
 
int datetime_get_increment_type (const DateTime *dt, int *mode, int *from, int *to, int *fracsec)
 This returns the components of a type (mode/from/to/fracsec) that can be used to construct a DateTime object that can be used to increment the 'src'. Also see datetime_set_increment_type(). returns: 0 dt is legal !=0 why dt is illegal Implemented as follows: More...
 
int datetime_set_increment_type (const DateTime *src, DateTime *incr)
 src must be legal This is a convenience routine which is implemented as follows: More...
 
int datetime_get_local_timezone (int *minutes)
 Returns: 0 OK -1 local timezone info not available. More...
 
void datetime_get_local_time (DateTime *dt)
 set mode/from/to ABSOLUTE/YEAR/SECOND set the local time into 'dt' does not set timezone. More...
 
int datetime_days_in_month (int year, int month, int ad)
 returns number of days in 'month' of a particular 'year' More...
 
int datetime_is_leap_year (int year, int ad)
 
int datetime_days_in_year (int year, int ad)
 returns the number of days in 'year' More...
 
int datetime_is_same (const DateTime *src, const DateTime *dst)
 Returns: 1 if 'src' is exactly the same as 'dst' 0 if they differ. More...
 
int datetime_scan (DateTime *dt, const char *buf)
 Convert the ascii string into a DateTime. This determines the mode/from/to based on the string, inits 'dt' and then sets values in 'dt' based on the [???] Returns 0 if 'string' is legal, -1 if not. More...
 
int datetime_is_positive (const DateTime *dt)
 Returns: 1 if the Datetime is positive 0 otherwise. More...
 
int datetime_is_negative (const DateTime *dt)
 Returns: 1 if the DateTime is negative 0 otherwise. More...
 
void datetime_set_positive (DateTime *dt)
 Makes the DateTime positive. (A.D. for ABSOLUTE DateTimes) More...
 
void datetime_set_negative (DateTime *dt)
 Makes the DateTime negative. (B.C. for ABSOLUTE DateTimes) More...
 
void datetime_invert_sign (DateTime *dt)
 
int datetime_set_type (DateTime *dt, int mode, int from, int to, int fracsec)
 
int datetime_get_type (const DateTime *dt, int *mode, int *from, int *to, int *fracsec)
 
int datetime_is_valid_type (const DateTime *dt)
 Returns: 1 if datetime_check_type() returns 0 0 if not. More...
 
int datetime_check_type (const DateTime *dt)
 checks the mode/from/to/fracsec in dt. Returns: More...
 
int datetime_in_interval_year_month (int x)
 
int datetime_in_interval_day_second (int x)
 
int datetime_is_absolute (const DateTime *dt)
 Returns: 1 if dt.mode is absolute 0 if not (even if dt.mode is not defined) More...
 
int datetime_is_relative (const DateTime *dt)
 Returns: 1 if dt.mode is relative 0 if not (even if dt.mode is not defined) More...
 
int datetime_check_timezone (const DateTime *dt, int minutes)
 returns 0 on success More...
 
int datetime_get_timezone (const DateTime *dt, int *minutes)
 returns 0 on success More...
 
int datetime_set_timezone (DateTime *dt, int minutes)
 returns 0 on success More...
 
int datetime_unset_timezone (DateTime *dt)
 unsets timezone in 'dt' returns 0 More...
 
int datetime_is_valid_timezone (int minutes)
 Returns: 1 OK: -720 <= minutes <= 780 (720 = 12 hours; 780 = 13 hours) 0 NOT OK. More...
 
int datetime_change_timezone (DateTime *dt, int minutes)
 if dt has a timezone, increment dt by minutes-dt.tz MINUTES and set dt.tz = minutes Returns: 0 OK datetime_check_timezone (dt) if not -4 if minutes invalid More...
 
int datetime_change_to_utc (DateTime *dt)
 Return datetime_change_timezone (dt, 0);. More...
 
void datetime_decompose_timezone (int tz, int *hours, int *minutes)
 tz = abs(tz) *hour = tz/60 *minute = tz%60 Note: hour,minute are non-negative. Must look at sign of tz itself to see if the tz is negative offset or not. This routine would be used to format tz for output. For example if tz=-350 this would be hour=5 minute=50, but negative. Output might encode this as -0550: printf ("%s%02d%02d", tz<0?"-":"", hour, minute) More...
 
int datetime_check_year (const DateTime *dt, int year)
 Returns: 0 is legal year for dt -1 illegal year for this dt -2 dt has no year component. More...
 
int datetime_check_month (const DateTime *dt, int month)
 Returns: 0 is legal month for dt -1 illegal month for this dt -2 dt has no month component. More...
 
int datetime_check_day (const DateTime *dt, int day)
 Returns: 0 is legal day for dt -1 illegal day for this dt -2 dt has no day component
Note: if dt.mode is ABSOLUTE, then dt.year and dt.month must also be legal, since the 'day' must be a legal value for the dt.year/dt.month. More...
 
int datetime_check_hour (const DateTime *dt, int hour)
 returns: 0 on success -1 if 'dt' has an invalid hour -2 if 'dt' has no hour More...
 
int datetime_check_minute (const DateTime *dt, int minute)
 returns: 0 on success -1 if 'dt' has an invalid minute -2 if 'dt' has no minute More...
 
int datetime_check_second (const DateTime *dt, double second)
 returns: 0 on success -1 if 'dt' has an invalid second -2 if 'dt' has no second More...
 
int datetime_check_fracsec (const DateTime *dt, int fracsec)
 returns: 0 on success -1 if 'dt' has an invalid fracsec -2 if 'dt' has no fracsec More...
 
int datetime_get_year (const DateTime *dt, int *year)
 returns 0 on success or negative value on error More...
 
int datetime_set_year (DateTime *dt, int year)
 if dt.mode = ABSOLUTE, this also sets dt.day = 0 More...
 
int datetime_get_month (const DateTime *dt, int *month)
 returns 0 on success or negative value on error More...
 
int datetime_set_month (DateTime *dt, int month)
 if dt.mode = ABSOLUTE, this also sets dt.day = 0 More...
 
int datetime_get_day (const DateTime *dt, int *day)
 returns 0 on success or negative value on error More...
 
int datetime_set_day (DateTime *dt, int day)
 if dt.mode = ABSOLUTE, then the dt.year, dt.month: More...
 
int datetime_get_hour (const DateTime *dt, int *hour)
 returns 0 on success or negative value on error More...
 
int datetime_set_hour (DateTime *dt, int hour)
 returns 0 on success or negative value on error More...
 
int datetime_get_minute (const DateTime *dt, int *minute)
 returns 0 on success or negative value on error More...
 
int datetime_set_minute (DateTime *dt, int minute)
 returns 0 on success or negative value on error More...
 
int datetime_get_second (const DateTime *dt, double *second)
 returns 0 on success or negative value on error More...
 
int datetime_set_second (DateTime *dt, double second)
 returns 0 on success or negative value on error More...
 
int datetime_get_fracsec (const DateTime *dt, int *fracsec)
 returns 0 on success or negative value on error More...
 
int datetime_set_fracsec (DateTime *dt, int fracsec)
 returns 0 on success or negative value on error More...
 

Function Documentation

◆ datetime_change_from_to()

int datetime_change_from_to ( DateTime dt,
int  from,
int  to,
int  round 
)

Changes the from/to of the type for dt. The 'from/to' must be legal values for the mode of dt; (if they are not legal, then the original values are preserved, dt is not changed). Returns: 0 OK -1 invalid 'dt' -2 invalid 'from/to'

  • round = negative implies floor() [decrease magnitude] 0 implies normal rounding, [incr/decr magnitude] positive implies ceil() [increase magnitude]
  • If dt.from < 'from' (losing "lower" elements), convert the "lost" values to the equivalent value for the new 'from' Lost elements are then set to zero. (This case can only occur for dt.mode relative): months += lost years * 12 ; years = 0 hours += lost days * 24 ; days = 0 minutes += lost hours * 60 ; hours = 0 seconds += lost minutes * 60.0 ; minutes = 0
  • If dt.from > 'from' (adding "lower" elements), the new elements are set to zero.
  • If dt.to < 'to' (adding "higher" elements), the new elements are set to zero.
  • If dt.to > 'to' (losing "higher" elements), the the new 'to' is adjusted according to the value for 'round' After rounding the "lost" elements are set to zero.
Parameters
dt
from
to
round
Returns
int

Definition at line 55 of file change.c.

Referenced by datetime_get_local_timezone().

◆ datetime_change_timezone()

int datetime_change_timezone ( DateTime dt,
int  minutes 
)

if dt has a timezone, increment dt by minutes-dt.tz MINUTES and set dt.tz = minutes Returns: 0 OK datetime_check_timezone (dt) if not -4 if minutes invalid

Parameters
dt
minutes
Returns
int

Definition at line 24 of file tz2.c.

References datetime_error(), datetime_get_timezone(), datetime_increment(), datetime_invert_sign(), datetime_is_valid_timezone(), DATETIME_MINUTE, DATETIME_RELATIVE, datetime_set_minute(), and datetime_set_type().

Referenced by datetime_change_to_utc().

◆ datetime_change_to_utc()

int datetime_change_to_utc ( DateTime dt)

Return datetime_change_timezone (dt, 0);.

Parameters
dt
Returns
int

Definition at line 63 of file tz2.c.

References datetime_change_timezone().

◆ datetime_check_day()

int datetime_check_day ( const DateTime dt,
int  day 
)

Returns: 0 is legal day for dt -1 illegal day for this dt -2 dt has no day component
Note: if dt.mode is ABSOLUTE, then dt.year and dt.month must also be legal, since the 'day' must be a legal value for the dt.year/dt.month.

Parameters
dt
day
Returns
int

Definition at line 91 of file values.c.

Referenced by datetime_get_day(), and datetime_set_day().

◆ datetime_check_fracsec()

int datetime_check_fracsec ( const DateTime dt,
int  fracsec 
)

returns: 0 on success -1 if 'dt' has an invalid fracsec -2 if 'dt' has no fracsec

Parameters
dt
fracsec
Returns
int

Definition at line 207 of file values.c.

Referenced by datetime_get_fracsec(), and datetime_set_fracsec().

◆ datetime_check_hour()

int datetime_check_hour ( const DateTime dt,
int  hour 
)

returns: 0 on success -1 if 'dt' has an invalid hour -2 if 'dt' has no hour

Parameters
dt
hour
Returns
int

Definition at line 129 of file values.c.

Referenced by datetime_get_hour(), and datetime_set_hour().

◆ datetime_check_increment()

int datetime_check_increment ( const DateTime src,
const DateTime incr 
)

This checks if the type of 'incr' is valid for incrementing/decrementing 'src'. The type (mode/from/to) of the 'src' can be anything. The incr.mode must be RELATIVE A timezone in 'src' is allowed - it's presence is ignored. To aid in setting the 'incr' type, see datetime_get_increment_type(). Returns:

  • 0 valid increment
  • 1 src is not a legal DateTime, error code/msg are those set by datetime_is_valid_type()
  • 2 incr is not a legal DateTime, error code/msg are those set by datetime_is_valid_type()
  • -1 incr.mode not relative
  • -2 incr more precise that src
  • -3 illegal incr, must be YEAR-MONTH
  • -4 illegal incr, must be DAY-SECOND
Parameters
src
incr
Returns
int

Definition at line 60 of file incr2.c.

◆ datetime_check_minute()

int datetime_check_minute ( const DateTime dt,
int  minute 
)

returns: 0 on success -1 if 'dt' has an invalid minute -2 if 'dt' has no minute

Parameters
dt
minute
Returns
int

Definition at line 155 of file values.c.

Referenced by datetime_get_minute(), and datetime_set_minute().

◆ datetime_check_month()

int datetime_check_month ( const DateTime dt,
int  month 
)

Returns: 0 is legal month for dt -1 illegal month for this dt -2 dt has no month component.

Parameters
dt
month
Returns
int

Definition at line 55 of file values.c.

Referenced by datetime_get_month(), and datetime_set_month().

◆ datetime_check_second()

int datetime_check_second ( const DateTime dt,
double  second 
)

returns: 0 on success -1 if 'dt' has an invalid second -2 if 'dt' has no second

Parameters
dt
second
Returns
int

Definition at line 181 of file values.c.

◆ datetime_check_timezone()

int datetime_check_timezone ( const DateTime dt,
int  minutes 
)

returns 0 on success

Parameters
dt
minutes
Returns
int

Definition at line 26 of file tz1.c.

References datetime_error(), and datetime_is_absolute().

Referenced by datetime_get_timezone(), and datetime_set_timezone().

◆ datetime_check_type()

int datetime_check_type ( const DateTime dt)

checks the mode/from/to/fracsec in dt. Returns:

  • 0: OK
  • -1: mode is invalid - not one of {ABSOLUTE,RELATIVE}
  • -2: from is invalid - not one of {YEAR,MONTH,DAY,HOUR,MINUTE,SECOND}
  • -3: to is invalid - not one of {YEAR,MONTH,DAY,HOUR,MINUTE,SECOND}
  • -4: from/to are reversed (from>to is illegal)
  • -5: invalid from/to combination for RELATIVE mode: from in {YEAR,MONTH} but to is not, or from in {DAY,HOUR,MINUTE,SECOND} but to is not
  • -6: from is invalid for ABSOLUTE mode (from != YEAR is illegal)
  • -7: fracsec is negative (only if to==SECOND)
Parameters
dt
Returns
int

Definition at line 116 of file datetime/type.c.

References DATETIME_ABSOLUTE, datetime_error(), datetime_in_interval_day_second(), datetime_in_interval_year_month(), datetime_is_between(), DATETIME_RELATIVE, DATETIME_SECOND, DATETIME_YEAR, DateTime::fracsec, DateTime::from, DateTime::mode, and DateTime::to.

Referenced by datetime_is_valid_type().

◆ datetime_check_year()

int datetime_check_year ( const DateTime dt,
int  year 
)

Returns: 0 is legal year for dt -1 illegal year for this dt -2 dt has no year component.

Parameters
dt
year
Returns
int

Definition at line 29 of file values.c.

Referenced by datetime_get_year(), and datetime_set_year().

◆ datetime_clear_error()

void datetime_clear_error ( void  )

clears error code and message

Returns
void

Definition at line 75 of file datetime/error.c.

◆ datetime_copy()

void datetime_copy ( DateTime dst,
const DateTime src 
)

Copies the DateTime [into/from ???] src.

Parameters
dst
src
Returns
void

Definition at line 20 of file datetime/copy.c.

◆ datetime_days_in_month()

int datetime_days_in_month ( int  year,
int  month,
int  ad 
)

returns number of days in 'month' of a particular 'year'

Parameters
month
year
ad
Returns
int

Definition at line 64 of file datetime/misc.c.

References datetime_error(), and datetime_is_leap_year().

◆ datetime_days_in_year()

int datetime_days_in_year ( int  year,
int  ad 
)

returns the number of days in 'year'

Parameters
year
ad
Returns
int

Definition at line 41 of file datetime/misc.c.

References datetime_error(), and datetime_is_leap_year().

◆ datetime_decompose_timezone()

void datetime_decompose_timezone ( int  tz,
int *  hours,
int *  minutes 
)

tz = abs(tz) *hour = tz/60 *minute = tz%60 Note: hour,minute are non-negative. Must look at sign of tz itself to see if the tz is negative offset or not. This routine would be used to format tz for output. For example if tz=-350 this would be hour=5 minute=50, but negative. Output might encode this as -0550: printf ("%s%02d%02d", tz<0?"-":"", hour, minute)

Parameters
tz
hours
minutes
Returns
void

Definition at line 87 of file tz2.c.

◆ datetime_difference()

int datetime_difference ( const DateTime a,
const DateTime b,
DateTime result 
)

This performs the formula: result = a - b;.

  • both a and b must be absolute.
  • result will be relative
  • If a is "earlier" than b, then result will be set negative.
  • b must be no more "precise" than a. (a copy of b is "extended" to the precision of a)
  • If result.to == SECOND, then result.fracsec is a.fracsec
  • result will have the following from/to based on a.to: result a.to from to YEAR YEAR YEAR MONTH YEAR MONTH DAY DAY DAY HOUR DAY HOUR MINUTE DAY MINUTE SECOND DAY SECOND [LAYOUT ??? - see HTML]
  • If either 'a' or 'b' has a timezone, both must have a timezone. The difference will account for the differences in the time zones.
Parameters
a
b
result
Returns
int

Definition at line 81 of file diff.c.

Referenced by datetime_get_local_timezone().

◆ datetime_error()

int datetime_error ( int  code,
char *  msg 
)

record 'code' and 'msg' as error code/msg (in static variables) code==0 will clear the error (ie set msg=NULL) returns 'code' so that it can be used like:

return datetime_error (-1, "bad date");
Parameters
code
msg
Returns
int

Definition at line 30 of file datetime/error.c.

Referenced by datetime_change_timezone(), datetime_check_timezone(), datetime_check_type(), datetime_days_in_month(), datetime_days_in_year(), and datetime_is_leap_year().

◆ datetime_error_code()

int datetime_error_code ( void  )

returns an error code

Returns
int

Definition at line 48 of file datetime/error.c.

Referenced by datetime_format().

◆ datetime_error_msg()

char* datetime_error_msg ( void  )

returns an error message

Returns
char *

Definition at line 61 of file datetime/error.c.

◆ datetime_format()

int datetime_format ( const DateTime dt,
char *  buf 
)

formats DateTime structure as a human-readable string returns 0 when successful and 'buf' is filled with the string returns a negative number on error

Parameters
dt
buf
Returns
int

Definition at line 28 of file datetime/format.c.

References datetime_error_code(), datetime_get_day(), datetime_get_month(), datetime_is_absolute(), and datetime_is_valid_type().

◆ datetime_get_day()

int datetime_get_day ( const DateTime dt,
int *  day 
)

returns 0 on success or negative value on error

Parameters
dt
day
Returns
int

Definition at line 325 of file values.c.

References datetime_check_day(), and DateTime::day.

Referenced by datetime_format().

◆ datetime_get_fracsec()

int datetime_get_fracsec ( const DateTime dt,
int *  fracsec 
)

returns 0 on success or negative value on error

Parameters
dt
fracsec
Returns
int

Definition at line 508 of file values.c.

References datetime_check_fracsec(), and DateTime::fracsec.

◆ datetime_get_hour()

int datetime_get_hour ( const DateTime dt,
int *  hour 
)

returns 0 on success or negative value on error

Parameters
dt
hour
Returns
int

Definition at line 376 of file values.c.

References datetime_check_hour(), and DateTime::hour.

◆ datetime_get_increment_type()

int datetime_get_increment_type ( const DateTime dt,
int *  mode,
int *  from,
int *  to,
int *  fracsec 
)

This returns the components of a type (mode/from/to/fracsec) that can be used to construct a DateTime object that can be used to increment the 'src'. Also see datetime_set_increment_type(). returns: 0 dt is legal !=0 why dt is illegal Implemented as follows:

*mode = RELATIVE
*to = src.to
*fracsec = src.fracsec
if src.mode is ABSOLUTE
if src.to is in {YEAR,MONTH} then
*from = YEAR
if src.to is in {DAY,HOUR,MINUTE,SECOND} then
*from = DAY
if src.mode is RELATIVE, then
*from = src.from
Parameters
dt
mode
from
to
fracsec
Returns
int

Definition at line 42 of file incr3.c.

◆ datetime_get_local_time()

void datetime_get_local_time ( DateTime dt)

set mode/from/to ABSOLUTE/YEAR/SECOND set the local time into 'dt' does not set timezone.

Parameters
dt
Returns
void

Definition at line 87 of file local.c.

References DATETIME_ABSOLUTE, DATETIME_SECOND, datetime_set_day(), datetime_set_hour(), datetime_set_minute(), datetime_set_month(), datetime_set_second(), datetime_set_type(), datetime_set_year(), DATETIME_YEAR, and localtime().

◆ datetime_get_local_timezone()

◆ datetime_get_minute()

int datetime_get_minute ( const DateTime dt,
int *  minute 
)

returns 0 on success or negative value on error

Parameters
dt
minute
Returns
int

Definition at line 420 of file values.c.

References datetime_check_minute(), and DateTime::minute.

◆ datetime_get_month()

int datetime_get_month ( const DateTime dt,
int *  month 
)

returns 0 on success or negative value on error

Parameters
dt
month
Returns
int

Definition at line 276 of file values.c.

References datetime_check_month(), and DateTime::month.

Referenced by datetime_format().

◆ datetime_get_second()

int datetime_get_second ( const DateTime dt,
double *  second 
)

returns 0 on success or negative value on error

Parameters
dt
second
Returns
int

Definition at line 464 of file values.c.

◆ datetime_get_timezone()

int datetime_get_timezone ( const DateTime dt,
int *  minutes 
)

returns 0 on success

Parameters
dt
minutes
Returns
int

Definition at line 49 of file tz1.c.

References datetime_check_timezone(), and DateTime::tz.

Referenced by datetime_change_timezone().

◆ datetime_get_type()

int datetime_get_type ( const DateTime dt,
int *  mode,
int *  from,
int *  to,
int *  fracsec 
)

Definition at line 58 of file datetime/type.c.

◆ datetime_get_year()

int datetime_get_year ( const DateTime dt,
int *  year 
)

returns 0 on success or negative value on error

Parameters
dt
year
Returns
int

Definition at line 227 of file values.c.

References datetime_check_year(), and DateTime::year.

◆ datetime_in_interval_day_second()

int datetime_in_interval_day_second ( int  x)

Definition at line 156 of file datetime/type.c.

References DATETIME_DAY, datetime_is_between(), and DATETIME_SECOND.

Referenced by datetime_check_type().

◆ datetime_in_interval_year_month()

int datetime_in_interval_year_month ( int  x)

Definition at line 151 of file datetime/type.c.

References datetime_is_between(), DATETIME_MONTH, and DATETIME_YEAR.

Referenced by datetime_check_type().

◆ datetime_increment()

int datetime_increment ( DateTime src,
DateTime incr 
)

This function changes the 'src' date/time data based on the 'incr' The type (mode/from/to) of the 'src' can be anything. The mode of the 'incr' must be RELATIVE, and the type (mode/from/to) for 'incr' must be a valid increment for 'src'. See datetime_is_valid_increment(), datetime_check_increment() Returns: 0: OK -1: 'incr' is invalid increment for 'src' For src.mode ABSOLUTE,.

  • positive 'incr' moves into the future,
  • negative 'incr' moves into the past.
  • BC implies the year is negative, but all else is positive. Also, year==0 is illegal: adding 1 year to 1[bc] gives 1[ad]

The 'fracsec' in 'src' is preserved. The 'from/to' of the 'src' is preserved. A timezone in 'src' is allowed - it's presence is ignored. NOTE: There is no datetime_decrement() To decrement, set the 'incr' negative.

Parameters
src
incr
Returns
int

Definition at line 67 of file incr1.c.

Referenced by datetime_change_timezone().

◆ datetime_invert_sign()

void datetime_invert_sign ( DateTime dt)
Parameters
dt
Returns
void

Definition at line 80 of file sign.c.

References DateTime::positive.

Referenced by datetime_change_timezone().

◆ datetime_is_absolute()

int datetime_is_absolute ( const DateTime dt)

Returns: 1 if dt.mode is absolute 0 if not (even if dt.mode is not defined)

Parameters
dt
Returns
int

Definition at line 173 of file datetime/type.c.

References DATETIME_ABSOLUTE, and DateTime::mode.

Referenced by datetime_check_timezone(), datetime_format(), datetime_set_month(), and datetime_set_year().

◆ datetime_is_between()

int datetime_is_between ( int  x,
int  a,
int  b 
)

◆ datetime_is_leap_year()

int datetime_is_leap_year ( int  year,
int  ad 
)
Parameters
year
ad
Returns
int

Definition at line 18 of file datetime/misc.c.

References datetime_error().

Referenced by datetime_days_in_month(), and datetime_days_in_year().

◆ datetime_is_negative()

int datetime_is_negative ( const DateTime dt)

Returns: 1 if the DateTime is negative 0 otherwise.

Parameters
dt
Returns
int

Definition at line 37 of file sign.c.

References DateTime::positive.

◆ datetime_is_positive()

int datetime_is_positive ( const DateTime dt)

Returns: 1 if the Datetime is positive 0 otherwise.

Parameters
dt
Returns
int

Definition at line 21 of file sign.c.

References DateTime::positive.

◆ datetime_is_relative()

int datetime_is_relative ( const DateTime dt)

Returns: 1 if dt.mode is relative 0 if not (even if dt.mode is not defined)

Parameters
dt
Returns
int

Definition at line 190 of file datetime/type.c.

References DATETIME_RELATIVE, and DateTime::mode.

◆ datetime_is_same()

int datetime_is_same ( const DateTime src,
const DateTime dst 
)

Returns: 1 if 'src' is exactly the same as 'dst' 0 if they differ.

Parameters
src
dst
Returns
int

Definition at line 23 of file same.c.

◆ datetime_is_valid_increment()

int datetime_is_valid_increment ( const DateTime src,
const DateTime incr 
)

Returns: datetime_check_increment(src, incr) == 0.

Parameters
src
incr
Returns
int

Definition at line 21 of file incr2.c.

◆ datetime_is_valid_timezone()

int datetime_is_valid_timezone ( int  minutes)

Returns: 1 OK: -720 <= minutes <= 780 (720 = 12 hours; 780 = 13 hours) 0 NOT OK.

Parameters
minutes
Returns
int

Definition at line 111 of file tz1.c.

Referenced by datetime_change_timezone().

◆ datetime_is_valid_type()

int datetime_is_valid_type ( const DateTime dt)

Returns: 1 if datetime_check_type() returns 0 0 if not.

Parameters
dt
Returns
int

Definition at line 80 of file datetime/type.c.

References datetime_check_type().

Referenced by datetime_format().

◆ datetime_scan()

int datetime_scan ( DateTime dt,
const char *  buf 
)

Convert the ascii string into a DateTime. This determines the mode/from/to based on the string, inits 'dt' and then sets values in 'dt' based on the [???] Returns 0 if 'string' is legal, -1 if not.

Parameters
dt
buf
Returns
int

Definition at line 43 of file scan.c.

◆ datetime_set_day()

int datetime_set_day ( DateTime dt,
int  day 
)

if dt.mode = ABSOLUTE, then the dt.year, dt.month:

if (day > <b>datetime_days_in_month</b> (dt.year, dt.month))
{error}

This implies that year/month must be set for ABSOLUTE datetimes.

Returns 0 on success or negative value on error

Parameters
dt
day
Returns
int

Definition at line 354 of file values.c.

References datetime_check_day(), and DateTime::day.

Referenced by datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_set_fracsec()

int datetime_set_fracsec ( DateTime dt,
int  fracsec 
)

returns 0 on success or negative value on error

Parameters
dt
fracsec
Returns
int

Definition at line 530 of file values.c.

References datetime_check_fracsec(), and DateTime::fracsec.

◆ datetime_set_hour()

int datetime_set_hour ( DateTime dt,
int  hour 
)

returns 0 on success or negative value on error

Parameters
dt
hour
Returns
int

Definition at line 398 of file values.c.

References datetime_check_hour(), and DateTime::hour.

Referenced by datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_set_increment_type()

int datetime_set_increment_type ( const DateTime src,
DateTime incr 
)

src must be legal This is a convenience routine which is implemented as follows:

int mode, from ,to;
int fracsec;
if(<b>datetime_get_increment_type</b>(src, &mode, &from, &to, &fracsec))
return <b>datetime_get_error_code()</b>;
return <b>datetime_set_type</b> (incr, mode, from, to, fracsec);

Timezone Timezones are represented in minutes from GMT in the range [-720,+780]. For a DateTime to have a timezone, it must be of type ABSOLUTE, and "to" must be in {MINUTE,SECOND}.

Parameters
src
incr
Returns
int

Definition at line 86 of file incr3.c.

◆ datetime_set_minute()

int datetime_set_minute ( DateTime dt,
int  minute 
)

returns 0 on success or negative value on error

Parameters
dt
minute
Returns
int

Definition at line 442 of file values.c.

References datetime_check_minute(), and DateTime::minute.

Referenced by datetime_change_timezone(), datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_set_month()

int datetime_set_month ( DateTime dt,
int  month 
)

if dt.mode = ABSOLUTE, this also sets dt.day = 0

returns 0 on success or negative value on error

Parameters
dt
month
Returns
int

Definition at line 300 of file values.c.

References datetime_check_month(), datetime_is_absolute(), DateTime::day, and DateTime::month.

Referenced by datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_set_negative()

void datetime_set_negative ( DateTime dt)

Makes the DateTime negative. (B.C. for ABSOLUTE DateTimes)

Parameters
dt
Returns
void

Definition at line 67 of file sign.c.

References DateTime::positive.

◆ datetime_set_positive()

void datetime_set_positive ( DateTime dt)

Makes the DateTime positive. (A.D. for ABSOLUTE DateTimes)

Parameters
dt
Returns
void

Definition at line 52 of file sign.c.

References DateTime::positive.

◆ datetime_set_second()

int datetime_set_second ( DateTime dt,
double  second 
)

returns 0 on success or negative value on error

Parameters
dt
second
Returns
int

Definition at line 486 of file values.c.

Referenced by datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_set_timezone()

int datetime_set_timezone ( DateTime dt,
int  minutes 
)

returns 0 on success

Parameters
dt
minutes
Returns
int

Definition at line 71 of file tz1.c.

References datetime_check_timezone(), and DateTime::tz.

◆ datetime_set_type()

int datetime_set_type ( DateTime dt,
int  mode,
int  from,
int  to,
int  fracsec 
)
  • This routine must be called can be made with other datetime functions.
  • initialize all the elements in dt.
  • Set all values to zero except: tz (set to illegal value - 99*24) positive (set to 1 for positive)
  • Set the type info in dt: mode, from, to, fracsec
  • validate the mode/from/to/fracsec (according to the rules for the mode)
  • return the return value from datetime_check_type(dt)
Parameters
mode
from
to
fracsec
Returns
int

Definition at line 37 of file datetime/type.c.

Referenced by datetime_change_timezone(), datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_set_year()

int datetime_set_year ( DateTime dt,
int  year 
)

if dt.mode = ABSOLUTE, this also sets dt.day = 0

returns 0 on success or negative value on error

Parameters
dt
year
Returns
int

Definition at line 251 of file values.c.

References datetime_check_year(), datetime_is_absolute(), DateTime::day, and DateTime::year.

Referenced by datetime_get_local_time(), and datetime_get_local_timezone().

◆ datetime_unset_timezone()

int datetime_unset_timezone ( DateTime dt)

unsets timezone in 'dt' returns 0

Parameters
dt
Returns
int

Definition at line 92 of file tz1.c.

References DateTime::tz.