intl/icu/source/i18n/windtfmt.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /*
     2 ********************************************************************************
     3 *   Copyright (C) 2005-2013, International Business Machines
     4 *   Corporation and others.  All Rights Reserved.
     5 ********************************************************************************
     6 *
     7 * File WINDTFMT.H
     8 *
     9 ********************************************************************************
    10 */
    12 #ifndef __WINDTFMT
    13 #define __WINDTFMT
    15 #include "unicode/utypes.h"
    17 #if U_PLATFORM_HAS_WIN32_API
    19 #if !UCONFIG_NO_FORMATTING
    21 #include "unicode/format.h"
    22 #include "unicode/datefmt.h"
    23 #include "unicode/calendar.h"
    24 #include "unicode/ustring.h"
    25 #include "unicode/locid.h"
    27 /**
    28  * \file 
    29  * \brief C++ API: Format dates using Windows API.
    30  */
    32 U_CDECL_BEGIN
    33 // Forward declarations for Windows types...
    34 typedef struct _SYSTEMTIME SYSTEMTIME;
    35 typedef struct _TIME_ZONE_INFORMATION TIME_ZONE_INFORMATION;
    36 U_CDECL_END
    38 U_NAMESPACE_BEGIN
    40 class Win32DateFormat : public DateFormat
    41 {
    42 public:
    43     Win32DateFormat(DateFormat::EStyle timeStyle, DateFormat::EStyle dateStyle, const Locale &locale, UErrorCode &status);
    45     Win32DateFormat(const Win32DateFormat &other);
    47     virtual ~Win32DateFormat();
    49     virtual Format *clone(void) const;
    51     Win32DateFormat &operator=(const Win32DateFormat &other);
    53     UnicodeString &format(Calendar &cal, UnicodeString &appendTo, FieldPosition &pos) const;
    55     UnicodeString& format(UDate date, UnicodeString& appendTo) const;
    57     void parse(const UnicodeString& text, Calendar& cal, ParsePosition& pos) const;
    59     /**
    60      * Set the calendar to be used by this date format. Initially, the default
    61      * calendar for the specified or default locale is used.  The caller should
    62      * not delete the Calendar object after it is adopted by this call.
    63      *
    64      * @param calendarToAdopt    Calendar object to be adopted.
    65      */
    66     virtual void adoptCalendar(Calendar* calendarToAdopt);
    68     /**
    69      * Set the calendar to be used by this date format. Initially, the default
    70      * calendar for the specified or default locale is used.
    71      *
    72      * @param newCalendar Calendar object to be set.
    73      */
    74     virtual void setCalendar(const Calendar& newCalendar);
    76     /**
    77      * Sets the time zone for the calendar of this DateFormat object. The caller
    78      * no longer owns the TimeZone object and should not delete it after this call.
    79      *
    80      * @param zoneToAdopt the TimeZone to be adopted.
    81      */
    82     virtual void adoptTimeZone(TimeZone* zoneToAdopt);
    84     /**
    85      * Sets the time zone for the calendar of this DateFormat object.
    86      * @param zone the new time zone.
    87      */
    88     virtual void setTimeZone(const TimeZone& zone);
    90     /**
    91      * Return the class ID for this class. This is useful only for comparing to
    92      * a return value from getDynamicClassID(). For example:
    93      * <pre>
    94      * .   Base* polymorphic_pointer = createPolymorphicObject();
    95      * .   if (polymorphic_pointer->getDynamicClassID() ==
    96      * .       erived::getStaticClassID()) ...
    97      * </pre>
    98      * @return          The class ID for all objects of this class.
    99      */
   100     U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
   102     /**
   103      * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
   104      * method is to implement a simple version of RTTI, since not all C++
   105      * compilers support genuine RTTI. Polymorphic operator==() and clone()
   106      * methods call this method.
   107      *
   108      * @return          The class ID for this object. All objects of a
   109      *                  given class have the same class ID.  Objects of
   110      *                  other classes have different class IDs.
   111      */
   112     virtual UClassID getDynamicClassID(void) const;
   114 private:
   115     void formatDate(const SYSTEMTIME *st, UnicodeString &appendTo) const;
   116     void formatTime(const SYSTEMTIME *st, UnicodeString &appendTo) const;
   118     UnicodeString setTimeZoneInfo(TIME_ZONE_INFORMATION *tzi, const TimeZone &zone) const;
   119     UnicodeString* getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status) const;
   121     UnicodeString *fDateTimeMsg;
   122     DateFormat::EStyle fTimeStyle;
   123     DateFormat::EStyle fDateStyle;
   124     Locale fLocale;
   125     int32_t fLCID;
   126     UnicodeString fZoneID;
   127     TIME_ZONE_INFORMATION *fTZI;
   128 };
   130 inline UnicodeString &Win32DateFormat::format(UDate date, UnicodeString& appendTo) const {
   131     return DateFormat::format(date, appendTo);
   132 }
   134 U_NAMESPACE_END
   136 #endif /* #if !UCONFIG_NO_FORMATTING */
   138 #endif // U_PLATFORM_HAS_WIN32_API
   140 #endif // __WINDTFMT

mercurial