32 #ifndef QORE_DATETIME_H 34 #define QORE_DATETIME_H 38 class AbstractQoreZoneInfo;
42 int year, month, day, hour, minute, second, us, utc_secs_east;
44 const char* zone_name;
45 const AbstractQoreZoneInfo* zone;
47 DLLLOCAL
void clear() {
61 DLLLOCAL
bool isTimeNull()
const {
62 return !hour && !minute && !second && !us;
95 friend class qore_relative_time;
96 friend class qore_absolute_time;
102 DLLLOCAL
void setDateLiteral(
int64 date);
103 DLLLOCAL
void setRelativeDateLiteral(
int64 date);
109 DLLLOCAL
DateTime(qore_date_private *n_priv);
129 DLLEXPORT
DateTime(
int n_year,
int n_month,
int n_day,
int n_hour = 0,
int n_minute = 0,
int n_second = 0,
short n_ms = 0,
bool n_relative =
false);
151 DLLEXPORT
explicit DateTime(
const AbstractQoreZoneInfo* zone,
const QoreValue v);
162 DLLEXPORT
DateTime(
const char* date);
176 DLLEXPORT
DateTime(
const AbstractQoreZoneInfo* zone,
const char* date);
182 DLLEXPORT
DateTime(
const struct tm *tms);
191 DLLEXPORT
void getTM(
struct tm *tms)
const;
196 DLLEXPORT
void setNow();
202 DLLEXPORT
void setNow(
const AbstractQoreZoneInfo* zone);
208 DLLEXPORT
void setDate(
int64 seconds);
215 DLLEXPORT
void setDate(
int64 seconds,
int ms);
222 DLLEXPORT
void setDate(
const AbstractQoreZoneInfo* zone,
int64 seconds,
int us);
229 DLLEXPORT
void setLocalDate(
const AbstractQoreZoneInfo* zone,
int64 seconds,
int us);
232 DLLEXPORT
void setDate(
const AbstractQoreZoneInfo* n_zone,
int n_year,
int n_month,
int n_day,
int n_hour = 0,
int n_minute = 0,
int n_second = 0,
int n_us = 0);
238 DLLEXPORT
void setDate(
const char* str);
247 DLLEXPORT
void setDate(
const char* str,
ExceptionSink* xsink);
254 DLLEXPORT
void setDate(
const AbstractQoreZoneInfo* zone,
const char* str);
257 DLLEXPORT
void setRelativeDate(
const char* str);
260 DLLEXPORT
void setDate(
const struct tm *tms,
short ms = 0);
263 DLLEXPORT
void setDate(
const DateTime &date);
272 DLLEXPORT
void setTime(
int h,
int m,
int s,
short ms = 0);
275 DLLEXPORT
void setRelativeDateSeconds(
int64 s,
int us = 0);
277 DLLEXPORT
bool checkValidity()
const;
278 DLLEXPORT
bool isEqual(
const DateTime* dt)
const;
279 DLLEXPORT
bool isEqual(
const DateTime& dt)
const;
293 DLLEXPORT
void addSecondsTo(
int64 secs,
int us = 0);
299 DLLEXPORT
int64 getEpochSeconds()
const;
305 DLLEXPORT
int64 getEpochSecondsUTC()
const;
311 DLLEXPORT
int64 getEpochMicrosecondsUTC()
const;
317 DLLEXPORT
int64 getEpochMillisecondsUTC()
const;
323 DLLEXPORT
int getDayNumber()
const;
329 DLLEXPORT
int getDayOfWeek()
const;
337 DLLEXPORT
void getISOWeek(
int& year,
int& week,
int& day)
const;
379 DLLEXPORT
void format(
QoreString& str,
const char* fmt)
const;
385 DLLEXPORT
bool isRelative()
const;
391 DLLEXPORT
bool isAbsolute()
const;
397 DLLEXPORT
short getYear()
const;
403 DLLEXPORT
int getMonth()
const;
409 DLLEXPORT
int getDay()
const;
415 DLLEXPORT
int getHour()
const;
421 DLLEXPORT
int getMinute()
const;
427 DLLEXPORT
int getSecond()
const;
433 DLLEXPORT
int getMillisecond()
const;
438 DLLEXPORT
int getMicrosecond()
const;
444 DLLEXPORT
int64 getRelativeSeconds()
const;
450 DLLEXPORT
int64 getRelativeMilliseconds()
const;
456 DLLEXPORT
int64 getRelativeMicroseconds()
const;
462 DLLEXPORT
double getRelativeSecondsDouble()
const;
465 DLLEXPORT
bool hasValue()
const;
468 DLLEXPORT
DateTime* unaryMinus()
const;
471 DLLEXPORT
void unaryMinusInPlace();
474 DLLEXPORT
void getInfo(
const AbstractQoreZoneInfo* n_zone,
qore_tm &info)
const;
477 DLLEXPORT
void getInfo(
qore_tm &info)
const;
480 DLLEXPORT
void setZone(
const AbstractQoreZoneInfo* n_zone);
483 DLLEXPORT
const AbstractQoreZoneInfo* getZone()
const;
487 DLLEXPORT
static bool isLeapYear(
int year);
490 DLLEXPORT
static int getLastDayOfMonth(
int month,
int year);
504 DLLEXPORT
static int compareDates(
const DateTime* left,
const DateTime* right);
507 DLLEXPORT
static DateTime* makeAbsolute(
const AbstractQoreZoneInfo* n_zone,
int n_year,
int n_month,
int n_day,
int n_hour = 0,
int n_minute = 0,
int n_second = 0,
int n_us = 0);
515 DLLEXPORT
static DateTime* makeAbsolute(
const AbstractQoreZoneInfo* zone,
int64 seconds,
int us = 0);
523 DLLEXPORT
static DateTime* makeAbsoluteLocal(
const AbstractQoreZoneInfo* zone,
int64 seconds,
int us = 0);
526 DLLEXPORT
static DateTime* makeRelative(
int n_year,
int n_month,
int n_day,
int n_hour = 0,
int n_minute = 0,
int n_second = 0,
int n_us = 0);
529 DLLEXPORT
static DateTime* makeRelativeFromSeconds(
int64 n_second,
int n_us = 0);
DLLEXPORT const char * regionName() const
returns the region name of the zone
class qore_date_private * priv
private date data - most are ints so relative dates can hold a lot of data
Definition: DateTime.h:100
Holds absolute and relative date/time values in Qore with precision to the microsecond.
Definition: DateTime.h:93
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:81
Qore's parse tree/value type for date-time values, reference-counted, dynamically-allocated only...
Definition: DateTimeNode.h:45
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:262
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:46
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260
DLLEXPORT int secsEast() const
returns seconds east of UTC for zone
for returning broken-down time information
Definition: DateTime.h:41