ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
calendar.inl
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of sub-namespace #alib::strings::util of module \alib_strings of
4/// the \aliblong.
5///
6/// \emoji :copyright: 2013-2025 A-Worx GmbH, Germany.
7/// Published under \ref mainpage_license "Boost Software License".
8//==================================================================================================
9ALIB_EXPORT namespace alib { namespace strings::util {
10
11//==================================================================================================
12/// This class represents a point in time as a set of calendar and clock values
13/// (year, month, day, hour, ...).
14/// It provides methods to convert to and from objects of type \alib{time;DateTime}.
15/// In addition, a method to format the date and time into human-readable string value is available.
16///
17/// \note
18/// The conversion from and into objects of type \alib{time;Ticks} is intentionally not supported.
19/// In the case that such objects should be used with this class, an additional conversion
20/// step has to be performed using class \alib{time;TickConverter}. In other words, conversion can
21/// be performed as follows:
22///
23/// CalendarDateTime <=> DateTime <=> Ticks
24/// <p>
25/// \note
26/// This class is using system-specific calendar methods and relies on the locale and time zone
27/// settings of the machine.
28//==================================================================================================
30{
31 public:
32 /// A list of month names used with the method
33 /// \alib{strings::util;CalendarDateTime::Format}.
34 ///
35 /// If module \alib_camp is not included in the \alibbuild, the values default to:
36 /// \snippet "strings/util/calendar.cpp" CDT_MONTH_NAMES
37 /// In case the module is included, the same values are resourced in #alib::BASECAMP under
38 /// key <c>"Months"</c>. In both cases a user might change this during bootstrap.
40
41 /// A list of day names used with the method \alib{strings::util;CalendarDateTime::Format}.
42 ///
43 /// If module \alib_camp is not included in the \alibbuild, the values default to:
44 /// \snippet "strings/util/calendar.cpp" CDT_DAY_NAMES
45 /// In case the module is included, the same values are resourced in #alib::BASECAMP under
46 /// key <c>"Days"</c>. In both cases a user might change this during bootstrap.
48
49 /// The calendar year (e.g., 2022).
50 int Year;
51
52 /// The calendar month (1..12).
53 int Month;
54
55 /// The calendar day (1..31).
56 int Day;
57
58 /// The calendar hour (0..23).
59 int Hour;
60
61 /// The calendar minute (0..59).
62 int Minute;
63
64 /// The calendar second (0..59).
65 int Second;
66
67 /// The calendar millisecond (0..999).
69
70 /// The calendar day of week (0==Sunday..6==Saturday).
71 /// \attention This value is only set when constructed with a \b DateTime object and
72 /// set to \c -1 if constructed with single values, or if method #Clear is
73 /// invoked.
75 //==============================================================================================
76 /// Constructs an unset object.
77 /// @param init If \b Initialization::Default or \b nulled, #Clear is invoked.
78 /// Otherwise fields are not initialized.
79 /// Defaults to \c Initialization::Default.
80 //==============================================================================================
86
87 //==============================================================================================
88 /// Constructs the object according to the given timestamp object and time zone.
89 /// @param timeStamp The point in time to use for setting the public fields
90 /// @param timezone Denotes if the time that is calculated should be local or UTC.
91 /// Defaults to \c TimeZone::Local.
92 //==============================================================================================
94 {
95 Set( timeStamp, timezone );
96 }
97
98 //==============================================================================================
99 /// Constructs the object according to the given date and time values.
100 /// @param year The year of the calendar time.
101 /// @param month The month of the calendar time.
102 /// @param day The day of the calendar time.
103 /// @param hour The hour of the calendar time.
104 /// @param minute The minute of the calendar time.
105 /// @param second The second of the calendar time.
106 /// @param millisecond The millisecond of the calendar time.
107 //==============================================================================================
108 CalendarDateTime( int year , int month= 1 , int day= 1,
109 int hour= 0, int minute= 0, int second= 0, int millisecond= 0 )
110 : Year ( year )
111 , Month ( month )
112 , Day ( day )
113 , Hour ( hour )
114 , Minute ( minute )
115 , Second ( second )
116 , Millisecond ( millisecond)
117 , DayOfWeek ( -1 )
118 {}
119
120 //==============================================================================================
121 /// Sets the public fields according to the given timestamp object.
122 /// @param timeStamp The point in time to use for setting the public fields
123 /// @param timezone Denotes if the time that is calculated should be local or UTC.
124 /// Defaults to \c TimeZone::Local.
125 //==============================================================================================
127 void Set( const DateTime& timeStamp, lang::Timezone timezone =lang::Timezone::Local );
128
129 //==============================================================================================
130 /// Creates a \b DateTime object from this calendar date.
131 /// \attention
132 /// The resolution and possible time range of class \b %DateTime is platform-dependent.
133 /// This method must not be used if inconsistent values are stored.
134 ///
135 /// @param timezone Denote if the time that is calculated should be local or UTC.
136 /// Defaults to \c TimeZone::Local.
137 /// @returns The point in time represented by the public fields of this class.
138 //==============================================================================================
141
142 //==============================================================================================
143 /// Sets all public values to \c 0.
144 //==============================================================================================
146 void Clear();
147
148 //==============================================================================================
149 /// Formats the date using a given pattern string. Within the pattern string, different symbols
150 /// are interpreted as tokens. The format is compatible with C# time format strings, as well as
151 /// with class SimpleDateFormat of the Java APIs.<br>
152 /// Strings within the format text that should not be interpreted as tokens may be surrounded
153 /// by single quotes.
154 /// Strings within the format text that should not be interpreted as tokens may be given
155 /// in single quotes.
156 /// Two consecutive single quotes will be replaced to one single quote.<br>
157 ///
158 /// <center>Token</center> | <center>Description</center>
159 /// - - - - -| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
160 /// y |The year with as many digits as it has (for current dates this is 4).</TD> </TR>
161 /// yy |The year, truncated to 2 digits (modulo 100).</TD> </TR>
162 /// yyy...y |The year with a minimum amount of digits as amount of y-characters given.</TD> </TR>
163 /// M |The month as numbers from 1..12.</TD> </TR>
164 /// MM |The month as numbers from 01..12.</TD> </TR>
165 /// MMM |The month as abbreviated, 3-digit word defined by resourced strings (defaults to English language).</TD> </TR>
166 /// MMMM |The month as word defined by resourced strings (defaults to English language).</TD> </TR>
167 /// d |The day as numbers from 1..31.</TD> </TR>
168 /// dd |The day as numbers from 01..31.</TD> </TR>
169 /// ddd |The day as abbreviated, 3-digit word defined by resourced strings (defaults to English language).</TD> </TR>
170 /// dddd |The day as word defined by resourced strings (defaults to English language).</TD> </TR>
171 /// H |The hour as numbers from 0..23.</TD> </TR>
172 /// HH |The hour as numbers from 00..23.</TD> </TR>
173 /// K |The hour as numbers from 0..11 am/pm.</TD> </TR>
174 /// KK |The hour as numbers from 00..11 am/pm.</TD> </TR>
175 /// m |The minute as numbers from 0..59.</TD> </TR>
176 /// mm |The minute as numbers from 00..59.</TD> </TR>
177 /// s |The second as numbers from 0..59.</TD> </TR>
178 /// ss |The second as numbers from 00..59.</TD> </TR>
179 ///
180 /// @param format The format pattern string.
181 /// @param target A reference to an AString that gets the result of the format processing
182 /// appended.
183 /// @param targetData If \c CurrentData::Keep (the default) the string is appended to \p{target}.
184 /// if \c CurrentData::Clear, \p{target} is cleared.
185 /// @returns \p{target} (for convenience).
186 //==============================================================================================
190};
191
192//==================================================================================================
193/// This class represents a time span, measured in human units like days, hours, minutes and so on.
194/// Besides conversion from and to nanoseconds, conversions from and to objects of types
195/// \alib{time;TimePointBase::Duration;DateTime::Duration} and
196/// \alib{time;TimePointBase::Duration;Ticks::Duration} is supported.
197//==================================================================================================
199{
200 public:
201 /// The number of days within the duration
202 int Days;
203
204 /// The number of hours (not the total, hence 0-23) within the duration.
205 int Hours;
206
207 /// The number of minutes (not the total, hence 0-59) within the duration.
209
210 /// The number of seconds (not the total, hence 0-59) within the duration.
212
213 /// The number of milliseconds (not the total, hence 0-999) within the duration.
215
216 /// The number of microseconds (not the total, hence 0-999) within the duration.
218
219 /// The number of nanoseconds (not the total, hence 0-999) within the duration.
221
222 //==============================================================================================
223 /// Constructs the object to represent a duration of 0. (Sets all public fields to 0.)
224 /// @param init If \b Initialization::Default or \b Nulled, #Clear is invoked.
225 /// Otherwise fields are not initialized.
226 /// Defaults to \b Initialization::Default.
227 //==============================================================================================
233
234 //==============================================================================================
235 /// Constructs the object using the given duration measured in nanoseconds.
236 /// Invokes #FromNanoSeconds.
237 /// @param nanos The duration to use for setting the public fields.
238 //==============================================================================================
239 CalendarDuration( int64_t nanos )
240 {
241 FromNanoSeconds( nanos );
242 }
243
244 //==============================================================================================
245 /// Constructs the object using the given duration object.
246 /// Invokes #FromDuration.
247 /// @param duration The duration to use for setting the public fields.
248 //==============================================================================================
249 CalendarDuration( DateTime::Duration duration )
250 {
251 FromDuration( duration );
252 }
253
254 //==============================================================================================
255 /// Constructs the object using the given duration object.
256 /// Invokes #FromDuration.
257 /// @param duration The duration to use for setting the public fields.
258 //==============================================================================================
259 CalendarDuration( Ticks::Duration duration )
260 {
261 FromDuration( duration );
262 }
263
264 //==============================================================================================
265 /// Sets the public fields to represent the given duration value.
266 /// The state of the object will hereafter be the same as it was when constructed with the same
267 /// parameter.
268 /// @param duration The duration to use for setting the public fields.
269 //==============================================================================================
270 void FromDuration( DateTime::Duration duration )
271 {
272 FromNanoSeconds( duration.InNanoseconds() );
273 }
274
275 //==============================================================================================
276 /// Sets the public fields to represent the given duration value.
277 /// The state of the object will hereafter be the same as it was when constructed with the same
278 /// parameter.
279 /// @param duration The duration to use for setting the public fields.
280 //==============================================================================================
281 void FromDuration( Ticks::Duration duration )
282 {
283 FromNanoSeconds( duration.InNanoseconds() );
284 }
285
286 //==============================================================================================
287 /// Takes the current values of the public fields and returns a duration value compatible with
288 /// class \b %DateTime.
289 /// @returns The duration represented by the public fields of this class.
290 //==============================================================================================
291 DateTime::Duration ToDateTimeDuration()
292 {
293 return DateTime::Duration::FromNanoseconds( ToNanoSeconds() );
294 }
295
296 //==============================================================================================
297 /// Takes the current values of the public fields and returns a duration value compatible with
298 /// class \b %Ticks.
299 /// @returns The duration represented by the public fields of this class.
300 //==============================================================================================
301 Ticks::Duration ToTicksDuration()
302 {
303 return Ticks::Duration::FromNanoseconds( ToNanoSeconds() );
304 }
305
306 //==============================================================================================
307 /// Sets the public fields to represent the given duration value.
308 /// The state of the object will hereafter be the same as it was when constructed with the same
309 /// parameter.
310 /// @param nanos The duration to use for setting the public fields.
311 //==============================================================================================
312 ALIB_DLL void FromNanoSeconds( int64_t nanos );
313
314 //==============================================================================================
315 /// Takes the current values of the public fields and returns the duration.
316 /// @returns The duration represented by the public fields of this class in nanoseconds.
317 //==============================================================================================
318 ALIB_DLL int64_t ToNanoSeconds();
319 //==============================================================================================
320 /// Sets all public values to 0.
321 //==============================================================================================
322 ALIB_DLL void Clear();
323};
324
325
326
327//==================================================================================================
328/// Represents a date in the systems calendar without the provision of a clock time.
329/// This class internally uses types \alib{time;DateTime} and \alib{strings::util;CalendarDateTime} to
330/// perform operators <c>+</c>, <c>-</c>, <c>+=</c> and <c>-=</c>, but is much more efficient with
331/// in- and decrement operators <c>++</c> and <c>--</c>. Furthermore it uses only 32-bits of storage.
332///
333/// Besides storing clock-time agnostic date values, the type is useful to securely iterate over
334/// dates, because there is no risk of false comparisons due to mixed time-zone and daylight
335/// saving properties and in general due to arbitrarily set clock times.
336///
337/// Another small difference is that field \alib{strings::util::CalendarDate;DayOfWeek} is always kept in a
338/// reliable (correct) state, which is not the case with field
339/// \alib{strings::util;CalendarDateTime::DayOfWeek}.
340///
341/// Internally, the values are stored a 32-bit storage word using the following scheme
342/// - bits 1-3 encode the day of week (from 0 (= Sunday) to 6 (= Saturday)
343/// - bits 4-8 encode the calendar day (1..31)
344/// - bits 9-12 encode the calendar month (1..12)
345/// - bits 13-32 encode the calendar year
346/// consequently, for the calendar year 20 bits are available, which evaluates to a range of
347/// \b 1,048,576 years.
348/// For simplicity and speed, the values are \b not defined in accordance to class
349/// \alib{strings::util;CalendarDateTime}, where a value of \c 0 represents year \b 1900.
350/// This class just stores the year value as is and does not allow negative values.
351/// As a result, this class is capable of storing values between <b>1/1/0000</b> and
352/// <b>12/31/1,048,576</b>.
353//==================================================================================================
355{
356 protected:
357 uint32_t stamp; ///< Encoded date value.
358
359 // #############################################################################################
360 // Conversion to time platform/language specific values
361 // #############################################################################################
362 public:
363 /// Default constructor leaving this object uninitialized (random value). **************
364 CalendarDate() = default;
365
366 /// Trivial default copy constructor. ***************************************************
367 CalendarDate( const CalendarDate& ) noexcept = default;
368
369 /// Trivial default move constructor. ***************************************************
370 CalendarDate( CalendarDate&& ) noexcept = default;
371
372 /// Trivial default copy assign operator.
373 /// @return A reference to \c this. ***************************************************
374 CalendarDate& operator=( const CalendarDate& ) noexcept = default;
375
376 /// Trivial default move assign operator.
377 /// @return A reference to \c this. ***************************************************
378 CalendarDate& operator=( CalendarDate&& ) noexcept = default;
379
380 /// Trivial default destructor. ***************************************************
381 ~CalendarDate() noexcept = default;
382
383 //==========================================================================================
384 /// Constructor taking the date as separated values.
385 /// @param year The year to use. Must be between 0 and 1,048,575
386 /// @param month The month to use. Must be between 1 and 12
387 /// @param day The day to use. Must be between 1 and 31
388 /// @param dayOfWeek The day of week that results from the previous values.
389 /// Defaults to \c -1 which instructs this constructor to retrieve that
390 /// correct value.<br>
391 /// If given, values must be between 0 (Sunday) and 6 (Saturday).
392 /// In debug compilations an assertion will be raised if the
393 /// value is out of range or inconsistent.
394 //==========================================================================================
395 CalendarDate(int year, int month, int day, int dayOfWeek= -1)
396 {
397 Set( year, month, day, dayOfWeek );
398 }
399
400 //==========================================================================================
401 /// Constructor creating a date that represents "today".
402 /// @param timezone Determines whether the local time zone should be used or UTC.
403 //==========================================================================================
404 explicit
406 {
408 }
409
410 //==========================================================================================
411 /// Constructor taking a \b DateTime value.
412 /// @param calendarDateTime The value to take the date from.
413 //==========================================================================================
414 ALIB_DLL explicit
415 CalendarDate( const CalendarDateTime& calendarDateTime )
416 {
417 Set( calendarDateTime.Year
418 ,calendarDateTime.Month
419 ,calendarDateTime.Day
420 ,calendarDateTime.DayOfWeek );
421 }
422
423 //==========================================================================================
424 /// Constructor taking a \b DateTime value.
425 /// @param dateTime The value to take the date from.
426 /// @param timezone Determines whether the local time zone should be used or UTC.
427 //==========================================================================================
428 CalendarDate( const DateTime& dateTime, lang::Timezone timezone )
429 {
430 Set( dateTime, timezone);
431 }
432
433
434 //==========================================================================================
435 /// Sets this class to the given values.
436 /// @param year The year to use. Must be between 0 and 1,048,575
437 /// @param month The month to use. Must be between 1 and 12
438 /// @param day The day to use. Must be between 1 and 31
439 /// @param dayOfWeek The day of week that results from the previous values.
440 /// Defaults to \c -1 which instructs this constructor to retrieve that
441 /// correct value.<br>
442 /// If given, values must be between 0 (Sunday) and 6 (Saturday).
443 /// In debug compilations an assertion will be raised if the
444 /// value is out of range or inconsistent.
445 //==========================================================================================
447 void Set( int year, int month, int day, int dayOfWeek= -1);
448
449 //==========================================================================================
450 /// Sets this class to the date represented by the given \b DateTime instance.
451 /// @param dateTime The value to take the date from.
452 /// @param timezone Determines whether the local time zone applies to \p dateTime or
453 /// whether it refers to UTC.
454 //==========================================================================================
456 void Set( const DateTime& dateTime, lang::Timezone timezone );
457
458 //==========================================================================================
459 /// Creates a \b DateTime object from this calendar date.
460 /// \attention
461 /// The resolution and possible time range of class \b %DateTime is platform-dependent.
462 /// This method must not be used if inconsistent values are stored.
463 ///
464 /// @param timezone Denote if the time that is calculated should be local or UTC.
465 /// Defaults to \c TimeZone::Local.
466 /// @param hour The hour of day (0..23) that the value returned should represent.
467 /// Defaults to noon time (\c 12).
468 /// @param minute The minute of the hour (0..59) that the value returned should represent.
469 /// Defaults to \c 0.
470 /// @param second The second of the minute (0..59) that the value returned should
471 /// represent. Defaults to \c 0.
472 /// @returns The point in time represented by this class and the given clock values.
473 //==========================================================================================
476 int hour= 12, int minute= 0, int second= 0 ) const;
477
478 //==========================================================================================
479 /// Returns a date and time value, by adding 12 o'clock noon time.
480 /// @return A corresponding \b DateTime value.
481 //==========================================================================================
484
485 //-------------------------- Year(), Month(), Day(), DayOfWeek() ------------------------
486 /// Extracts the day of month from this date as a value between \c 1 and \c 31.
487 /// @return The calendar day of month.
488 int Year() const { return int( stamp >> 12 ); }
489
490 /// Extracts the month from this date as a value between \c 1 and \c 12.
491 /// @return The calendar day of month.
492 int Month() const { return int( (stamp >> 8) & 15 ); }
493
494 /// Extracts the day of month from this date as a value between \c 1 and \c 31.
495 /// @return The calendar day of month.
496 int Day() const { return int( (stamp >> 3) & 31 ); }
497
498 /// Extracts the day of week from this date as a value between \c 0 (representing sunday)
499 /// and \c 6 (representing Saturday) in accordance with field
500 /// \alib{strings::util;CalendarDateTime::DayOfWeek}.
501 /// @return The calendar day of month.
502 int DayOfWeek() const { return int( stamp & 7 ); }
503
504 //--------------------------- +/- and ++/--/+=/-= operators ----------------------------
505
506 //==========================================================================================
507 /// Adds the given number of days to this date.
508 /// @param daysToAdd The days to add. May be negative for subtraction.
509 /// @return A copy of this object after modification.
510 //==========================================================================================
512 CalendarDate operator+ ( int daysToAdd ) const;
513
514 //==========================================================================================
515 /// Subtracts the given number of days to this date.
516 /// @param daysToSubtract The days to add. May be negative for additions.
517 /// @return A copy of this object after modification.
518 //==========================================================================================
519 CalendarDate operator- ( int daysToSubtract ) const
520 {
521 return (*this) + (-daysToSubtract);
522 }
523
524 //==========================================================================================
525 /// Prefix increment operator.
526 /// @return A copy of this object after modification.
527 //==========================================================================================
530
531 //==========================================================================================
532 /// Prefix decrement operator.
533 /// @return A copy of this object after modification.
534 //==========================================================================================
537
538 //==========================================================================================
539 /// Postfix increment operator.
540 /// @return A copy of this object before its modification.
541 //==========================================================================================
543 {
544 auto tmp = *this;
545 ++(*this);
546 return tmp;
547 }
548
549 //==========================================================================================
550 /// Postfix decrement operator.
551 /// @return A copy of this object before its modification.
552 //==========================================================================================
554 {
555 auto tmp = *this;
556 --(*this);
557 return tmp;
558 }
559
560 //==========================================================================================
561 /// Adds the given number of days to this date.
562 /// @param daysToAdd The days to add. May be negative for subtraction.
563 /// @return A copy of this object after modification.
564 //==========================================================================================
565 CalendarDate operator+=( int daysToAdd )
566 {
567 return (*this)= (*this) + daysToAdd;
568 }
569
570 //==========================================================================================
571 /// Subtracts the given number of days to this date.
572 /// @param daysToSubtract The days to add. May be negative for additons.
573 /// @return A copy of this object after modification.
574 //==========================================================================================
575 CalendarDate operator-=( int daysToSubtract )
576 {
577 return (*this)+= (- daysToSubtract);
578 }
579
580
581 //------------------------------------ Comparison ------------------------------------
582 //==========================================================================================
583 /// Equal to operator.
584 /// @param other The date stamp to compare.
585 /// @return The result of the comparison.
586 //==========================================================================================
587 bool operator==( const CalendarDate& other ) const
588 {
589 return stamp == other.stamp;
590 }
591
592 //==========================================================================================
593 /// Not equal to operator.
594 /// @param other The date stamp to compare.
595 /// @return The result of the comparison.
596 //==========================================================================================
597 bool operator!=( const CalendarDate& other ) const
598 {
599 return stamp != other.stamp;
600 }
601
602 //==========================================================================================
603 /// Less than operator.
604 /// @param other The date stamp to compare.
605 /// @return A reference to this object.
606 //==========================================================================================
607 bool operator<( const CalendarDate& other ) const
608 {
609 return stamp < other.stamp;
610 }
611
612 //==========================================================================================
613 /// Less than or equal to operator.
614 /// @param other The date stamp to compare.
615 /// @return The result of the comparison.
616 //==========================================================================================
617 bool operator<=( const CalendarDate& other ) const
618 {
619 return stamp <= other.stamp;
620 }
621
622 //==========================================================================================
623 /// Greater than operator.
624 /// @param other The date stamp to compare.
625 /// @return The result of the comparison.
626 //==========================================================================================
627 bool operator>( const CalendarDate& other ) const
628 {
629 return stamp > other.stamp;
630 }
631
632 //==========================================================================================
633 /// Greater than or equal to operator.
634 /// @param other The date stamp to compare.
635 /// @return The result of the comparison.
636 //==========================================================================================
637 bool operator>=( const CalendarDate& other ) const
638 {
639 return stamp >= other.stamp;
640 }
641}; // class CalendarDate
642
643
644} // namespace alib[::strings::util]
645
646/// Type alias in namespace \b alib.
648
649/// Type alias in namespace \b alib.
651
652/// Type alias in namespace \b alib.
654
655} // namespace [alib]
656
657
int Minute
The calendar minute (0..59).
Definition calendar.inl:62
ALIB_DLL void Set(const DateTime &timeStamp, lang::Timezone timezone=lang::Timezone::Local)
Definition calendar.cpp:75
int Second
The calendar second (0..59).
Definition calendar.inl:65
CalendarDateTime(const DateTime &timeStamp, lang::Timezone timezone=lang::Timezone::Local)
Definition calendar.inl:93
int Day
The calendar day (1..31).
Definition calendar.inl:56
CalendarDateTime(lang::Initialization init=lang::Initialization::Default)
Definition calendar.inl:81
ALIB_DLL AString & Format(Substring format, AString &target, lang::CurrentData targetData=lang::CurrentData::Keep) const
Definition calendar.cpp:319
int Hour
The calendar hour (0..23).
Definition calendar.inl:59
static ALIB_DLL String MONTH_NAMES[12]
Definition calendar.inl:39
int Year
The calendar year (e.g., 2022).
Definition calendar.inl:50
CalendarDateTime(int year, int month=1, int day=1, int hour=0, int minute=0, int second=0, int millisecond=0)
Definition calendar.inl:108
ALIB_DLL DateTime Get(lang::Timezone timezone=lang::Timezone::Local) const
Definition calendar.cpp:117
ALIB_DLL void Clear()
Sets all public values to 0.
Definition calendar.cpp:63
static ALIB_DLL String DAY_NAMES[7]
Definition calendar.inl:47
int Month
The calendar month (1..12).
Definition calendar.inl:53
int Millisecond
The calendar millisecond (0..999).
Definition calendar.inl:68
bool operator>(const CalendarDate &other) const
Definition calendar.inl:627
CalendarDate()=default
Default constructor leaving this object uninitialized (random value). **************.
ALIB_DLL void Set(int year, int month, int day, int dayOfWeek=-1)
Definition calendar.cpp:223
bool operator==(const CalendarDate &other) const
Definition calendar.inl:587
ALIB_DLL CalendarDateTime ToCalendarDateTime() const
ALIB_DLL CalendarDate operator++()
Definition calendar.cpp:265
CalendarDate operator-(int daysToSubtract) const
Definition calendar.inl:519
CalendarDate(const DateTime &dateTime, lang::Timezone timezone)
Definition calendar.inl:428
bool operator!=(const CalendarDate &other) const
Definition calendar.inl:597
uint32_t stamp
Encoded date value.
Definition calendar.inl:357
ALIB_DLL CalendarDate(const CalendarDateTime &calendarDateTime)
Definition calendar.inl:415
CalendarDate(const CalendarDate &) noexcept=default
Trivial default copy constructor. ***************************************************.
CalendarDate operator+=(int daysToAdd)
Definition calendar.inl:565
CalendarDate operator-=(int daysToSubtract)
Definition calendar.inl:575
CalendarDate(CalendarDate &&) noexcept=default
Trivial default move constructor. ***************************************************.
ALIB_DLL DateTime Get(lang::Timezone timezone=lang::Timezone::Local, int hour=12, int minute=0, int second=0) const
Definition calendar.cpp:252
bool operator<=(const CalendarDate &other) const
Definition calendar.inl:617
bool operator>=(const CalendarDate &other) const
Definition calendar.inl:637
CalendarDate(lang::Timezone timezone)
Definition calendar.inl:405
ALIB_DLL CalendarDate operator+(int daysToAdd) const
Definition calendar.cpp:257
bool operator<(const CalendarDate &other) const
Definition calendar.inl:607
ALIB_DLL CalendarDate operator--()
Definition calendar.cpp:298
CalendarDuration(lang::Initialization init=lang::Initialization::Default)
Definition calendar.inl:228
CalendarDuration(DateTime::Duration duration)
Definition calendar.inl:249
int Seconds
The number of seconds (not the total, hence 0-59) within the duration.
Definition calendar.inl:211
CalendarDuration(Ticks::Duration duration)
Definition calendar.inl:259
ALIB_DLL void FromNanoSeconds(int64_t nanos)
Definition calendar.cpp:189
int Hours
The number of hours (not the total, hence 0-23) within the duration.
Definition calendar.inl:205
int Nanoseconds
The number of nanoseconds (not the total, hence 0-999) within the duration.
Definition calendar.inl:220
int Minutes
The number of minutes (not the total, hence 0-59) within the duration.
Definition calendar.inl:208
void FromDuration(DateTime::Duration duration)
Definition calendar.inl:270
int Milliseconds
The number of milliseconds (not the total, hence 0-999) within the duration.
Definition calendar.inl:214
ALIB_DLL void Clear()
Sets all public values to 0.
Definition calendar.cpp:171
DateTime::Duration ToDateTimeDuration()
Definition calendar.inl:291
void FromDuration(Ticks::Duration duration)
Definition calendar.inl:281
int Microseconds
The number of microseconds (not the total, hence 0-999) within the duration.
Definition calendar.inl:217
int Days
The number of days within the duration.
Definition calendar.inl:202
#define ALIB_DLL
Definition alib.inl:496
#define ALIB_EXPORT
Definition alib.inl:488
@ Keep
Chooses not no clear existing data.
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.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
time::DateTime DateTime
Type alias in namespace alib.
Definition datetime.inl:224
strings::util::CalendarDateTime CalendarDateTime
Type alias in namespace alib.
Definition calendar.inl:647
strings::util::CalendarDuration CalendarDuration
Type alias in namespace alib.
Definition calendar.inl:650
strings::util::CalendarDate CalendarDate
Type alias in namespace alib.
Definition calendar.inl:653
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2381
strings::TSubstring< character > Substring
Type alias in namespace alib.