ICU 54.1 54.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dtitvfmt.h
Go to the documentation of this file.
1 /********************************************************************************
2 * Copyright (C) 2008-2013, International Business Machines Corporation and
3 * others. All Rights Reserved.
4 *******************************************************************************
5 *
6 * File DTITVFMT.H
7 *
8 *******************************************************************************
9 */
10
11 #ifndef __DTITVFMT_H__
12 #define __DTITVFMT_H__
13
14
15 #include "unicode/utypes.h"
16
22 #if !UCONFIG_NO_FORMATTING
23
24 #include "unicode/ucal.h"
25 #include "unicode/smpdtfmt.h"
26 #include "unicode/dtintrv.h"
27 #include "unicode/dtitvinf.h"
28 #include "unicode/dtptngen.h"
29
30 U_NAMESPACE_BEGIN
31
32
33
218 class U_I18N_API DateIntervalFormat : public Format {
219 public:
220
234 static DateIntervalFormat* U_EXPORT2 createInstance(
235 const UnicodeString& skeleton,
236 UErrorCode& status);
237
272 static DateIntervalFormat* U_EXPORT2 createInstance(
273 const UnicodeString& skeleton,
274 const Locale& locale,
275 UErrorCode& status);
276
292 static DateIntervalFormat* U_EXPORT2 createInstance(
293 const UnicodeString& skeleton,
294 const DateIntervalInfo& dtitvinf,
295 UErrorCode& status);
296
337 static DateIntervalFormat* U_EXPORT2 createInstance(
338 const UnicodeString& skeleton,
339 const Locale& locale,
340 const DateIntervalInfo& dtitvinf,
341 UErrorCode& status);
342
347 virtual ~DateIntervalFormat();
348
355 virtual Format* clone(void) const;
356
364 virtual UBool operator==(const Format& other) const;
365
373 UBool operator!=(const Format& other) const;
374
375
376 using Format::format;
377
394 virtual UnicodeString& format(const Formattable& obj,
395 UnicodeString& appendTo,
396 FieldPosition& fieldPosition,
397 UErrorCode& status) const ;
398
399
400
413 UnicodeString& format(const DateInterval* dtInterval,
414 UnicodeString& appendTo,
415 FieldPosition& fieldPosition,
416 UErrorCode& status) const ;
417
418
439 UnicodeString& format(Calendar& fromCalendar,
440 Calendar& toCalendar,
441 UnicodeString& appendTo,
442 FieldPosition& fieldPosition,
443 UErrorCode& status) const ;
444
471 virtual void parseObject(const UnicodeString& source,
472 Formattable& result,
473 ParsePosition& parse_pos) const;
474
475
482 const DateIntervalInfo* getDateIntervalInfo(void) const;
483
484
491 void setDateIntervalInfo(const DateIntervalInfo& newIntervalPatterns,
492 UErrorCode& status);
493
494
500 const DateFormat* getDateFormat(void) const;
501
507 virtual const TimeZone& getTimeZone(void) const;
508
515 virtual void adoptTimeZone(TimeZone* zoneToAdopt);
516
522 virtual void setTimeZone(const TimeZone& zone);
523
535 static UClassID U_EXPORT2 getStaticClassID(void);
536
548 virtual UClassID getDynamicClassID(void) const;
549
550 protected:
551
556 DateIntervalFormat(const DateIntervalFormat&);
557
562 DateIntervalFormat& operator=(const DateIntervalFormat&);
563
564 private:
565
566 /*
567 * This is for ICU internal use only. Please do not use.
568 * Save the interval pattern information.
569 * Interval pattern consists of 2 single date patterns and the separator.
570 * For example, interval pattern "MMM d - MMM d, yyyy" consists
571 * a single date pattern "MMM d", another single date pattern "MMM d, yyyy",
572 * and a separator "-".
573 * The pattern is divided into 2 parts. For above example,
574 * the first part is "MMM d - ", and the second part is "MMM d, yyyy".
575 * Also, the first date appears in an interval pattern could be
576 * the earlier date or the later date.
577 * And such information is saved in the interval pattern as well.
578 */
579 struct PatternInfo {
580 UnicodeString firstPart;
581 UnicodeString secondPart;
595 UBool laterDateFirst;
596 };
597
598
603 DateIntervalFormat();
604
623 DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo,
624 const UnicodeString* skeleton, UErrorCode& status);
625
626
639 static DateIntervalFormat* U_EXPORT2 create(const Locale& locale,
640 DateIntervalInfo* dtitvinf,
641 const UnicodeString* skeleton,
642 UErrorCode& status);
643
656 static SimpleDateFormat* U_EXPORT2 createSDFPatternInstance(
657 const UnicodeString& skeleton,
658 const Locale& locale,
659 DateTimePatternGenerator* dtpng,
660 UErrorCode& status);
661
662
685 UnicodeString& fallbackFormat(Calendar& fromCalendar,
686 Calendar& toCalendar,
687 UnicodeString& appendTo,
688 FieldPosition& pos,
689 UErrorCode& status) const;
690
691
692
727 void initializePattern(UErrorCode& status);
728
729
730
738 void setFallbackPattern(UCalendarDateFields field,
739 const UnicodeString& skeleton,
740 UErrorCode& status);
741
742
743
768 static void U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton,
769 UnicodeString& date,
770 UnicodeString& normalizedDate,
771 UnicodeString& time,
772 UnicodeString& normalizedTime);
773
774
775
799 UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,
800 const UnicodeString& timeSkeleton);
801
802
803
804
828 UBool setIntervalPattern(UCalendarDateFields field,
829 const UnicodeString* skeleton,
830 const UnicodeString* bestSkeleton,
831 int8_t differenceInfo,
832 UnicodeString* extendedSkeleton = NULL,
833 UnicodeString* extendedBestSkeleton = NULL);
834
863 static void U_EXPORT2 adjustFieldWidth(
864 const UnicodeString& inputSkeleton,
865 const UnicodeString& bestMatchSkeleton,
866 const UnicodeString& bestMatchIntervalPattern,
867 int8_t differenceInfo,
868 UnicodeString& adjustedIntervalPattern);
869
882 void concatSingleDate2TimeInterval(const UChar* format,
883 int32_t formatLen,
884 const UnicodeString& datePattern,
885 UCalendarDateFields field,
886 UErrorCode& status);
887
894 static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field,
895 const UnicodeString& skeleton);
896
897
903 static int32_t U_EXPORT2 splitPatternInto2Part(const UnicodeString& intervalPattern);
904
905
911 void setIntervalPattern(UCalendarDateFields field,
912 const UnicodeString& intervalPattern);
913
914
921 void setIntervalPattern(UCalendarDateFields field,
922 const UnicodeString& intervalPattern,
923 UBool laterDateFirst);
924
925
935 void setPatternInfo(UCalendarDateFields field,
936 const UnicodeString* firstPart,
937 const UnicodeString* secondPart,
938 UBool laterDateFirst);
939
940
941 // from calendar field to pattern letter
942 static const UChar fgCalendarFieldToPatternLetter[];
943
944
948 DateIntervalInfo* fInfo;
949
953 SimpleDateFormat* fDateFormat;
954
960 Calendar* fFromCalendar;
961 Calendar* fToCalendar;
962
966 DateTimePatternGenerator* fDtpng;
967
971 UnicodeString fSkeleton;
972 PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX];
973 };
974
975 inline UBool
976 DateIntervalFormat::operator!=(const Format& other) const {
977 return !operator==(other);
978 }
979
980 U_NAMESPACE_END
981
982 #endif /* #if !UCONFIG_NO_FORMATTING */
983
984 #endif // _DTITVFMT_H__
985 //eof