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:44
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:63
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 culture_info get_culture_info(const xtd::string &name)
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 (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 date_time_format_info &info)
 Initializes a new instance of the xtd::globalization::date_time_format_info class with specified infp.
 

Public Properties

const xtd::array< xtd::string > & abreviated_day_names () const noexcept
 Gets a one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week.
 
date_time_format_infoabreviated_day_names (const xtd::array< xtd::string > &value) noexcept
 Sets a one-dimensional array of type String containing the culture-specific abbreviated names of the days of the week.
 
const xtd::array< xtd::string > & abreviated_month_genitive_names () const noexcept
 
date_time_format_infoabreviated_month_genitive_names (const xtd::array< xtd::string > &value) noexcept
 
const xtd::array< xtd::string > & abreviated_month_names () const noexcept
 
date_time_format_infoabreviated_month_names (const xtd::array< xtd::string > &value) noexcept
 
const xtd::stringam_designator () const noexcept
 
date_time_format_infoam_designator (const xtd::string &value) noexcept
 
const xtd::stringdate_separator () const noexcept
 
date_time_format_infodate_separator (const xtd::string &value) noexcept
 
const xtd::array< xtd::string > & day_names () const noexcept
 
date_time_format_infoday_names (const xtd::array< xtd::string > &value) noexcept
 
xtd::day_of_week first_day_of_week () const noexcept
 
date_time_format_infofirst_day_of_week (xtd::day_of_week value) noexcept
 
const stringfull_date_time_pattern () const noexcept
 
date_time_format_infofull_date_time_pattern (const string &value) noexcept
 
const stringlong_date_pattern () const noexcept
 
date_time_format_infolong_date_pattern (const string &value) noexcept
 
const stringlong_time_pattern () const noexcept
 
date_time_format_infolong_time_pattern (const string &value) noexcept
 
const stringmonth_day_pattern () const noexcept
 
date_time_format_infomonth_day_pattern (const string &value) noexcept
 
const xtd::array< xtd::string > & month_genitive_names () const noexcept
 
date_time_format_infomonth_genitive_names (const xtd::array< xtd::string > &value) noexcept
 
const xtd::array< xtd::string > & month_names () const noexcept
 
date_time_format_infomonth_names (const xtd::array< xtd::string > &value) noexcept
 
const xtd::stringnative_calendar_name () const noexcept
 
date_time_format_infonative_calendar_name (const xtd::string &value) noexcept
 
const xtd::stringpm_designator () const noexcept
 
date_time_format_infopm_designator (const xtd::string &value) noexcept
 
const stringrfc_1123_pattern () const noexcept
 
date_time_format_inforfc_1123_pattern (const string &value) noexcept
 
const stringshort_date_pattern () const noexcept
 
date_time_format_infoshort_date_pattern (const string &value) noexcept
 
const stringshort_time_pattern () const noexcept
 
date_time_format_infoshort_time_pattern (const string &value) noexcept
 
const xtd::array< xtd::string > & shortest_day_names () const noexcept
 
date_time_format_infoshortest_day_names (const xtd::array< xtd::string > &value) noexcept
 
const stringsortable_date_time_pattern () const noexcept
 
date_time_format_infosortable_date_time_pattern (const string &value) noexcept
 
const xtd::stringtime_separator () const noexcept
 
date_time_format_infotime_separator (const xtd::string &value) noexcept
 
const stringuniversal_sortable_date_time_pattern () const noexcept
 
date_time_format_infouniversal_sortable_date_time_pattern (const string &value) noexcept
 
const stringyear_month_pattern () const noexcept
 
date_time_format_infoyear_month_pattern (const string &value) noexcept
 

Public Static Properties

static const date_time_format_infocurrent_info () noexcept
 
static const date_time_format_infoinvariant_info () noexcept
 

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 noexcept
 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 ( 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 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]

const xtd::array< xtd::string > & xtd::globalization::date_time_format_info::abreviated_day_names ( ) const
noexcept

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]

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

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.

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