9DOX_MARKER( [CDT_MONTH_NAMES])
16DOX_MARKER( [CDT_MONTH_NAMES])
24DOX_MARKER( [CDT_DAY_NAMES])
29DOX_MARKER( [CDT_DAY_NAMES])
63 #elif defined (__GLIBCXX__) || defined(_LIBCPP_VERSION) || defined(__APPLE__) || defined(__ANDROID_NDK__)
71 localtime_r( &tt, &tm );
74 Year= tm.tm_year + 1900;
83 #pragma message ("Unknown Platform in file: " __FILE__ )
93 st.wYear= (WORD)
Year;
96 st.wMonth= (WORD)
Month;
97 st.wHour= (WORD)
Hour;
104 #elif defined (__GLIBCXX__) || defined(_LIBCPP_VERSION) || defined(__APPLE__) || defined(__ANDROID_NDK__)
106 tm.tm_year=
Year - 1900;
126 #pragma message ("Unknown Platform in file: " __FILE__ )
146#define NanosPerDay INT64_C( 86400000000000 )
147#define NanosPerHour INT64_C( 3600000000000 )
148#define NanosPerMinute INT64_C( 60000000000 )
149#define NanosPerSecond INT64_C( 1000000000 )
150#define NanosPerMillisecond INT64_C( 1000000 )
151#define NanosPerMicrosecond INT64_C( 1000 )
156 decltype(nanos) fract;
157 if ( nanos > NanosPerDay ) {
Days= int( fract= nanos / NanosPerDay ); nanos-= fract * NanosPerDay; }
158 if ( nanos > NanosPerHour ) {
Hours= int( fract= nanos / NanosPerHour ); nanos-= fract * NanosPerHour; }
159 if ( nanos > NanosPerMinute ) {
Minutes= int( fract= nanos / NanosPerMinute ); nanos-= fract * NanosPerMinute; }
160 if ( nanos > NanosPerSecond ) {
Seconds= int( fract= nanos / NanosPerSecond ); nanos-= fract * NanosPerSecond; }
161 if ( nanos > NanosPerMillisecond ) {
Milliseconds= int( fract= nanos / NanosPerMillisecond ); nanos-= fract * NanosPerMillisecond; }
162 if ( nanos > NanosPerMicrosecond ) {
Microseconds= int( fract= nanos / NanosPerMicrosecond ); }
166 return Days * NanosPerDay
167 +
Hours * NanosPerHour
181 | uint32_t( cdt.
Month ) << 8
182 | uint32_t( cdt.
Day ) << 3
186 ALIB_ASSERT_ERROR( year >= 0 && year <= 1048575,
"CAMP",
"CalendarDate: Years must be between 0 and 1,048,575. Given: ", year )
187 ALIB_ASSERT_ERROR( month >= 1 && month <= 12 ,
"CAMP",
"CalendarDate: Months must be between 1 and 12. Given: ", month )
188 ALIB_ASSERT_ERROR( day >= 1 && day <= 31 ,
"CAMP",
"CalendarDate: Days must be between 1 and 31. Given: ", day )
189 ALIB_ASSERT_ERROR( dayOfWeek <= 6 ,
"CAMP",
"CalendarDate: Day of week must be either negative or between 0 and 6. Given: ", dayOfWeek)
201 "Given day of week {} does not correspond to given date. Should be: ",
205 stamp= uint32_t( year ) << 12
206 | uint32_t( month ) << 8
207 | uint32_t( day ) << 3
208 | uint32_t( dayOfWeek ) ;
217 + DateTime::Duration::FromAbsoluteDays( daysToAdd ),
227 if( ( month != 2 && day != 30 )
228 || ( month == 2 && day != 28 ) )
231 && ( day != 29 || month != 2 ) )
236 if( ++month == 13 ) {
255 | ( uint32_t( day-1 ) << 3 )
256 | ( ( (
stamp & 7) + 6 ) % 7 ) ;
276 while (
format.IsNotEmpty() ) {
280 while (
format.ConsumeChar(c) )
298 ALIB_WARNING(
"ALIB",
"Format Error: Missing single Quote" )
299 target <<
"Format Error: Missing closing single quote character <'>" ;
319 target.
_<
NC>(
Hour < 12 ?
" am" :
" pm" );
#define ALIB_WARNING(domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
TAString & InsertChars(TChar c, integer qty)
TAString & _(const TAppendable &src)
static String MONTH_NAMES[12]
static String DAY_NAMES[7]
int Minute
The calendar minute (0..59).
void Set(const DateTime &timeStamp, lang::Timezone timezone=lang::Timezone::Local)
int Second
The calendar second (0..59).
int Day
The calendar day (1..31).
AString & Format(Substring format, AString &target, lang::CurrentData targetData=lang::CurrentData::Keep) const
int Hour
The calendar hour (0..23).
int Year
The calendar year (e.g., 2022).
DateTime Get(lang::Timezone timezone=lang::Timezone::Local) const
void Clear()
Sets all public values to 0.
int Month
The calendar month (1..12).
int Millisecond
The calendar millisecond (0..999).
CalendarDate()=default
Default constructor leaving this object uninitialized (random value).
void Set(int year, int month, int day, int dayOfWeek=-1)
CalendarDate operator++()
uint32_t stamp
Encoded date value.
DateTime Get(lang::Timezone timezone=lang::Timezone::Local, int hour=12, int minute=0, int second=0) const
CalendarDate operator+(int daysToAdd) const
CalendarDate operator--()
int Seconds
The number of seconds (not the total, hence 0-59) within the duration.
void FromNanoSeconds(int64_t nanos)
int Hours
The number of hours (not the total, hence 0-23) within the duration.
int Nanoseconds
The number of nanoseconds (not the total, hence 0-999) within the duration.
int Minutes
The number of minutes (not the total, hence 0-59) within the duration.
int Milliseconds
The number of milliseconds (not the total, hence 0-999) within the duration.
void Clear()
Sets all public values to 0.
int Microseconds
The number of microseconds (not the total, hence 0-999) within the duration.
int Days
The number of days within the duration.
static DateTime FromSystemTime(const SYSTEMTIME &systemTime, lang::Timezone timezone=lang::Timezone::Local)
time_t InEpochSeconds() const
SYSTEMTIME ToSystemTime(lang::Timezone timezone=lang::Timezone::Local) const
static DateTime FromEpochSeconds(time_t epochSeconds)
@ Clear
Chooses to clear existing data.
Timezone
Denotes whether a time value represents local time or UTC.
@ UTC
Denotes UTC (coordinated universal time).
strings::TNumberFormat< character > NumberFormat
Type alias in namespace #"%alib".
lang::integer integer
Type alias in namespace #"%alib".
strings::TString< character > String
Type alias in namespace #"%alib".
strings::TDec< character > Dec
Type alias in namespace #"%alib".
strings::TSubstring< character > Substring
Type alias in namespace #"%alib".
strings::util::CalendarDateTime CalendarDateTime
Type alias in namespace #"%alib".
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
characters::character character
Type alias in namespace #"%alib".
time::DateTime DateTime
Type alias in namespace #"%alib".