]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/windtfmt.h
ICU-64243.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / windtfmt.h
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
73c04bcf
A
3/*
4********************************************************************************
2ca993e8 5* Copyright (C) 2005-2015, International Business Machines
73c04bcf
A
6* Corporation and others. All Rights Reserved.
7********************************************************************************
8*
9* File WINDTFMT.H
10*
11********************************************************************************
12*/
13
14#ifndef __WINDTFMT
15#define __WINDTFMT
16
17#include "unicode/utypes.h"
18
f3c0d7a5 19#if U_PLATFORM_USES_ONLY_WIN32_API
73c04bcf
A
20
21#if !UCONFIG_NO_FORMATTING
22
23#include "unicode/format.h"
24#include "unicode/datefmt.h"
25#include "unicode/calendar.h"
26#include "unicode/ustring.h"
27#include "unicode/locid.h"
28
29/**
30 * \file
31 * \brief C++ API: Format dates using Windows API.
32 */
33
34U_CDECL_BEGIN
35// Forward declarations for Windows types...
36typedef struct _SYSTEMTIME SYSTEMTIME;
37typedef struct _TIME_ZONE_INFORMATION TIME_ZONE_INFORMATION;
38U_CDECL_END
39
40U_NAMESPACE_BEGIN
41
42class Win32DateFormat : public DateFormat
43{
44public:
45 Win32DateFormat(DateFormat::EStyle timeStyle, DateFormat::EStyle dateStyle, const Locale &locale, UErrorCode &status);
46
47 Win32DateFormat(const Win32DateFormat &other);
48
49 virtual ~Win32DateFormat();
50
51 virtual Format *clone(void) const;
52
53 Win32DateFormat &operator=(const Win32DateFormat &other);
54
55 UnicodeString &format(Calendar &cal, UnicodeString &appendTo, FieldPosition &pos) const;
56
2ca993e8 57 using DateFormat::format;
73c04bcf
A
58
59 void parse(const UnicodeString& text, Calendar& cal, ParsePosition& pos) const;
60
61 /**
62 * Set the calendar to be used by this date format. Initially, the default
63 * calendar for the specified or default locale is used. The caller should
64 * not delete the Calendar object after it is adopted by this call.
65 *
66 * @param calendarToAdopt Calendar object to be adopted.
73c04bcf
A
67 */
68 virtual void adoptCalendar(Calendar* calendarToAdopt);
69
70 /**
71 * Set the calendar to be used by this date format. Initially, the default
72 * calendar for the specified or default locale is used.
73 *
74 * @param newCalendar Calendar object to be set.
73c04bcf
A
75 */
76 virtual void setCalendar(const Calendar& newCalendar);
77
78 /**
79 * Sets the time zone for the calendar of this DateFormat object. The caller
80 * no longer owns the TimeZone object and should not delete it after this call.
81 *
82 * @param zoneToAdopt the TimeZone to be adopted.
73c04bcf
A
83 */
84 virtual void adoptTimeZone(TimeZone* zoneToAdopt);
85
86 /**
87 * Sets the time zone for the calendar of this DateFormat object.
88 * @param zone the new time zone.
73c04bcf
A
89 */
90 virtual void setTimeZone(const TimeZone& zone);
91
92 /**
93 * Return the class ID for this class. This is useful only for comparing to
94 * a return value from getDynamicClassID(). For example:
95 * <pre>
96 * . Base* polymorphic_pointer = createPolymorphicObject();
97 * . if (polymorphic_pointer->getDynamicClassID() ==
f3c0d7a5 98 * . derived::getStaticClassID()) ...
73c04bcf
A
99 * </pre>
100 * @return The class ID for all objects of this class.
73c04bcf 101 */
46f4442e 102 U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
73c04bcf
A
103
104 /**
105 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
106 * method is to implement a simple version of RTTI, since not all C++
107 * compilers support genuine RTTI. Polymorphic operator==() and clone()
108 * methods call this method.
109 *
110 * @return The class ID for this object. All objects of a
111 * given class have the same class ID. Objects of
112 * other classes have different class IDs.
73c04bcf
A
113 */
114 virtual UClassID getDynamicClassID(void) const;
115
116private:
117 void formatDate(const SYSTEMTIME *st, UnicodeString &appendTo) const;
118 void formatTime(const SYSTEMTIME *st, UnicodeString &appendTo) const;
119
120 UnicodeString setTimeZoneInfo(TIME_ZONE_INFORMATION *tzi, const TimeZone &zone) const;
729e4ab9 121 UnicodeString* getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status) const;
73c04bcf
A
122
123 UnicodeString *fDateTimeMsg;
124 DateFormat::EStyle fTimeStyle;
125 DateFormat::EStyle fDateStyle;
57a6839d 126 Locale fLocale;
73c04bcf
A
127 UnicodeString fZoneID;
128 TIME_ZONE_INFORMATION *fTZI;
f3c0d7a5
A
129
130 UnicodeString* fWindowsLocaleName; // Stores the equivalent Windows locale name.
73c04bcf
A
131};
132
73c04bcf
A
133U_NAMESPACE_END
134
135#endif /* #if !UCONFIG_NO_FORMATTING */
136
f3c0d7a5 137#endif // U_PLATFORM_USES_ONLY_WIN32_API
73c04bcf
A
138
139#endif // __WINDTFMT