Quick Links: |
Provide date and time vocabulary types, and related utilities. More...
Components | |
Component bdlt_calendar | |
Provide fast repository for accessing weekend/holiday information. | |
Component bdlt_calendarcache | |
Provide an efficient cache for read-only | |
Component bdlt_calendarloader | |
Provide a protocol (or pure interface) for loading calendars. | |
Component bdlt_calendarreverseiteratoradapter | |
Provide reverse iterator adapter for calendar iterators. | |
Component bdlt_calendarutil | |
Provide common date manipulations requiring a calendar. | |
Component bdlt_currenttime | |
Provide utilities to retrieve the current time. | |
Component bdlt_date | |
Provide a value-semantic type to represent dates. | |
Component bdlt_datetime | |
Provide a value-semantic type representing both date and time. | |
Component bdlt_datetimeimputil | |
Provide constants useful for encoding datetimes. | |
Component bdlt_datetimeinterval | |
Provide a representation of an interval of time. | |
Component bdlt_datetimeintervalutil | |
Provide non-primitive operations on | |
Component bdlt_datetimetz | |
Provide a representation of a date and time with time zone offset. | |
Component bdlt_datetimeutil | |
Provide common non-primitive operations on | |
Component bdlt_datetz | |
Provide a representation of a date with time zone offset. | |
Component bdlt_dateutil | |
Provide common non-primitive operations on date objects. | |
Component bdlt_dayofweek | |
Provide an enumeration of the set of days of the week. | |
Component bdlt_dayofweekset | |
Provide an ordered set of (unique) | |
Component bdlt_dayofweekutil | |
Provide common non-primitive operations on | |
Component bdlt_defaultcalendarcache | |
Provide a process-wide default | |
Component bdlt_defaulttimetablecache | |
Provide a process-wide default | |
Component bdlt_epochutil | |
Conversion between absolute/relative time with respect to epoch. | |
Component bdlt_fixutil | |
Provide conversions between date/time objects and FIX strings. | |
Component bdlt_fixutilconfiguration | |
Provide an attribute class to configure FIX string generation. | |
Component bdlt_fuzzutil | |
Provide creation of | |
Component bdlt_intervalconversionutil | |
Provide functions to convert between time-interval representations. | |
Component bdlt_iso8601util | |
Provide conversions between date/time objects and ISO 8601 strings. | |
Component bdlt_iso8601utilconfiguration | |
Provide an attribute class to configure ISO 8601 string generation. | |
Component bdlt_localtimeoffset | |
Provide utilities to retrieve the local time offset. | |
Component bdlt_monthofyear | |
Enumerate the set of month-of-year values. | |
Component bdlt_packedcalendar | |
Provide a compact repository for weekend/holiday information. | |
Component bdlt_posixdateimputil | |
Provide low-level support functions for date-value manipulation. | |
Component bdlt_prolepticdateimputil | |
Provide low-level support functions for date-value manipulation. | |
Component bdlt_serialdateimputil | |
Provide low-level support functions for date-value manipulation. | |
Component bdlt_time | |
Provide a value-semantic type representing time-of-day. | |
Component bdlt_timetable | |
Provide a repository for accessing timetable information. | |
Component bdlt_timetablecache | |
Provide an efficient cache for read-only | |
Component bdlt_timetableloader | |
Provide a protocol (or pure interface) for loading timetables. | |
Component bdlt_timetz | |
Provide a representation of a time with time zone offset. | |
Component bdlt_timeunitratio | |
Provide constants characterizing ratios between common time units. | |
Component bdlt_timeutil | |
Provide common non-primitive operations on |
bdlt
("Basic Development Library Time") package provides vocabulary types for representing date, time, and datetime values, and utilities providing non-primitive functionality on the value types. bdlt
package currently has 40 components having 9 levels of physical dependency. The list below shows the hierarchical ordering of the components. The order of components within each level is not architecturally significant, just alphabetical. 9. bdlt_defaultcalendarcache bdlt_defaulttimetablecache 8. bdlt_calendarcache bdlt_timetablecache 7. bdlt_currenttime bdlt_fixutil bdlt_iso8601util 6. bdlt_calendarutil bdlt_datetimetz bdlt_localtimeoffset bdlt_timetableloader 5. bdlt_calendar bdlt_calendarloader bdlt_datetimeutil bdlt_datetz bdlt_epochutil bdlt_timetable 4. bdlt_datetime bdlt_dateutil bdlt_fuzzutil bdlt_packedcalendar bdlt_timetz bdlt_timeutil 3. bdlt_date bdlt_datetimeintervalutil bdlt_intervalconversionutil bdlt_time 2. bdlt_datetimeimputil bdlt_datetimeinterval bdlt_dayofweekset bdlt_dayofweekutil bdlt_serialdateimputil 1. bdlt_calendarreverseiteratoradapter bdlt_dayofweek bdlt_fixutilconfiguration bdlt_iso8601utilconfiguration bdlt_monthofyear bdlt_posixdateimputil bdlt_prolepticdateimputil bdlt_timeunitratio
bdlt_calendar
: bdlt_calendarloader
: bdlt_calendarreverseiteratoradapter
: bdlt_calendarutil
: bdlt_currenttime
: bdlt_date
: bdlt_datetime
: bdlt_datetimeimputil
: bdlt_datetimeinterval
: bdlt_datetimetz
: bdlt_datetz
: bdlt_dateutil
: bdlt_dayofweek
: bdlt_epochutil
: bdlt_fixutil
: bdlt_fixutilconfiguration
: bdlt_fuzzutil
: bdlt
data types from fuzz data.bdlt_intervalconversionutil
: bdlt_iso8601util
: bdlt_iso8601utilconfiguration
: bdlt_localtimeoffset
: bdlt_monthofyear
: bdlt_packedcalendar
: bdlt_posixdateimputil
: bdlt_prolepticdateimputil
: bdlt_serialdateimputil
: bdlt_time
: bdlt_timetable
: bdlt_timetableloader
: bdlt_timetz
: bdlt_timeunitratio
: bdlt
package defines bdlt::Date
to represent date values, bdlt::Time
to represent time values (to microsecond resolution) within a day, and the combined bdlt::Datetime
to represent all points in time (to microsecond resolution) across the range of date values. The ranges of each type are shown below. Type Range ------- ------------------------------------------------------------ Date [0001/01/01 .. 9999/12/31 ] Time [ 00:00:00.000000 .. 23:59:59.999999 ] Datetime [0001/01/01_00:00:00.000000 .. 9999/12/31_23:59:59.999999 ]
bdlt_date
. bdlt::Datetime
does not allow for leap seconds. bdlt::DatetimeInterval
class represents the difference (to microsecond resolution) between those points. Type Difference Type ------- ---------------- Date int (days) Time DatetimeInterval Datetime DatetimeInterval DatetimeInterval DatetimeInterval
bdlt::Time
class defines a singular value, "24:00:00.000000", which is also the default-constructed value. This singular value is distinguished in two ways: Relational comparisons to other time values are disallowed -- the behavior is undefined. Note that comparisons of equality and inequality to other values are legal.
bdlt::Time
values. bdlt::Datetime
class defines one singular value, "0001/01/01_24:00:00.000000", which happens to be the default constructed value. The restrictions and semantics of this value parallel those of the singular bdlt::Time
value. bdetu_unset
.) seconds
attribute of bsls::TimeInterval
). Basis Type Augmented Type ---------- ---------------- bldt:Date bdlt::DateTz bldt:Time bdlt::TimeTz bldt:Datetime bdlt::DatetimeTz
utc*
accessor method. bdlt
package provides enumerations in bdlt_monthofyear
and bdlt_dayofweek
. The bdlt_dayofweekset
provides an efficient, ordered container of unique btdl::DayofWeek::Enum
values (i.e., containing no more than seven elements). bdlt_currenttime
component provides: bdlt::Datetime
value for the current UTC time. bdlt::Datetime
value for the current local time. bsls::TimeInterval
from the start of the epoch. bdlt_localtimeoffset
component defines a function that returns the offset of the host machines designated time zone (as set by the system administrator) from UTC, including adjustments between standard and daylight-saving time, as of a given UTC time and date. For local-time offset for arbitrary time zones see the baetzo
package. bdlt::CurrentTime
and bdlt::LocalTimeOffset
obtain their values via user-installed callback functions. The default callbacks obtain their values from platform appropriate system calls. User-defined callbacks can provide high-performance (e.g., cached) alternatives to the default system calls, can be instrumented to gather statistics, and can simulate the passage of time for test scenarios. bdet_dateutil
component provides functions on bdlt::Date
values that extend those provided by the bdlt::Date
class itself. For example: bdlt::Date
that is a specified number of months -- or years -- before or after a given date. Two different end-of-month conventions are provided. bdlt::Date
values to and from int
values in the "YYYYMMDD" format. bdlt
provide functions for the conversion of date and time types to other types, some defined in the C++ Standard, others defined elsewhere in BDE. In particular, the bdlt_epochutil
component provides functions that convert bdlt::Datetime
values (in UTC) -- understood to represent an absolute date and time in UTC -- to equivalent difference values measured from the start of the Unix standard epoch (1970/01/01_00:00:00.000000 UTC). Component Conversions ----------------- -------------------------------------------------------- bdlt_dateutil bdlt::Date <=> 'int' in "YYYYMMDD" format bdlt_datetimeutil bdlt::Datetime <=> bsl::tm bdlt_epochutil bdlt::Datetime <=> bsl::time_t from the epoch bdlt::Datetime <=> bdlt::TimeT64 from the epoch bdlt::Datetime <=> bsls::TimeInterval from the epoch bdlt::Datetime <=> bdlt::DateTimeInterval from the epoch bdlt_intervalconversionutil bdlt::DatetimeInterval <=> bsls::TimeInterval bdlt_serialdateimputil bdlt::Date <=> 'int' in the range '[1 .. 3652059]' (corresponding to '[00001/01/01 .. 9999/12/31]')
bdlt_timeunitratio
component provides a set of constants that express the ratios between standard time units such as days, hours, ..., nanoseconds. One example is bdlt::TimeUnitRatio::k_MILLISECONDS_PER_MINUTE
. bdlt::Datetime
object to represent our date of birth. Let us assume that we were born at the exact start of the Unix epoch: bdlt::Datetime dtBirthday = bdlt::EpochUtil::epoch(); assert(bdlt::Datetime(1970, 1, 1, 0, 0, 0, 0) == dtBirthday);
bdlt::Datetime dt20k(dtBirthday); dt20k.addDays(20000); assert(bdlt::DatetimeInterval(20000) == dt20k - dtBirthday); bsl::cout << dt20k << bsl::endl;
04OCT2024_00:00:00.000000
bsls::TimeInterval localTimeOffset = bdlt::LocalTimeOffset::localTimeOffset(dt20k); bdlt::DatetimeInterval dtOffset = bdlt::IntervalConversionUtil::convertToDatetimeInterval(localTimeOffset); bdlt::DatetimeTz dtz20kLocal( dt20k + dtOffset, static_cast<int>(dtOffset.totalMinutes())); bsl::cout << dtz20kLocal << bsl::endl;
03OCT2024_20:00:00.000000-0400
bdlt::DatetimeTz
, but the class print
method shows that value as the concatenated decimal values four hours and minutes. bdlt::DayOfWeekSet
object set of the weekend days in New York City. bdlt::DayOfWeekSet weekendDays; weekendDays.add(bdlt::DayOfWeek::e_SATURDAY); weekendDays.add(bdlt::DayOfWeek::e_SUNDAY);
bdlt::Date milestone = dtz20kLocal.localDatetime().date(); bdlt::Date holdDate = weekendDays.isMember(milestone.dayOfWeek()) ? milestone : bdlt::DateUtil::nextDayOfWeek( bdlt::DayOfWeek::e_SATURDAY, milestone);
bsl::cout << "Milestone:" << " " << milestone.dayOfWeek() << " " << milestone << bsl::endl; bsl::cout << "Hold date:" << " " << holdDate.dayOfWeek() << " " << holdDate << bsl::endl;
Milestone: THU 03OCT2024 Hold date: SAT 05OCT2024