xtd 0.2.0
Loading...
Searching...
No Matches
xtd::globalization::date_time_format_info Class Reference
Inheritance diagram for xtd::globalization::date_time_format_info:
xtd::object

Definition

Provides culture-specific information about the format of date and time values.

date_time_format_info()
Initializes a new instance of the xtd::globalization::date_time_format_info class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Inheritance
xtd::objectxtd::globalization::date_time_format_info
Header
#include <xtd/globalization/date_time_format_info>
Namespace
xtd::globalization
Library
xtd.core
Examples
The following example uses reflection to get the properties of the xtd::globalization::date_time_format_info object for the English (United States) culture. It displays the value of those properties that contain custom format strings and uses those strings to display formatted dates.
#include <xtd/xtd>
using namespace xtd::globalization;
auto main() -> int {
// Get the properties of an en-US date_time_format_info object.
auto dtfi = culture_info::get_culture_info("en-US").date_time_format();
using property_info = std::tuple<string, delegate<const string&()>>;
auto props = array<property_info> {{"full_date_time_pattern", {dtfi, &date_time_format_info::full_date_time_pattern}}, {"long_date_pattern", {dtfi, &date_time_format_info::long_date_pattern}}, {"long_time_pattern", {dtfi, &date_time_format_info::long_time_pattern}}, {"month_day_pattern", {dtfi, &date_time_format_info::month_day_pattern}}, {"rfc_1123_pattern", {dtfi, &date_time_format_info::rfc_1123_pattern}}, {"short_date_pattern", {dtfi, &date_time_format_info::short_date_pattern}}, {"short_time_pattern", {dtfi, &date_time_format_info::short_time_pattern}}, {"sortable_date_time_pattern", {dtfi, &date_time_format_info::sortable_date_time_pattern}}, {"universal_sortable_date_time_pattern", {dtfi, &date_time_format_info::universal_sortable_date_time_pattern}}, {"year_month_pattern", {dtfi, &date_time_format_info::year_month_pattern}}};
auto value = date_time {2012, 5, 28, 11, 35, 0};
for (const auto& [name, pattern] : props)
console::write_line("{,-37} {} \n{,-41}Example: {}\n", name, pattern(), "", value.to_string(pattern()));
}
// This code produces the following output :
//
// full_date_time_pattern dddd, MMMM d, yyyy h:mm:ss tt
// Example: Monday, May 28, 2012 11:35:00 AM
//
// long_date_pattern dddd, MMMM d, yyyy
// Example: Monday, May 28, 2012
//
// long_time_pattern h:mm:ss tt
// Example: 11:35:00 AM
//
// month_day_pattern MMMM d
// Example: May 28
//
// rfc_1123_pattern ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
// Example: Mon, 28 May 2012 11:35:00 GMT
//
// short_date_pattern M/d/yyyy
// Example: 5/28/2012
//
// short_time_pattern h:mm tt
// Example: 11:35 AM
//
// sortable_date_time_pattern yyyy'-'MM'-'dd'T'HH':'mm':'ss
// Example: 2012-05-28T11:35:00
//
// universal_sortable_date_time_pattern yyyy'-'MM'-'dd HH':'mm':'ss'Z'
// Example: 2012-05-28 11:35:00Z
//
// year_month_pattern MMMM yyyy
// Example: May 2012
//
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:83
static auto get_culture_info(const xtd::string &name) -> xtd::globalization::culture_info
Retrieves a cached, read-only instance of a culture using the specified culture name.
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
Contains classes that define culture-related information, including language, country/region,...
Definition culture_info.hpp:20

Public Constructors

 date_time_format_info ()
 Initializes a new instance of the xtd::globalization::date_time_format_info class.
 
 date_time_format_info (xtd::globalization::date_time_format_info &&info)=default
 Initializes a new instance of the xtd::globalization::date_time_format_info class with specified info.
 
 date_time_format_info (const xtd::globalization::date_time_format_info &info)
 Initializes a new instance of the xtd::globalization::date_time_format_info class with specified infp.
 

Public Properties

auto abreviated_day_names () const noexcept -> const xtd::array< xtd::string > &
 Gets a one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week.
 
auto abreviated_day_names (const xtd::array< xtd::string > &value) -> xtd::globalization::date_time_format_info &
 Sets a one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week.
 
auto abreviated_month_genitive_names () const noexcept -> const xtd::array< xtd::string > &
 Gets a string array of abbreviated month names associated with the current xtd::globalization::date_time_format_info object.
 
auto abreviated_month_genitive_names (const xtd::array< xtd::string > &value) -> xtd::globalization::date_time_format_info &
 Sets a string array of abbreviated month names associated with the current xtd::globalization::date_time_format_info object.
 
auto abreviated_month_names () const noexcept -> const xtd::array< xtd::string > &
 Gets or a one-dimensional string array that contains the culture-specific abbreviated names of the months.
 
auto abreviated_month_names (const xtd::array< xtd::string > &value) -> xtd::globalization::date_time_format_info &
 Sets or a one-dimensional string array that contains the culture-specific abbreviated names of the months. @oaram value A one-dimensional string array with 13 elements that contains the culture-specific abbreviated names of the months. For 12-month calendars, the 13th element of the array is an empty string. The array for InvariantInfo contains "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", and "".
 
auto am_designator () const noexcept -> const xtd::string &
 Gets the string designator for hours that are "ante meridiem" (before noon).
 
auto am_designator (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 Sets the string designator for hours that are "ante meridiem" (before noon).
 
auto date_separator () const noexcept -> const xtd::string &
 
auto date_separator (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto day_names () const noexcept -> const xtd::array< xtd::string > &
 
auto day_names (const xtd::array< xtd::string > &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto first_day_of_week () const noexcept -> xtd::day_of_week
 
auto first_day_of_week (xtd::day_of_week value) noexcept -> xtd::globalization::date_time_format_info &
 
auto full_date_time_pattern () const noexcept -> const xtd::string &
 
auto full_date_time_pattern (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto long_date_pattern () const noexcept -> const xtd::string &
 
auto long_date_pattern (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto long_time_pattern () const noexcept -> const xtd::string &
 
auto long_time_pattern (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto month_day_pattern () const noexcept -> const xtd::string &
 
auto month_day_pattern (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto month_genitive_names () const noexcept -> const xtd::array< xtd::string > &
 
auto month_genitive_names (const xtd::array< xtd::string > &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto month_names () const noexcept -> const xtd::array< xtd::string > &
 
auto month_names (const xtd::array< xtd::string > &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto native_calendar_name () const noexcept -> const xtd::string &
 
auto native_calendar_name (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto pm_designator () const noexcept -> const xtd::string &
 
auto pm_designator (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto rfc_1123_pattern () const noexcept -> const xtd::string &
 
auto rfc_1123_pattern (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto short_date_pattern () const noexcept -> const xtd::string &
 
auto short_date_pattern (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto short_time_pattern () const noexcept -> const xtd::string &
 
auto short_time_pattern (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto shortest_day_names () const noexcept -> const xtd::array< xtd::string > &
 
auto shortest_day_names (const xtd::array< xtd::string > &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto sortable_date_time_pattern () const noexcept -> const xtd::string &
 
auto sortable_date_time_pattern (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto time_separator () const noexcept -> const xtd::string &
 
auto time_separator (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto universal_sortable_date_time_pattern () const noexcept -> const xtd::string &
 
auto universal_sortable_date_time_pattern (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 
auto year_month_pattern () const noexcept -> const xtd::string &
 
auto year_month_pattern (const xtd::string &value) noexcept -> xtd::globalization::date_time_format_info &
 

Public Static Properties

static auto current_info () noexcept -> const xtd::globalization::date_time_format_info &
 Gets a read-only xtd::globalization::date_time_format_info object that formats values based on the current culture.
 
static auto invariant_info () noexcept -> const xtd::globalization::date_time_format_info &
 Gets the default read-only xtd::globalization::date_time_format_info object that is culture-independent (invariant).
 

Additional Inherited Members

 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual xtd::size get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<class object_t>
xtd::unique_ptr_object< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
virtual xtd::string to_string () const
 Returns a xtd::string that represents the current object.
 
template<class object_a_t, class object_b_t>
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<class object_a_t, class object_b_t>
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Constructor & Destructor Documentation

◆ date_time_format_info() [1/3]

xtd::globalization::date_time_format_info::date_time_format_info ( )

Initializes a new instance of the xtd::globalization::date_time_format_info class.

Remarks
This constructor creates a xtd::globalization::date_time_format_info object that represents the date and time information of the invariant culture. To create a xtd::globalization::date_time_format_info object for a specific culture, create a xtd::globalization::culture_info object for that culture and retrieve the xtd::globalization::date_time_format_info object returned by its xtd::globalization::culture_info::date_time_format property.
The properties of the xtd::globalization::date_time_format_info object created by this constructor can be modified. However, you cannot modify the xtd::globalization::date_time_format_info::calendar property, because the invariant culture supports only a localized version of the Gregorian calendar. To create a xtd::globalization::date_time_format_info object that uses a specific calendar, you must instantiate a xtd::globalization::culture_info object that supports that calendar and assign the calendar to the xtd::globalization::date_time_format_info::calendar property of the xtd::globalization::date_time_format_info object returned by the xtd::globalization::culture_info::date_time_format property.

◆ date_time_format_info() [2/3]

xtd::globalization::date_time_format_info::date_time_format_info ( xtd::globalization::date_time_format_info && info)
default

Initializes a new instance of the xtd::globalization::date_time_format_info class with specified info.

Parameters
infoThe xtd::globalization::date_time_format_info to inititalise this instance.

◆ date_time_format_info() [3/3]

xtd::globalization::date_time_format_info::date_time_format_info ( const xtd::globalization::date_time_format_info & info)

Initializes a new instance of the xtd::globalization::date_time_format_info class with specified infp.

Parameters
infoThe xtd::globalization::date_time_format_info to inititalise this instance.

Member Function Documentation

◆ abreviated_day_names() [1/2]

auto xtd::globalization::date_time_format_info::abreviated_day_names ( ) const -> const xtd::array< xtd::string > &
nodiscardnoexcept

Gets a one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week.

Returns
A one-dimensional array of type xtd::string containing the culture-specific abbreviated names of the days of the week. The array for xtd::globalization::date_time_format_info::invariant_info contains "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", and "Sat".

◆ abreviated_day_names() [2/2]

auto xtd::globalization::date_time_format_info::abreviated_day_names ( const xtd::array< xtd::string > & value) -> xtd::globalization::date_time_format_info &

Sets a one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week.

Parameters
valueA one-dimensional array of type xtd::string containing the culture-specific abbreviated names of the days of the week. The array for xtd::globalization::date_time_format_info::invariant_info contains "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", and "Sat".
Exceptions
xtd::argument_exceptionThe property is being set to an array that has a length that is not exactly 7.

◆ abreviated_month_genitive_names() [1/2]

auto xtd::globalization::date_time_format_info::abreviated_month_genitive_names ( ) const -> const xtd::array< xtd::string > &
nodiscardnoexcept

Gets a string array of abbreviated month names associated with the current xtd::globalization::date_time_format_info object.

Returns
An array of abbreviated month names.

◆ abreviated_month_genitive_names() [2/2]

auto xtd::globalization::date_time_format_info::abreviated_month_genitive_names ( const xtd::array< xtd::string > & value) -> xtd::globalization::date_time_format_info &

Sets a string array of abbreviated month names associated with the current xtd::globalization::date_time_format_info object.

Parameters
valueAn array of abbreviated month names.
Exceptions
xtd::argument_exceptionThe property is being set to an array that has a length that is not exactly 13.

◆ abreviated_month_names() [1/2]

auto xtd::globalization::date_time_format_info::abreviated_month_names ( ) const -> const xtd::array< xtd::string > &
nodiscardnoexcept

Gets or a one-dimensional string array that contains the culture-specific abbreviated names of the months.

Returns
A one-dimensional string array with 13 elements that contains the culture-specific abbreviated names of the months. For 12-month calendars, the 13th element of the array is an empty string. The array for InvariantInfo contains "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", and "".

◆ abreviated_month_names() [2/2]

auto xtd::globalization::date_time_format_info::abreviated_month_names ( const xtd::array< xtd::string > & value) -> xtd::globalization::date_time_format_info &

Sets or a one-dimensional string array that contains the culture-specific abbreviated names of the months. @oaram value A one-dimensional string array with 13 elements that contains the culture-specific abbreviated names of the months. For 12-month calendars, the 13th element of the array is an empty string. The array for InvariantInfo contains "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", and "".

Exceptions
xtd::argument_exceptionThe property is being set to an array that has a length that is not exactly 13.

◆ am_designator() [1/2]

auto xtd::globalization::date_time_format_info::am_designator ( ) const -> const xtd::string &
nodiscardnoexcept

Gets the string designator for hours that are "ante meridiem" (before noon).

Returns
The string designator for hours that are ante meridiem. The default for InvariantInfo is "AM".
Remarks
The xtd::globalization::date_time_format_info::am_designator property is used for all times from 0:00:00 (midnight) to 11:59:59.999.
If a custom format string includes the "tt" format specifier and the time is before noon, the xtd::date_time::to_string method includes the value of the xtd::globalization::date_time_format_info::am_designator property in place of "tt" in the result string. If the custom format string includes the "t" custom format specifier, only the first character of the xtd::globalization::date_time_format_info::am_designator property value is included. You should use "tt" for languages for which it is necessary to maintain the distinction between A.M. and P.M. An example is Japanese, in which the A.M. and P.M. designators differ in the second character instead of the first character.
For cultures that do not use an A.M. designator, this property returns an empty string.

◆ am_designator() [2/2]

auto xtd::globalization::date_time_format_info::am_designator ( const xtd::string & value) -> xtd::globalization::date_time_format_info &
noexcept

Sets the string designator for hours that are "ante meridiem" (before noon).

Parameters
valueThe string designator for hours that are ante meridiem. The default for InvariantInfo is "AM".
Remarks
If a custom format string includes the "tt" format specifier and the time is before noon, the xtd::date_time::to_string method includes the value of the xtd::globalization::date_time_format_info::am_designator property in place of "tt" in the result string. If the custom format string includes the "t" custom format specifier, only the first character of the xtd::globalization::date_time_format_info::am_designator property value is included. You should use "tt" for languages for which it is necessary to maintain the distinction between A.M. and P.M. An example is Japanese, in which the A.M. and P.M. designators differ in the second character instead of the first character.
For cultures that do not use an A.M. designator, this property returns an empty string.

◆ current_info()

static auto xtd::globalization::date_time_format_info::current_info ( ) -> const xtd::globalization::date_time_format_info &
staticnodiscardnoexcept

Gets a read-only xtd::globalization::date_time_format_info object that formats values based on the current culture.

Returns
A read-only xtd::globalization::date_time_format_info object based on the xtd::globalization::culture_info object for the current thread.
Remarks
The xtd::globalization::date_time_format_info object returned by the xtd::globalization::date_time_format_info::current_info property reflects user overrides.

◆ invariant_info()

static auto xtd::globalization::date_time_format_info::invariant_info ( ) -> const xtd::globalization::date_time_format_info &
staticnodiscardnoexcept

Gets the default read-only xtd::globalization::date_time_format_info object that is culture-independent (invariant).

Returns
A read-only object that is culture-independent (invariant).
Remarks
This property does not change, regardless of the current culture. Because of this, the invariant culture's xtd::globalization::date_time_format_info object can be used to produce consistent, culture-independent results in parsing and formatting operations on data that is multi-cultural. For example, if date and time data from multiple cultures is to be persisted in string form, it can be formatted by using the xtd::globalization::date_time_format_info object of the invariant culture and saved. It can then be parsed by using the invariant culture's xtd::globalization::date_time_format_info object.

The documentation for this class was generated from the following file: