10# if !defined(HPP_ALIB_LANG_BASECAMP)
13# if !defined (HPP_ALIB_LANG_BASECAMP)
16# if !defined (HPP_ALIB_STRINGS_NUMBERFORMAT)
19# if !defined (HPP_ALIB_STRINGS_FORMAT)
22# if !defined (HPP_ALIB_STRINGS_SUBSTRING)
25# if !defined(HPP_ALIB_TIME_TIME)
28# if !defined (HPP_ALIB_LANG_RESOURCES_RESOURCES)
31# if !defined (HPP_ALIB_CAMP_DIRECTORY)
34# if !defined (HPP_ALIB_CAMP_CALENDAR)
37# if !defined (HPP_ALIB_ENUMS_RECORDBOOTSTRAP)
40# if !defined(HPP_ALIB_ENUMS_SERIALIZATION)
43#if !defined(HPP_ALIB_LANG_FORMAT_FWDS)
80 #elif defined (__GLIBCXX__) || defined(__APPLE__) || defined(__ANDROID_NDK__)
91 localtime_r( &tt, &tm );
94 Year= tm.tm_year + 1900;
103 #pragma message ("Unknown Platform in file: " __FILE__ )
111 #if defined( _WIN32 )
114 st.wYear= (WORD)
Year;
117 st.wMonth= (WORD)
Month;
118 st.wHour= (WORD)
Hour;
119 st.wMinute= (WORD)
Minute;
120 st.wSecond= (WORD)
Second;
125 #elif defined (__GLIBCXX__) || defined(__APPLE__) || defined(__ANDROID_NDK__)
127 tm.tm_year=
Year - 1900;
150 #pragma message ("Unknown Platform in file: " __FILE__ )
171#define NanosPerDay INT64_C( 86400000000000 )
172#define NanosPerHour INT64_C( 3600000000000 )
173#define NanosPerMinute INT64_C( 60000000000 )
174#define NanosPerSecond INT64_C( 1000000000 )
175#define NanosPerMillisecond INT64_C( 1000000 )
176#define NanosPerMicrosecond INT64_C( 1000 )
182 decltype(nanos) fract;
183 if ( nanos > NanosPerDay ) {
Days=
static_cast<int>( fract= nanos / NanosPerDay ); nanos-= fract * NanosPerDay; }
184 if ( nanos > NanosPerHour ) {
Hours=
static_cast<int>( fract= nanos / NanosPerHour ); nanos-= fract * NanosPerHour; }
185 if ( nanos > NanosPerMinute ) {
Minutes=
static_cast<int>( fract= nanos / NanosPerMinute ); nanos-= fract * NanosPerMinute; }
186 if ( nanos > NanosPerSecond ) {
Seconds=
static_cast<int>( fract= nanos / NanosPerSecond ); nanos-= fract * NanosPerSecond; }
187 if ( nanos > NanosPerMillisecond ) {
Milliseconds=
static_cast<int>( fract= nanos / NanosPerMillisecond ); nanos-= fract * NanosPerMillisecond; }
188 if ( nanos > NanosPerMicrosecond ) {
Microseconds=
static_cast<int>( fract= nanos / NanosPerMicrosecond ); }
193 return Days * NanosPerDay
194 +
Hours * NanosPerHour
209 | uint32_t( cdt.
Month ) << 8
210 | uint32_t( cdt.
Day ) << 3
215 ALIB_ASSERT_ERROR( year >= 0 && year <= 1048575,
"CAMP",
"CalendarDate: Years must be between 0 and 1,048,575." )
216 ALIB_ASSERT_ERROR( month >= 1 && month <= 12 ,
"CAMP",
"CalendarDate: Months must be between 1 and 12." )
217 ALIB_ASSERT_ERROR( day >= 1 && day <= 31 ,
"CAMP",
"CalendarDate: Days must be between 1 and 31." )
218 ALIB_ASSERT_ERROR( dayOfWeek <= 6 ,
"CAMP",
"CalendarDate: Day of week must be either negative or between 0 and 6." )
232 "Day of week does not correspond to given date. Should be: ", cdt.
DayOfWeek )
235 stamp= uint32_t( year ) << 12
236 | uint32_t( month ) << 8
237 | uint32_t( day ) << 3
238 | uint32_t( dayOfWeek ) ;
250 + DateTime::Duration::FromAbsoluteDays( daysToAdd ),
261 if( ( month != 2 && day != 30 )
262 || ( month == 2 && day != 28 ) )
265 && ( day != 29 || month != 2 ) )
294 stamp= (
stamp & ~lang::LowerMask<8, uint32_t>() )
295 | ( uint32_t( day-1 ) << 3 )
296 | ( ( (
stamp & 7) + 6 ) % 7 ) ;
ALIB_API void Set(const DateTime &timeStamp, lang::Timezone timezone=lang::Timezone::Local)
ALIB_API DateTime Get(lang::Timezone timezone=lang::Timezone::Local) const
ALIB_API CalendarDate operator--()
ALIB_API CalendarDate operator+(int daysToAdd) const
ALIB_API DateTime Get(lang::Timezone timezone=lang::Timezone::Local, int hour=12, int minute=0, int second=0) const
uint32_t stamp
Encoded date value.
ALIB_API CalendarDate operator++()
ALIB_API void Set(int year, int month, int day, int dayOfWeek=-1)
ALIB_API int64_t ToNanoSeconds()
ALIB_API void FromNanoSeconds(int64_t nanos)
static DateTime FromEpochSeconds(time_t epochSeconds)
time_t InEpochSeconds() const
static ALIB_API DateTime FromSystemTime(const SYSTEMTIME &systemTime, lang::Timezone timezone=lang::Timezone::Local)
ALIB_API SYSTEMTIME ToSystemTime(lang::Timezone timezone=lang::Timezone::Local) const
#define ALIB_ASSERT_ERROR(cond,...)
@ UTC
Denotes UTC (coordinated universal time).
@ Get
Denotes to search data.
lang::system::CalendarDateTime CalendarDateTime
Type alias in namespace alib.