541
* Gets the date format for the current locale. The format is that used by
544
* @param lang The language to use. Defaults to host language.
545
* @param country The country to use. Defaults to host country.
546
* @return Returns said date format.
548
zstring get_date_format( iso639_1::type lang = iso639_1::unknown,
549
iso3166_1::type country = iso3166_1::unknown );
552
* Gets the date and time format for the current locale. The format is
553
* that used by strptime(3).
555
* @param lang The language to use. Defaults to host language.
556
* @param country The country to use. Defaults to host country.
557
* @return Returns said date format.
559
zstring get_date_time_format( iso639_1::type lang = iso639_1::unknown,
560
iso3166_1::type country = iso3166_1::unknown);
539
563
* Gets the ISO 3166-1 country code enumeration for the host system.
541
565
* @return Returns said enumeration or \c unknown.
550
574
iso639_1::type get_host_lang();
577
* Gets a month's abbreviation in the current locale.
579
* @param month_index The index of the month to get in the range 0-11.
580
* @param lang The language to use. Defaults to host language.
581
* @param country The country to use. Defaults to host country.
582
* @return Returns said abbreviation.
584
zstring get_month_abbr( unsigned month_index,
585
iso639_1::type lang = iso639_1::unknown,
586
iso3166_1::type country = iso3166_1::unknown );
589
* Gets a month's full name in the current locale.
591
* @param month_index The index of the month to get in the range 0-11.
592
* @param lang The language to use. Defaults to host language.
593
* @param country The country to use. Defaults to host country.
594
* @return Returns said full name.
596
zstring get_month_name( unsigned month_index,
597
iso639_1::type lang = iso639_1::unknown,
598
iso3166_1::type country = iso3166_1::unknown );
601
* Gets the time AM or PM string in the current locale.
603
* @param pm If \c true, gets the PM string; else the AM string.
604
* @param lang The language to use. Defaults to host language.
605
* @param country The country to use. Defaults to host country.
606
* @return Returns said string.
608
zstring get_time_ampm( bool pm, iso639_1::type lang = iso639_1::unknown,
609
iso3166_1::type country = iso3166_1::unknown );
612
* Gets the time format for the current locale. The format is that used by
615
* @param lang The language to use. Defaults to host language.
616
* @param country The country to use. Defaults to host country.
617
* @return Returns said time format.
619
zstring get_time_format( iso639_1::type lang = iso639_1::unknown,
620
iso3166_1::type country = iso3166_1::unknown );
623
* Gets a weekday's abbreviation in the current locale.
625
* @param day_index The index of the weekday to get in the range 0-6.
626
* @param lang The language to use. Defaults to host language.
627
* @param country The country to use. Defaults to host country.
628
* @return Returns said abbreviation.
630
zstring get_weekday_abbr( unsigned day_index,
631
iso639_1::type lang = iso639_1::unknown,
632
iso3166_1::type country = iso3166_1::unknown );
635
* Gets a weekday's full name in the current locale.
637
* @param day_index The index of the month to get in the range 0-6.
638
* @param lang The language to use. Defaults to host language.
639
* @param country The country to use. Defaults to host country.
640
* @return Returns said full name.
642
zstring get_weekday_name( unsigned day_index,
643
iso639_1::type lang = iso639_1::unknown,
644
iso3166_1::type country = iso3166_1::unknown );
647
* Checks if the given locale is supported by the OS.
649
* @param lang The language to use.
650
* @param country The country to use. Defaults to none.
651
* @return Returns \a true only if the given locale is supported by the OS.
653
bool is_supported( iso639_1::type lang,
654
iso3166_1::type country = iso3166_1::unknown );
657
* Parses a locale string.
659
* @param locale_str A locale string of the form \c ll{-_}CC[.enc] where
660
* \c ll is a 2 letter ISO 639-1 (or 3 letter 639-2) language code, \c CC
661
* is a 2 letter ISO 3166-1 country code, and \c enc is an optional
662
* encoding (which is ignored).
663
* @param lang A pointer to receive the language, if any.
664
* @param country A pointer to receive the country, if any.
665
* @return Returns \c true if at least a language is parsed.
667
bool parse( char const *locale_str, iso639_1::type *lang = nullptr,
668
iso3166_1::type *country = nullptr );
671
// Template version of parse().
673
template<class StringType> inline
674
typename std::enable_if<
675
ztd::has_c_str<StringType,char const* (StringType::*)() const>::value,
678
parse( StringType const &locale_str, iso639_1::type *lang = nullptr,
679
iso3166_1::type *country = nullptr ) {
680
return parse( locale_str.c_str(), lang, country );
552
683
///////////////////////////////////////////////////////////////////////////
554
685
} // namespace locale