ICU 4.8.1.1  4.8.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
udat.h
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  * Copyright (C) 1996-2010, International Business Machines
4  * Corporation and others. All Rights Reserved.
5  *******************************************************************************
6 */
7 
8 #ifndef UDAT_H
9 #define UDAT_H
10 
11 #include "unicode/utypes.h"
12 
13 #if !UCONFIG_NO_FORMATTING
14 
15 #include "unicode/localpointer.h"
16 #include "unicode/ucal.h"
17 #include "unicode/unum.h"
139 typedef void* UDateFormat;
140 
144 typedef enum UDateFormatStyle {
155 
157  UDAT_RELATIVE = (1 << 7),
158 
159  UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,
160 
161  UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,
162 
163  UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,
164 
165  UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,
166 
167 
169  UDAT_NONE = -1,
172 
174 
175 
207 #define UDAT_MINUTE_SECOND "ms"
208 #define UDAT_HOUR24_MINUTE "Hm"
209 #define UDAT_HOUR24_MINUTE_SECOND "Hms"
210 #define UDAT_HOUR_MINUTE_SECOND "hms"
211 #define UDAT_STANDALONE_MONTH "LLLL"
212 #define UDAT_ABBR_STANDALONE_MONTH "LLL"
213 #define UDAT_YEAR_QUARTER "yQQQ"
214 #define UDAT_YEAR_ABBR_QUARTER "yQ"
215 
226 #define UDAT_HOUR_MINUTE "hm"
227 #define UDAT_YEAR "y"
228 #define UDAT_DAY "d"
229 #define UDAT_NUM_MONTH_WEEKDAY_DAY "MEd"
230 #define UDAT_YEAR_NUM_MONTH "yM"
231 #define UDAT_NUM_MONTH_DAY "Md"
232 #define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd"
233 #define UDAT_ABBR_MONTH_WEEKDAY_DAY "MMMEd"
234 #define UDAT_YEAR_MONTH "yMMMM"
235 #define UDAT_YEAR_ABBR_MONTH "yMMM"
236 #define UDAT_MONTH_DAY "MMMMd"
237 #define UDAT_ABBR_MONTH_DAY "MMMd"
238 #define UDAT_MONTH_WEEKDAY_DAY "MMMMEEEEd"
239 #define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd"
240 #define UDAT_YEAR_MONTH_WEEKDAY_DAY "yMMMMEEEEd"
241 #define UDAT_YEAR_MONTH_DAY "yMMMMd"
242 #define UDAT_YEAR_ABBR_MONTH_DAY "yMMMd"
243 #define UDAT_YEAR_NUM_MONTH_DAY "yMd"
244 #define UDAT_NUM_MONTH "M"
245 #define UDAT_ABBR_MONTH "MMM"
246 #define UDAT_MONTH "MMMM"
247 #define UDAT_HOUR_MINUTE_GENERIC_TZ "hmv"
248 #define UDAT_HOUR_MINUTE_TZ "hmz"
249 #define UDAT_HOUR "h"
250 #define UDAT_HOUR_GENERIC_TZ "hv"
251 #define UDAT_HOUR_TZ "hz"
252 
261 typedef enum UDateFormatField {
268 
275 
282 
289 
298 
307 
314 
321 
328 
335 
342 
349 
356 
363 
370 
379 
388 
396 
403 
410 
417 
424 
431 
439 
453 
461 
470 
479 
486 
496 
498 
499 
510 
511 
534 udat_open(UDateFormatStyle timeStyle,
535  UDateFormatStyle dateStyle,
536  const char *locale,
537  const UChar *tzID,
538  int32_t tzIDLength,
539  const UChar *pattern,
540  int32_t patternLength,
541  UErrorCode *status);
542 
543 
550 U_STABLE void U_EXPORT2
551 udat_close(UDateFormat* format);
552 
553 #if U_SHOW_CPLUSPLUS_API
554 
556 
566 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateFormatPointer, UDateFormat, udat_close);
567 
569 
570 #endif
571 
581 udat_clone(const UDateFormat *fmt,
582  UErrorCode *status);
583 
602 U_STABLE int32_t U_EXPORT2
603 udat_format( const UDateFormat* format,
604  UDate dateToFormat,
605  UChar* result,
606  int32_t resultLength,
607  UFieldPosition* position,
608  UErrorCode* status);
609 
624 udat_parse( const UDateFormat* format,
625  const UChar* text,
626  int32_t textLength,
627  int32_t *parsePos,
628  UErrorCode *status);
629 
643 U_STABLE void U_EXPORT2
644 udat_parseCalendar(const UDateFormat* format,
645  UCalendar* calendar,
646  const UChar* text,
647  int32_t textLength,
648  int32_t *parsePos,
649  UErrorCode *status);
650 
661 udat_isLenient(const UDateFormat* fmt);
662 
672 U_STABLE void U_EXPORT2
674  UBool isLenient);
675 
686 udat_getCalendar(const UDateFormat* fmt);
687 
697 U_STABLE void U_EXPORT2
699  const UCalendar* calendarToSet);
700 
712 
722 U_STABLE void U_EXPORT2
724  const UNumberFormat* numberFormatToSet);
725 
735 U_STABLE const char* U_EXPORT2
736 udat_getAvailable(int32_t localeIndex);
737 
746 U_STABLE int32_t U_EXPORT2
747 udat_countAvailable(void);
748 
761  UErrorCode *status);
762 
773 U_STABLE void U_EXPORT2
775  UDate d,
776  UErrorCode *status);
777 
790 U_STABLE int32_t U_EXPORT2
791 udat_toPattern( const UDateFormat *fmt,
792  UBool localized,
793  UChar *result,
794  int32_t resultLength,
795  UErrorCode *status);
796 
807 U_STABLE void U_EXPORT2
809  UBool localized,
810  const UChar *pattern,
811  int32_t patternLength);
812 
817 typedef enum UDateFormatSymbolType {
840  UDAT_STANDALONE_SHORT_MONTHS,
841  UDAT_STANDALONE_NARROW_MONTHS,
844  UDAT_STANDALONE_SHORT_WEEKDAYS,
845  UDAT_STANDALONE_NARROW_WEEKDAYS,
852  UDAT_STANDALONE_SHORT_QUARTERS
853 
855 
856 struct UDateFormatSymbols;
862 
879 U_STABLE int32_t U_EXPORT2
880 udat_getSymbols(const UDateFormat *fmt,
882  int32_t symbolIndex,
883  UChar *result,
884  int32_t resultLength,
885  UErrorCode *status);
886 
899 U_STABLE int32_t U_EXPORT2
900 udat_countSymbols( const UDateFormat *fmt,
901  UDateFormatSymbolType type);
902 
918 U_STABLE void U_EXPORT2
921  int32_t symbolIndex,
922  UChar *value,
923  int32_t valueLength,
924  UErrorCode *status);
925 
935 U_STABLE const char* U_EXPORT2
937  ULocDataLocaleType type,
938  UErrorCode* status);
939 
951 U_INTERNAL int32_t U_EXPORT2
953  UChar *result,
954  int32_t resultLength,
955  UErrorCode *status);
956 
968 U_INTERNAL int32_t U_EXPORT2
970  UChar *result,
971  int32_t resultLength,
972  UErrorCode *status);
973 
986 U_INTERNAL void U_EXPORT2
988  const UChar *datePattern,
989  int32_t datePatternLength,
990  const UChar *timePattern,
991  int32_t timePatternLength,
992  UErrorCode *status);
993 
994 
995 #endif /* #if !UCONFIG_NO_FORMATTING */
996 
997 #endif
int32_t udat_format(const UDateFormat *format, UDate dateToFormat, UChar *result, int32_t resultLength, UFieldPosition *position, UErrorCode *status)
Format a date using an UDateFormat.
void * UCalendar
A calendar.
Definition: ucal.h:153
FieldPosition and UFieldPosition selector for &#39;w&#39; field alignment, corresponding to the UCAL_WEEK_OF_...
Definition: udat.h:355
FieldPosition and UFieldPosition selector for &#39;e&#39; field alignment, corresponding to the UCAL_DOW_LOCA...
Definition: udat.h:409
Standalone context versions of months.
Definition: udat.h:839
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:183
UBool udat_isLenient(const UDateFormat *fmt)
Determine if an UDateFormat will perform lenient parsing.
The localized characters.
Definition: udat.h:831
FieldPosition and UFieldPosition selector for &#39;V&#39; field alignment, corresponding to the UCAL_ZONE_OFF...
Definition: udat.h:485
The narrow weekday names, for example N.
Definition: udat.h:837
FieldPosition selector for &quot;Q&quot; field alignment, corresponding to quarters.
Definition: udat.h:469
C API: Calendar.
FieldPosition and UFieldPosition selector for &#39;M&#39; field alignment, corresponding to the UCAL_MONTH fi...
Definition: udat.h:281
FieldPosition and UFieldPosition selector for &#39;k&#39; field alignment, corresponding to the UCAL_HOUR_OF_...
Definition: udat.h:297
const char * udat_getLocaleByType(const UDateFormat *fmt, ULocDataLocaleType type, UErrorCode *status)
Get the locale for this date format object.
The long era names, for example Anno Domini.
Definition: udat.h:833
void udat_applyPatternRelative(UDateFormat *format, const UChar *datePattern, int32_t datePatternLength, const UChar *timePattern, int32_t timePatternLength, UErrorCode *status)
Set the date &amp; time patterns used by a UDateFormat set for relative date formatting.
Short style.
Definition: udat.h:152
The quarters, for example 1st Quarter.
Definition: udat.h:847
double UDate
Date and Time data type.
Definition: utypes.h:314
No style.
Definition: udat.h:169
Standalone context versions of weekdays.
Definition: udat.h:843
Long style.
Definition: udat.h:148
void udat_setCalendar(UDateFormat *fmt, const UCalendar *calendarToSet)
Set the UCalendar associated with an UDateFormat.
The short month names, for example Feb.
Definition: udat.h:823
#define U_INTERNAL
This is used to declare a function as an internal ICU C API.
Definition: umachine.h:145
Default style.
Definition: udat.h:154
const UNumberFormat * udat_getNumberFormat(const UDateFormat *fmt)
Get the UNumberFormat associated with an UDateFormat.
void udat_setLenient(UDateFormat *fmt, UBool isLenient)
Specify whether an UDateFormat will perform lenient parsing.
FieldPosition and UFieldPosition selector for &#39;g&#39; field alignment, corresponding to the UCAL_JULIAN_D...
Definition: udat.h:423
const UCalendar * udat_getCalendar(const UDateFormat *fmt)
Get the UCalendar associated with an UDateFormat.
Bitfield for relative date.
Definition: udat.h:157
FieldPosition and UFieldPosition selector for &#39;D&#39; field alignment, corresponding to the UCAL_DAY_OF_Y...
Definition: udat.h:341
FieldPosition selector for the &quot;q&quot; field alignment, corresponding to stand-alone quarters.
Definition: udat.h:478
FieldPosition and UFieldPosition selector for &#39;u&#39; field alignment, corresponding to the UCAL_EXTENDED...
Definition: udat.h:416
for internal API use only
Definition: udat.h:171
void udat_setSymbols(UDateFormat *format, UDateFormatSymbolType type, int32_t symbolIndex, UChar *value, int32_t valueLength, UErrorCode *status)
Set the symbols associated with an UDateFormat.
void udat_setNumberFormat(UDateFormat *fmt, const UNumberFormat *numberFormatToSet)
Set the UNumberFormat associated with an UDateFormat.
FieldPosition selector for &#39;c&#39; field alignment, corresponding to the UCAL_DOW_LOCAL field...
Definition: udat.h:452
FieldPosition and UFieldPosition selector for &#39;d&#39; field alignment, corresponding to the UCAL_DATE fie...
Definition: udat.h:288
void udat_close(UDateFormat *format)
Close a UDateFormat.
Full style.
Definition: udat.h:146
FieldPosition and UFieldPosition selector for &#39;Y&#39; field alignment, corresponding to the UCAL_YEAR_WOY...
Definition: udat.h:402
void udat_set2DigitYearStart(UDateFormat *fmt, UDate d, UErrorCode *status)
Set the year relative to which all 2-digit years will be interpreted.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
FieldPosition and UFieldPosition selector for &#39;F&#39; field alignment, corresponding to the UCAL_DAY_OF_W...
Definition: udat.h:348
UDateFormatSymbolType
The possible types of date format symbols.
Definition: udat.h:817
The month names, for example February.
Definition: udat.h:821
void * UNumberFormat
A number formatter.
Definition: unum.h:130
A struct representing a range of text containing a specific field.
Definition: umisc.h:32
FieldPosition and UFieldPosition selector for &#39;A&#39; field alignment, corresponding to the UCAL_MILLISEC...
Definition: udat.h:430
C++ API: &quot;Smart pointers&quot; for use with and in ICU4C C++ code.
void * UDateFormat
A date formatter.
Definition: udat.h:139
int32_t udat_toPatternRelativeDate(const UDateFormat *fmt, UChar *result, int32_t resultLength, UErrorCode *status)
Extract the date pattern from a UDateFormat set for relative date formatting.
FieldPosition and UFieldPosition selector for &#39;v&#39; field alignment, corresponding to the UCAL_ZONE_OFF...
Definition: udat.h:445
The era names, for example AD.
Definition: udat.h:819
FieldPosition and UFieldPosition selector for &#39;W&#39; field alignment, corresponding to the UCAL_WEEK_OF_...
Definition: udat.h:362
The weekday names, for example Monday.
Definition: udat.h:825
UCalendarDateFields udat_toCalendarDateField(UDateFormatField field)
Maps from a UDateFormatField to the corresponding UCalendarDateFields.
struct UDateFormatSymbols UDateFormatSymbols
Date format symbols.
Definition: udat.h:861
UDateFormatStyle
The possible date/time format styles.
Definition: udat.h:144
UDate udat_parse(const UDateFormat *format, const UChar *text, int32_t textLength, int32_t *parsePos, UErrorCode *status)
Parse a string into an date/time using a UDateFormat.
#define U_EXPORT2
Definition: platform.h:314
UDateFormat * udat_open(UDateFormatStyle timeStyle, UDateFormatStyle dateStyle, const char *locale, const UChar *tzID, int32_t tzIDLength, const UChar *pattern, int32_t patternLength, UErrorCode *status)
Open a new UDateFormat for formatting and parsing dates and times.
void udat_applyPattern(UDateFormat *format, UBool localized, const UChar *pattern, int32_t patternLength)
Set the pattern used by an UDateFormat.
FieldPosition and UFieldPosition selector for &#39;E&#39; field alignment, corresponding to the UCAL_DAY_OF_W...
Definition: udat.h:334
int32_t udat_toPattern(const UDateFormat *fmt, UBool localized, UChar *result, int32_t resultLength, UErrorCode *status)
Extract the pattern from a UDateFormat.
FieldPosition and UFieldPosition selector for &#39;a&#39; field alignment, corresponding to the UCAL_AM_PM fi...
Definition: udat.h:369
The short quarter names, for example Q1.
Definition: udat.h:849
FieldPosition and UFieldPosition selector for &#39;K&#39; field alignment, corresponding to the UCAL_HOUR fie...
Definition: udat.h:387
const char * udat_getAvailable(int32_t localeIndex)
Get a locale for which date/time formatting patterns are available.
int32_t udat_getSymbols(const UDateFormat *fmt, UDateFormatSymbolType type, int32_t symbolIndex, UChar *result, int32_t resultLength, UErrorCode *status)
Get the symbols associated with an UDateFormat.
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:325
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
Standalone context versions of quarters.
Definition: udat.h:851
UDateFormatField
FieldPosition and UFieldPosition selectors for format fields defined by DateFormat and UDateFormat...
Definition: udat.h:261
FieldPosition and UFieldPosition selector for &#39;G&#39; field alignment, corresponding to the UCAL_ERA fiel...
Definition: udat.h:267
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:639
UDateFormat * udat_clone(const UDateFormat *fmt, UErrorCode *status)
Open a copy of a UDateFormat.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:336
FieldPosition and UFieldPosition selector for &#39;m&#39; field alignment, corresponding to the UCAL_MINUTE f...
Definition: udat.h:313
int32_t udat_countSymbols(const UDateFormat *fmt, UDateFormatSymbolType type)
Count the number of particular symbols for an UDateFormat.
The narrow month names, for example F.
Definition: udat.h:835
FieldPosition and UFieldPosition selector for &#39;s&#39; field alignment, corresponding to the UCAL_SECOND f...
Definition: udat.h:320
Basic definitions for ICU, for both C and C++ APIs.
The short weekday names, for example Mon.
Definition: udat.h:827
FieldPosition and UFieldPosition selector for &#39;z&#39; field alignment, corresponding to the UCAL_ZONE_OFF...
Definition: udat.h:395
FieldPosition and UFieldPosition selector for &#39;y&#39; field alignment, corresponding to the UCAL_YEAR fie...
Definition: udat.h:274
FieldPosition selector for &#39;L&#39; field alignment, corresponding to the UCAL_MONTH field.
Definition: udat.h:460
The AM/PM names, for example AM.
Definition: udat.h:829
Number of FieldPosition and UFieldPosition selectors for DateFormat and UDateFormat.
Definition: udat.h:495
int32_t udat_toPatternRelativeTime(const UDateFormat *fmt, UChar *result, int32_t resultLength, UErrorCode *status)
Extract the time pattern from a UDateFormat set for relative date formatting.
FieldPosition and UFieldPosition selector for &#39;Z&#39; field alignment, corresponding to the UCAL_ZONE_OFF...
Definition: udat.h:438
UDate udat_get2DigitYearStart(const UDateFormat *fmt, UErrorCode *status)
Get the year relative to which all 2-digit years are interpreted.
int32_t udat_countAvailable(void)
Determine how many locales have date/time formatting patterns available.
FieldPosition and UFieldPosition selector for &#39;H&#39; field alignment, corresponding to the UCAL_HOUR_OF_...
Definition: udat.h:306
FieldPosition and UFieldPosition selector for &#39;S&#39; field alignment, corresponding to the UCAL_MILLISEC...
Definition: udat.h:327
FieldPosition and UFieldPosition selector for &#39;h&#39; field alignment, corresponding to the UCAL_HOUR fie...
Definition: udat.h:378
void udat_parseCalendar(const UDateFormat *format, UCalendar *calendar, const UChar *text, int32_t textLength, int32_t *parsePos, UErrorCode *status)
Parse a string into an date/time using a UDateFormat.
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:137
int8_t UBool
The ICU boolean type.
Definition: umachine.h:228
C API: NumberFormat.
Medium style.
Definition: udat.h:150