dtl
Category: utilities | Component type: type |
jtime_c objects represent Julian dates. This class supports dates from Jan. 1, 1970 to Jan. 1, 4000. jtime_c objects can be converted freely into SQL timestamps (TIMESTAMP_STRUCT's) or jtime_t values (long indicating the number of seconds elapsed since Jan. 1, 1970, midnight).
Defined in the date_util.h header file.
None.
typedef struct tag_jtime_tm { int sec; // Seconds after the minute (0, 61) int min; // minutes after the hour (0, 59) int hour; // hours since midnight (0, 23) int day; // day of the month int mon; // month number (1, 12) int year; // year number (AD) } jtime_tm;
None.
See date_unit_test() in date_util.cpp.
X | A type that is a model of jtime_c |
a | Object of type X |
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Default constructor | X a() |
Default Constructor. | ||
Copy constructor | X a(const X &b) |
Copy construct a jtime_c. | ||
Construct from SQL timestamp | X a(const TIMESTAMP_STRUCT &b) |
Construct from a TIMESTAMP_STRUCT. | ||
Construct from jtime_t | X a(const jtime_t &b) |
Construct from a jtime_t. | ||
Assignment operators | X& operator=(const X&b) X& operator=(const TIMESTAMP_STRUCT &b) X& operator=(const jtime_t &b) |
Assignment of a date. | ||
Comparison operators | friend
bool operator<(const jtime_c &lhs, const jtime_c
&rhs) friend bool operator<(const jtime_c &lhs, const jtime_c &rhs) friend bool operator>(const jtime_c &lhs, const jtime_c &rhs) friend bool operator<=(const jtime_c &lhs, const jtime_c &rhs) friend bool operator>=(const jtime_c &lhs, const jtime_c &rhs) friend bool operator!=(const jtime_c &lhs, const jtime_c &rhs) |
Compare two dates. Note that these are friends. | ||
Stream operator | friend ostream &operator<<(ostream &o, const jtime_c &ts) |
Stream out the date to o. Note that this is a friend. | ||
Conversion operators | operator jtime_t() const operator TIMESTAMP_STRUCT() const |
Converts the object into the appropriate date type. |
Description | Expression |
---|---|
Returns current local time including seconds | jtime_t Now() |
Returns current local time rounded down to midnight of that day. (i.e. the current day). | jtime_t Today() |
Convert from an ODBC timestamp to jtime_t | RETCODE Timestamp2Jtime(const timestamp_t *tst, jtime_t *jtime ); |
Convert from a jtime_t to an ODBC timestamp. | RETCODE Jtime2Timestamp(jtime_t jtime, timestamp_t *tst)& operator=(const X&b) |
Convert a date in day/month/year format to a jtime_t | RETCODE julday(int day, int month, int year, jtime_t *jtime) |
Convert from jtime_t to a jtime_tm structure. | RETCODE unjultime(jtime_t jtime, jtime_tm *time) |
Convert a jtime_tm structure into a jtime_t | RETCODE jultime(const jtime_tm *time, jtime_t *jtime) |
Add the time in the jtime_tm structure to the date held by oldtime. | RETCODE addtime(jtime_t oldtime, jtime_tm add, jtime_t *newtime) |
Add the number of seconds to the date passed in | jtime_t addsecs(jtime_t oldtime, int secs) |
Add the number of hours to the date passed in | jtime_t addhours(jtime_t oldtime, int hours) |
Add the number of days to the date passed in | jtime_t adddays(jtime_t oldtime, int days) |
Add the number of months to the date passed in | jtime_t addmonths(jtime_t oldtime, int months) |
Return the date as a string down to the day in the formt 'MON-DD-YYYY HH:MM:SS' |
string jul2str(jtime_t juldate) |
Return the time as a string down to the second in the format 'MON-DD-YYYY HH:MM:SS'. If HH:MM:SS is midnight this will be truncated down to a day format. |
string jul2strtm(jtime_t jtime) |
Convert the date into a SQL date string |
void jul2SQLtm(jtime_t jultime, string szSQLtm) |
Convert the string date in the format 'MON-DD-YYYY' to a Julian date |
RETCODE str2jultm(string szDt, jtime_t *jtime) |
Find the difference in the appropriate time units | double diffdays(jtime_t date1, jtime_t date2) double diffhours(jtime_t date1, jtime_t date2) double diffsecs(jtime_t date1, jtime_t date2) |
Find the end of the month, week, or day passed in. | jtime_t eomonth(jtime_t oldtime) jtime_t eoweek(jtime_t oldtime) jtime_t eoday(jtime_t oldtime) |
Find the beginning of the month, week, or day passed in. (Beginning of a day is at midnight). | jtime_t beginmonth(jtime_t oldtime) jtime_t beginweek(jtime_t oldtime) jtime_t beginday(jtime_t oldtime) |
Return the number of days in the month of the year | int month_days(int year, int month) |
Given a particular date return the what week in the current month this represents, i.e. first week, second week, etc. Weeks are assumed to start on Sunday and end on Saturday. | int monthweek(jtime_t jtime) |
Return the year, or month of the week of the passed in date. | int year(jtime_t oldtime) int month(jtime_t oldtime) |
Return the maximum or minimum of the two dates passed in. | jtime_t maxtime(jtime_t a, jtime_t b) jtime_t mintime(jtime_t a, jtime_t b) |
None.
Copyright © 2002, Michael Gradman and Corwin Joy.
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appears in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Corwin Joy and Michael Gradman make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.