9#ifndef HPP_ALIB_LANG_SYSTEM_CALENDAR
10#define HPP_ALIB_LANG_SYSTEM_CALENDAR 1
16#include "alib/time/ticks.hpp"
21namespace alib {
namespace lang::system {
96 Set( timeStamp, timezone );
110 int hour= 0,
int minute= 0,
int second= 0,
int millisecond= 0 )
300 return DateTime::Duration::FromNanoseconds(
ToNanoSeconds() );
404 Set( year, month, day, dayOfWeek );
425 ,calendarDateTime.
Month
426 ,calendarDateTime.
Day
437 Set( dateTime, timezone);
454 void Set(
int year,
int month,
int day,
int dayOfWeek= -1);
483 int hour= 12,
int minute= 0,
int second= 0 )
const;
503 int Day()
const {
return int( (
stamp >> 3) & 31 ); }
528 return (*
this) + (-daysToSubtract);
574 return (*
this)= (*this) + daysToAdd;
584 return (*
this)+= (- daysToSubtract);
677namespace APPENDABLES {
681template<
typename TChar,
typename TAllocator>
struct T_Append<time::DateTime::Duration ,TChar,TAllocator>
700template<
typename TChar,
typename TAllocator>
struct T_Append<time::Ticks::Duration ,TChar,TAllocator>
int Minute
The calendar minute (0..59).
int Year
The calendar year (e.g., 2022).
int Month
The calendar month (1..12).
CalendarDateTime(Initialization init=Initialization::Default)
ALIB_API void Set(const DateTime &timeStamp, lang::Timezone timezone=lang::Timezone::Local)
CalendarDateTime(const DateTime &timeStamp, lang::Timezone timezone=lang::Timezone::Local)
int Day
The calendar day (1..31).
int Hour
The calendar hour (0..23).
ALIB_API void Clear()
Sets all public values to 0.
CalendarDateTime(int year, int month=1, int day=1, int hour=0, int minute=0, int second=0, int millisecond=0)
int Millisecond
The calendar millisecond (0..999).
int Second
The calendar second (0..59).
bool operator<=(const CalendarDate &other) const
CalendarDate operator-=(int daysToSubtract)
bool operator==(const CalendarDate &other) const
CalendarDate operator-(int daysToSubtract) const
bool operator!=(const CalendarDate &other) const
ALIB_API CalendarDate operator--()
ALIB_API CalendarDate operator+(int daysToAdd) const
ALIB_API CalendarDate(const CalendarDateTime &calendarDateTime)
bool operator>(const CalendarDate &other) const
CalendarDate operator+=(int daysToAdd)
CalendarDate operator--(int)
CalendarDate()=default
Default constructor leaving this object uninitialized (random value). **************.
bool operator>=(const CalendarDate &other) const
bool operator<(const CalendarDate &other) const
CalendarDate(CalendarDate &&) noexcept=default
Trivial default move constructor. ***************************************************.
uint32_t stamp
Encoded date value.
CalendarDate(lang::Timezone timezone)
CalendarDate operator++(int)
ALIB_API CalendarDate operator++()
CalendarDate(const DateTime &dateTime, lang::Timezone timezone)
ALIB_API void Set(int year, int month, int day, int dayOfWeek=-1)
CalendarDate(const CalendarDate &) noexcept=default
Trivial default copy constructor. ***************************************************.
ALIB_API CalendarDateTime ToCalendarDateTime() const
int Nanoseconds
The number of nanoseconds (not the total, hence 0-999) within the duration.
CalendarDuration(lang::Initialization init=Initialization::Default)
CalendarDuration(DateTime::Duration duration)
ALIB_API int64_t ToNanoSeconds()
int Milliseconds
The number of milliseconds (not the total, hence 0-999) within the duration.
int Seconds
The number of seconds (not the total, hence 0-59) within the duration.
CalendarDuration(int64_t nanos)
int Microseconds
The number of microseconds (not the total, hence 0-999) within the duration.
int Days
The number of days within the duration.
DateTime::Duration ToDateTimeDuration()
void FromDuration(Ticks::Duration duration)
int Hours
The number of hours (not the total, hence 0-23) within the duration.
ALIB_API void FromNanoSeconds(int64_t nanos)
int Minutes
The number of minutes (not the total, hence 0-59) within the duration.
ALIB_API void Clear()
Sets all public values to 0.
Ticks::Duration ToTicksDuration()
CalendarDuration(Ticks::Duration duration)
void FromDuration(DateTime::Duration duration)
#define ALIB_ASSERT_MODULE(modulename)
ALIB_API void FFormat_DateTime(const Box &self, const String &formatSpec, NumberFormat &nf, AString &target)
Initialization
Used for example with constructors that allow to suppress initialization of members.
Timezone
Denotes whether a time value represents local time or UTC.
@ Local
Denotes local time.
@ Keep
Chooses not no clear existing data.
@ Get
Denotes to search data.
strings::TFormat< character > Format
Type alias in namespace alib.
time::DateTime DateTime
Type alias in namespace alib.
ALIB_API void operator()(TAString< TChar, TAllocator > &target, const time::DateTime::Duration duration)
void operator()(TAString< TChar, TAllocator > &target, const time::Ticks::Duration duration)
void operator()(TAString< TChar > &target, const TAppendable &src)