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);
157 DLLEXPORT
explicit DateTime(
const QoreValue v);
162 DLLEXPORT
DateTime(
const char* date);
168 DLLEXPORT
DateTime(
const AbstractQoreZoneInfo* zone,
const char* date);
174 DLLEXPORT
DateTime(
const struct tm *tms);
183 DLLEXPORT
void getTM(
struct tm *tms)
const;
188 DLLEXPORT
void setNow();
194 DLLEXPORT
void setNow(
const AbstractQoreZoneInfo* zone);
200 DLLEXPORT
void setDate(
int64 seconds);
207 DLLEXPORT
void setDate(
int64 seconds,
int ms);
214 DLLEXPORT
void setDate(
const AbstractQoreZoneInfo* zone,
int64 seconds,
int us);
221 DLLEXPORT
void setLocalDate(
const AbstractQoreZoneInfo* zone,
int64 seconds,
int us);
224 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);
230 DLLEXPORT
void setDate(
const char* str);
237 DLLEXPORT
void setDate(
const AbstractQoreZoneInfo* zone,
const char* str);
240 DLLEXPORT
void setRelativeDate(
const char* str);
243 DLLEXPORT
void setDate(
const struct tm *tms,
short ms = 0);
246 DLLEXPORT
void setDate(
const DateTime &date);
255 DLLEXPORT
void setTime(
int h,
int m,
int s,
short ms = 0);
257 DLLEXPORT
bool checkValidity()
const;
258 DLLEXPORT
bool isEqual(
const DateTime* dt)
const;
259 DLLEXPORT
bool isEqual(
const DateTime& dt)
const;
273 DLLEXPORT
void addSecondsTo(
int64 secs,
int us = 0);
279 DLLEXPORT
int64 getEpochSeconds()
const;
285 DLLEXPORT
int64 getEpochSecondsUTC()
const;
291 DLLEXPORT
int64 getEpochMicrosecondsUTC()
const;
297 DLLEXPORT
int64 getEpochMillisecondsUTC()
const;
303 DLLEXPORT
int getDayNumber()
const;
309 DLLEXPORT
int getDayOfWeek()
const;
317 DLLEXPORT
void getISOWeek(
int& year,
int& week,
int& day)
const;
359 DLLEXPORT
void format(
QoreString& str,
const char* fmt)
const;
365 DLLEXPORT
bool isRelative()
const;
371 DLLEXPORT
bool isAbsolute()
const;
377 DLLEXPORT
short getYear()
const;
383 DLLEXPORT
int getMonth()
const;
389 DLLEXPORT
int getDay()
const;
395 DLLEXPORT
int getHour()
const;
401 DLLEXPORT
int getMinute()
const;
407 DLLEXPORT
int getSecond()
const;
413 DLLEXPORT
int getMillisecond()
const;
418 DLLEXPORT
int getMicrosecond()
const;
424 DLLEXPORT
int64 getRelativeSeconds()
const;
430 DLLEXPORT
int64 getRelativeMilliseconds()
const;
436 DLLEXPORT
int64 getRelativeMicroseconds()
const;
442 DLLEXPORT
double getRelativeSecondsDouble()
const;
445 DLLEXPORT
bool hasValue()
const;
448 DLLEXPORT
DateTime* unaryMinus()
const;
451 DLLEXPORT
void unaryMinusInPlace();
454 DLLEXPORT
void getInfo(
const AbstractQoreZoneInfo* n_zone,
qore_tm &info)
const;
457 DLLEXPORT
void getInfo(
qore_tm &info)
const;
460 DLLEXPORT
void setZone(
const AbstractQoreZoneInfo* n_zone);
463 DLLEXPORT
const AbstractQoreZoneInfo* getZone()
const;
467 DLLEXPORT
static bool isLeapYear(
int year);
470 DLLEXPORT
static int getLastDayOfMonth(
int month,
int year);
484 DLLEXPORT
static int compareDates(
const DateTime* left,
const DateTime* right);
487 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);
495 DLLEXPORT
static DateTime* makeAbsolute(
const AbstractQoreZoneInfo* zone,
int64 seconds,
int us = 0);
503 DLLEXPORT
static DateTime* makeAbsoluteLocal(
const AbstractQoreZoneInfo* zone,
int64 seconds,
int us = 0);
506 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);
509 DLLEXPORT
static DateTime* makeRelativeFromSeconds(
int64 n_second,
int n_us = 0);
class qore_date_private * priv
private date data - most are ints so relative dates can hold a lot of data
Definition: DateTime.h:100
DLLEXPORT const char * regionName() const
returns the region name of the zone
Holds absolute and relative date/time values in Qore with precision to the microsecond.
Definition: DateTime.h:93
DLLEXPORT int secsEast() const
returns seconds east of UTC for zone
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:82
Qore's parse tree/value type for date-time values, reference-counted, dynamically-allocated only...
Definition: DateTimeNode.h:44
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:43
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:228
for returning broken-down time information
Definition: DateTime.h:41