8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
34DOX_MARKER( [CDT_MONTH_NAMES])
41DOX_MARKER( [CDT_MONTH_NAMES])
49DOX_MARKER( [CDT_DAY_NAMES])
54DOX_MARKER( [CDT_DAY_NAMES])
90 #elif defined (__GLIBCXX__) || defined(_LIBCPP_VERSION) || defined(__APPLE__) || defined(__ANDROID_NDK__)
101 localtime_r( &tt, &tm );
104 Year= tm.tm_year + 1900;
107 Month= tm.tm_mon + 1;
113 #pragma message ("Unknown Platform in file: " __FILE__ )
121 #if defined( _WIN32 )
124 st.wYear= (WORD)
Year;
127 st.wMonth= (WORD)
Month;
128 st.wHour= (WORD)
Hour;
129 st.wMinute= (WORD)
Minute;
130 st.wSecond= (WORD)
Second;
135 #elif defined (__GLIBCXX__) || defined(_LIBCPP_VERSION) || defined(__APPLE__) || defined(__ANDROID_NDK__)
137 tm.tm_year=
Year - 1900;
160 #pragma message ("Unknown Platform in file: " __FILE__ )
181#define NanosPerDay INT64_C( 86400000000000 )
182#define NanosPerHour INT64_C( 3600000000000 )
183#define NanosPerMinute INT64_C( 60000000000 )
184#define NanosPerSecond INT64_C( 1000000000 )
185#define NanosPerMillisecond INT64_C( 1000000 )
186#define NanosPerMicrosecond INT64_C( 1000 )
192 decltype(nanos) fract;
193 if ( nanos > NanosPerDay ) {
Days= int( fract= nanos / NanosPerDay ); nanos-= fract * NanosPerDay; }
194 if ( nanos > NanosPerHour ) {
Hours= int( fract= nanos / NanosPerHour ); nanos-= fract * NanosPerHour; }
195 if ( nanos > NanosPerMinute ) {
Minutes= int( fract= nanos / NanosPerMinute ); nanos-= fract * NanosPerMinute; }
196 if ( nanos > NanosPerSecond ) {
Seconds= int( fract= nanos / NanosPerSecond ); nanos-= fract * NanosPerSecond; }
197 if ( nanos > NanosPerMillisecond ) {
Milliseconds= int( fract= nanos / NanosPerMillisecond ); nanos-= fract * NanosPerMillisecond; }
198 if ( nanos > NanosPerMicrosecond ) {
Microseconds= int( fract= nanos / NanosPerMicrosecond ); }
203 return Days * NanosPerDay
204 +
Hours * NanosPerHour
219 | uint32_t( cdt.
Month ) << 8
220 | uint32_t( cdt.
Day ) << 3
225 ALIB_ASSERT_ERROR( year >= 0 && year <= 1048575,
"CAMP",
"CalendarDate: Years must be between 0 and 1,048,575. Given: ", year )
226 ALIB_ASSERT_ERROR( month >= 1 && month <= 12 ,
"CAMP",
"CalendarDate: Months must be between 1 and 12. Given: ", month )
227 ALIB_ASSERT_ERROR( day >= 1 && day <= 31 ,
"CAMP",
"CalendarDate: Days must be between 1 and 31. Given: ", day )
228 ALIB_ASSERT_ERROR( dayOfWeek <= 6 ,
"CAMP",
"CalendarDate: Day of week must be either negative or between 0 and 6. Given: ", dayOfWeek)
242 "Given day of week {} does not correspond to given date. Should be: ",
246 stamp= uint32_t( year ) << 12
247 | uint32_t( month ) << 8
248 | uint32_t( day ) << 3
249 | uint32_t( dayOfWeek ) ;
261 + DateTime::Duration::FromAbsoluteDays( daysToAdd ),
272 if( ( month != 2 && day != 30 )
273 || ( month == 2 && day != 28 ) )
276 && ( day != 29 || month != 2 ) )
306 | ( uint32_t( day-1 ) << 3 )
307 | ( ( (
stamp & 7) + 6 ) % 7 ) ;
328 while (
format.IsNotEmpty() )
333 while (
format.ConsumeChar(c) )
355 ALIB_WARNING(
"ALIB",
"Format Error: Missing single Quote" )
356 target <<
"Format Error: Missing closing single quote character <'>" ;
376 target.
_<
NC>(
Hour < 12 ?
" am" :
" pm" );
TAString & InsertChars(TChar c, integer qty)
TAString & _(const TAppendable &src)
int Minute
The calendar minute (0..59).
ALIB_DLL 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).
ALIB_DLL AString & Format(Substring format, AString &target, lang::CurrentData targetData=lang::CurrentData::Keep) const
int Hour
The calendar hour (0..23).
static ALIB_DLL String MONTH_NAMES[12]
int Year
The calendar year (e.g., 2022).
ALIB_DLL DateTime Get(lang::Timezone timezone=lang::Timezone::Local) const
ALIB_DLL void Clear()
Sets all public values to 0.
static ALIB_DLL String DAY_NAMES[7]
int Month
The calendar month (1..12).
int Millisecond
The calendar millisecond (0..999).
CalendarDate()=default
Default constructor leaving this object uninitialized (random value). **************.
ALIB_DLL void Set(int year, int month, int day, int dayOfWeek=-1)
ALIB_DLL CalendarDate operator++()
uint32_t stamp
Encoded date value.
ALIB_DLL DateTime Get(lang::Timezone timezone=lang::Timezone::Local, int hour=12, int minute=0, int second=0) const
ALIB_DLL CalendarDate operator+(int daysToAdd) const
ALIB_DLL CalendarDate operator--()
int Seconds
The number of seconds (not the total, hence 0-59) within the duration.
ALIB_DLL 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.
ALIB_DLL 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.
ALIB_DLL int64_t ToNanoSeconds()
time_t InEpochSeconds() const
static ALIB_DLL DateTime FromSystemTime(const SYSTEMTIME &systemTime, lang::Timezone timezone=lang::Timezone::Local)
ALIB_DLL SYSTEMTIME ToSystemTime(lang::Timezone timezone=lang::Timezone::Local) const
static DateTime FromEpochSeconds(time_t epochSeconds)
#define ALIB_WARNING(domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
@ Clear
Chooses to clear existing data.
Timezone
Denotes whether a time value represents local time or UTC.
@ UTC
Denotes UTC (coordinated universal time).
strings::TDec< character > Dec
Type alias in namespace alib.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
time::DateTime DateTime
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
strings::TNumberFormat< character > NumberFormat
Type alias in namespace alib.
strings::util::CalendarDateTime CalendarDateTime
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.