ICU 4.2.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-2009, 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/ucal.h"
16 #include "unicode/unum.h"
138 typedef void* UDateFormat;
139 
143 typedef enum UDateFormatStyle {
154 
156  UDAT_RELATIVE = (1 << 7),
157 
158  UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,
159 
160  UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,
161 
162  UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,
163 
164  UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,
165 
166 
168  UDAT_NONE = -1,
171 
173 
174 
206 #define UDAT_MINUTE_SECOND "ms"
207 #define UDAT_HOUR24_MINUTE "Hm"
208 #define UDAT_HOUR24_MINUTE_SECOND "Hms"
209 #define UDAT_HOUR_MINUTE_SECOND "hms"
210 #define UDAT_STANDALONE_MONTH "LLLL"
211 #define UDAT_ABBR_STANDALONE_MONTH "LLL"
212 #define UDAT_YEAR_QUARTER "yQQQ"
213 #define UDAT_YEAR_ABBR_QUARTER "yQ"
214 
224 #define UDAT_HOUR_MINUTE "hm"
225 #define UDAT_YEAR "y"
226 #define UDAT_DAY "d"
227 #define UDAT_NUM_MONTH_WEEKDAY_DAY "MEd"
228 #define UDAT_YEAR_NUM_MONTH "yM"
229 #define UDAT_NUM_MONTH_DAY "Md"
230 #define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd"
231 #define UDAT_ABBR_MONTH_WEEKDAY_DAY "MMMEd"
232 #define UDAT_YEAR_MONTH "yMMMM"
233 #define UDAT_YEAR_ABBR_MONTH "yMMM"
234 #define UDAT_MONTH_DAY "MMMMd"
235 #define UDAT_ABBR_MONTH_DAY "MMMd"
236 #define UDAT_MONTH_WEEKDAY_DAY "MMMMEEEEd"
237 #define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd"
238 #define UDAT_YEAR_MONTH_WEEKDAY_DAY "yMMMMEEEEd"
239 #define UDAT_YEAR_MONTH_DAY "yMMMMd"
240 #define UDAT_YEAR_ABBR_MONTH_DAY "yMMMd"
241 #define UDAT_YEAR_NUM_MONTH_DAY "yMd"
242 #define UDAT_NUM_MONTH "M"
243 #define UDAT_ABBR_MONTH "MMM"
244 #define UDAT_MONTH "MMMM"
245 #define UDAT_HOUR_MINUTE_GENERIC_TZ "hmv"
246 #define UDAT_HOUR_MINUTE_TZ "hmz"
247 #define UDAT_HOUR "h"
248 #define UDAT_HOUR_GENERIC_TZ "hv"
249 #define UDAT_HOUR_TZ "hz"
250 
259 typedef enum UDateFormatField {
266 
273 
280 
287 
296 
305 
312 
319 
326 
333 
340 
347 
354 
361 
368 
377 
386 
394 
401 
408 
415 
422 
429 
437 
451 
459 
468 
477 
484 
494 
496 
519 udat_open(UDateFormatStyle timeStyle,
520  UDateFormatStyle dateStyle,
521  const char *locale,
522  const UChar *tzID,
523  int32_t tzIDLength,
524  const UChar *pattern,
525  int32_t patternLength,
526  UErrorCode *status);
527 
528 
535 U_STABLE void U_EXPORT2
536 udat_close(UDateFormat* format);
537 
547 udat_clone(const UDateFormat *fmt,
548  UErrorCode *status);
549 
569 udat_format( const UDateFormat* format,
570  UDate dateToFormat,
571  UChar* result,
572  int32_t resultLength,
573  UFieldPosition* position,
574  UErrorCode* status);
575 
590 udat_parse( const UDateFormat* format,
591  const UChar* text,
592  int32_t textLength,
593  int32_t *parsePos,
594  UErrorCode *status);
595 
609 U_STABLE void U_EXPORT2
610 udat_parseCalendar(const UDateFormat* format,
611  UCalendar* calendar,
612  const UChar* text,
613  int32_t textLength,
614  int32_t *parsePos,
615  UErrorCode *status);
616 
627 udat_isLenient(const UDateFormat* fmt);
628 
638 U_STABLE void U_EXPORT2
640  UBool isLenient);
641 
652 udat_getCalendar(const UDateFormat* fmt);
653 
663 U_STABLE void U_EXPORT2
665  const UCalendar* calendarToSet);
666 
678 
688 U_STABLE void U_EXPORT2
690  const UNumberFormat* numberFormatToSet);
691 
701 U_STABLE const char* U_EXPORT2
702 udat_getAvailable(int32_t localeIndex);
703 
713 udat_countAvailable(void);
714 
727  UErrorCode *status);
728 
739 U_STABLE void U_EXPORT2
741  UDate d,
742  UErrorCode *status);
743 
757 udat_toPattern( const UDateFormat *fmt,
758  UBool localized,
759  UChar *result,
760  int32_t resultLength,
761  UErrorCode *status);
762 
773 U_STABLE void U_EXPORT2
775  UBool localized,
776  const UChar *pattern,
777  int32_t patternLength);
778 
783 typedef enum UDateFormatSymbolType {
806  UDAT_STANDALONE_SHORT_MONTHS,
807  UDAT_STANDALONE_NARROW_MONTHS,
810  UDAT_STANDALONE_SHORT_WEEKDAYS,
811  UDAT_STANDALONE_NARROW_WEEKDAYS,
818  UDAT_STANDALONE_SHORT_QUARTERS
819 
821 
822 struct UDateFormatSymbols;
828 
846 udat_getSymbols(const UDateFormat *fmt,
848  int32_t symbolIndex,
849  UChar *result,
850  int32_t resultLength,
851  UErrorCode *status);
852 
866 udat_countSymbols( const UDateFormat *fmt,
867  UDateFormatSymbolType type);
868 
884 U_STABLE void U_EXPORT2
887  int32_t symbolIndex,
888  UChar *value,
889  int32_t valueLength,
890  UErrorCode *status);
891 
901 U_STABLE const char* U_EXPORT2
903  ULocDataLocaleType type,
904  UErrorCode* status);
905 
919  UChar *result,
920  int32_t resultLength,
921  UErrorCode *status);
922 
936  UChar *result,
937  int32_t resultLength,
938  UErrorCode *status);
939 
952 U_INTERNAL void U_EXPORT2
954  const UChar *datePattern,
955  int32_t datePatternLength,
956  const UChar *timePattern,
957  int32_t timePatternLength,
958  UErrorCode *status);
959 
960 #endif /* #if !UCONFIG_NO_FORMATTING */
961 
962 #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:146
FieldPosition and UFieldPosition selector for &#39;w&#39; field alignment, corresponding to the UCAL_WEEK_OF_...
Definition: udat.h:353
FieldPosition and UFieldPosition selector for &#39;e&#39; field alignment, corresponding to the UCAL_DOW_LOCA...
Definition: udat.h:407
Standalone context versions of months.
Definition: udat.h:805
UBool udat_isLenient(const UDateFormat *fmt)
Determine if an UDateFormat will perform lenient parsing.
The localized characters.
Definition: udat.h:797
FieldPosition and UFieldPosition selector for &#39;V&#39; field alignment, corresponding to the UCAL_ZONE_OFF...
Definition: udat.h:483
The narrow weekday names, for example N.
Definition: udat.h:803
FieldPosition selector for &quot;Q&quot; field alignment, corresponding to quarters.
Definition: udat.h:467
C API: Calendar.
FieldPosition and UFieldPosition selector for &#39;M&#39; field alignment, corresponding to the UCAL_MONTH fi...
Definition: udat.h:279
FieldPosition and UFieldPosition selector for &#39;k&#39; field alignment, corresponding to the UCAL_HOUR_OF_...
Definition: udat.h:295
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:799
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:151
The quarters, for example 1st Quarter.
Definition: udat.h:813
double UDate
Date and Time data type.
Definition: utypes.h:281
No style.
Definition: udat.h:168
Standalone context versions of weekdays.
Definition: udat.h:809
Long style.
Definition: udat.h:147
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:789
#define U_INTERNAL
This is used to declare a function as an internal ICU C API.
Definition: umachine.h:125
Default style.
Definition: udat.h:153
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:421
const UCalendar * udat_getCalendar(const UDateFormat *fmt)
Get the UCalendar associated with an UDateFormat.
Bitfield for relative date.
Definition: udat.h:156
FieldPosition and UFieldPosition selector for &#39;D&#39; field alignment, corresponding to the UCAL_DAY_OF_Y...
Definition: udat.h:339
FieldPosition selector for the &quot;q&quot; field alignment, corresponding to stand-alone quarters.
Definition: udat.h:476
FieldPosition and UFieldPosition selector for &#39;u&#39; field alignment, corresponding to the UCAL_EXTENDED...
Definition: udat.h:414
for internal API use only
Definition: udat.h:170
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_DATE field.
Definition: udat.h:450
FieldPosition and UFieldPosition selector for &#39;d&#39; field alignment, corresponding to the UCAL_DATE fie...
Definition: udat.h:286
void udat_close(UDateFormat *format)
Close a UDateFormat.
Full style.
Definition: udat.h:145
FieldPosition and UFieldPosition selector for &#39;Y&#39; field alignment, corresponding to the UCAL_YEAR_WOY...
Definition: udat.h:400
void udat_set2DigitYearStart(UDateFormat *fmt, UDate d, UErrorCode *status)
Set the year relative to which all 2-digit years will be interpreted.
FieldPosition and UFieldPosition selector for &#39;F&#39; field alignment, corresponding to the UCAL_DAY_OF_W...
Definition: udat.h:346
UDateFormatSymbolType
The possible types of date format symbols.
Definition: udat.h:783
The month names, for example February.
Definition: udat.h:787
void * UNumberFormat
A number formatter.
Definition: unum.h:129
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:428
void * UDateFormat
A date formatter.
Definition: udat.h:138
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:443
The era names, for example AD.
Definition: udat.h:785
FieldPosition and UFieldPosition selector for &#39;W&#39; field alignment, corresponding to the UCAL_WEEK_OF_...
Definition: udat.h:360
The weekday names, for example Monday.
Definition: udat.h:791
struct UDateFormatSymbols UDateFormatSymbols
Date format symbols.
Definition: udat.h:827
UDateFormatStyle
The possible date/time format styles.
Definition: udat.h:143
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:338
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:332
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:367
The short quarter names, for example Q1.
Definition: udat.h:815
FieldPosition and UFieldPosition selector for &#39;K&#39; field alignment, corresponding to the UCAL_HOUR fie...
Definition: udat.h:385
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:299
Standalone context versions of quarters.
Definition: udat.h:817
UDateFormatField
FieldPosition and UFieldPosition selectors for format fields defined by DateFormat and UDateFormat...
Definition: udat.h:259
FieldPosition and UFieldPosition selector for &#39;G&#39; field alignment, corresponding to the UCAL_ERA fiel...
Definition: udat.h:265
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:593
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:314
FieldPosition and UFieldPosition selector for &#39;m&#39; field alignment, corresponding to the UCAL_MINUTE f...
Definition: udat.h:311
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:801
FieldPosition and UFieldPosition selector for &#39;s&#39; field alignment, corresponding to the UCAL_SECOND f...
Definition: udat.h:318
Basic definitions for ICU, for both C and C++ APIs.
The short weekday names, for example Mon.
Definition: udat.h:793
FieldPosition and UFieldPosition selector for &#39;z&#39; field alignment, corresponding to the UCAL_ZONE_OFF...
Definition: udat.h:393
FieldPosition and UFieldPosition selector for &#39;y&#39; field alignment, corresponding to the UCAL_YEAR fie...
Definition: udat.h:272
FieldPosition selector for &#39;L&#39; field alignment, corresponding to the UCAL_MONTH field.
Definition: udat.h:458
The AM/PM names, for example AM.
Definition: udat.h:795
Number of FieldPosition and UFieldPosition selectors for DateFormat and UDateFormat.
Definition: udat.h:493
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:436
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:304
FieldPosition and UFieldPosition selector for &#39;S&#39; field alignment, corresponding to the UCAL_MILLISEC...
Definition: udat.h:325
FieldPosition and UFieldPosition selector for &#39;h&#39; field alignment, corresponding to the UCAL_HOUR fie...
Definition: udat.h:376
signed int int32_t
Define 64 bit limits.
Definition: pwin32.h:143
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:117
int8_t UBool
The ICU boolean type.
Definition: umachine.h:208
C API: NumberFormat.
Medium style.
Definition: udat.h:149