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

- Search for |

- File List
- Globals

# dtitvfmt.h

Go to the documentation of this file.

    00001 /********************************************************************************
    00002 * Copyright (C) 2008-2009, International Business Machines Corporation and others. All Rights Reserved.
    00003 *******************************************************************************
    00004 *
    00005 * File DTITVFMT.H
    00006 *
    00007 *******************************************************************************
    00008 */
    00009
    00010 #ifndef __DTITVFMT_H__
    00011 #define __DTITVFMT_H__
    00012
    00013
    00014 #include "unicode/utypes.h"
    00015
    00021 #if !UCONFIG_NO_FORMATTING
    00022
    00023 #include "unicode/ucal.h"
    00024 #include "unicode/smpdtfmt.h"
    00025 #include "unicode/dtintrv.h"
    00026 #include "unicode/dtitvinf.h"
    00027 #include "unicode/dtptngen.h"
    00028
    00029 U_NAMESPACE_BEGIN
    00030
    00031
    00032
    00218 class U_I18N_API DateIntervalFormat : public Format {
    00219 public:
    00220
    00234     static DateIntervalFormat* U_EXPORT2 createInstance(
    00235                                                const UnicodeString& skeleton,
    00236                                                UErrorCode& status);
    00237
    00267     static DateIntervalFormat* U_EXPORT2 createInstance(
    00268                                                const UnicodeString& skeleton,
    00269                                                const Locale& locale,
    00270                                                UErrorCode& status);
    00271
    00287     static DateIntervalFormat* U_EXPORT2 createInstance(
    00288                                               const UnicodeString& skeleton,
    00289                                               const DateIntervalInfo& dtitvinf,
    00290                                               UErrorCode& status);
    00291
    00327     static DateIntervalFormat* U_EXPORT2 createInstance(
    00328                                               const UnicodeString& skeleton,
    00329                                               const Locale& locale,
    00330                                               const DateIntervalInfo& dtitvinf,
    00331                                               UErrorCode& status);
    00332
    00337     virtual ~DateIntervalFormat();
    00338
    00345     virtual Format* clone(void) const;
    00346
    00354     virtual UBool operator==(const Format& other) const;
    00355
    00363     UBool operator!=(const Format& other) const;
    00364
    00381     virtual UnicodeString& format(const Formattable& obj,
    00382                                   UnicodeString& appendTo,
    00383                                   FieldPosition& fieldPosition,
    00384                                   UErrorCode& status) const ;
    00385
    00386
    00387
    00400     UnicodeString& format(const DateInterval* dtInterval,
    00401                           UnicodeString& appendTo,
    00402                           FieldPosition& fieldPosition,
    00403                           UErrorCode& status) const ;
    00404
    00405
    00426     UnicodeString& format(Calendar& fromCalendar,
    00427                           Calendar& toCalendar,
    00428                           UnicodeString& appendTo,
    00429                           FieldPosition& fieldPosition,
    00430                           UErrorCode& status) const ;
    00431
    00458     virtual void parseObject(const UnicodeString& source,
    00459                              Formattable& result,
    00460                              ParsePosition& parse_pos) const;
    00461
    00462
    00469     const DateIntervalInfo* getDateIntervalInfo(void) const;
    00470
    00471
    00478     void setDateIntervalInfo(const DateIntervalInfo& newIntervalPatterns,
    00479                              UErrorCode& status);
    00480
    00481
    00487     const DateFormat* getDateFormat(void) const;
    00488
    00500     static UClassID U_EXPORT2 getStaticClassID(void);
    00501
    00513     virtual UClassID getDynamicClassID(void) const;
    00514
    00515 protected:
    00516
    00521     DateIntervalFormat(const DateIntervalFormat&);
    00522
    00527     DateIntervalFormat& operator=(const DateIntervalFormat&);
    00528
    00529 private:
    00530
    00531     /*
    00532      * This is for ICU internal use only. Please do not use.
    00533      * Save the interval pattern information.
    00534      * Interval pattern consists of 2 single date patterns and the separator.
    00535      * For example, interval pattern "MMM d - MMM d, yyyy" consists
    00536      * a single date pattern "MMM d", another single date pattern "MMM d, yyyy",
    00537      * and a separator "-".
    00538      * The pattern is divided into 2 parts. For above example,
    00539      * the first part is "MMM d - ", and the second part is "MMM d, yyyy".
    00540      * Also, the first date appears in an interval pattern could be
    00541      * the earlier date or the later date.
    00542      * And such information is saved in the interval pattern as well.
    00543      * @internal ICU 4.0
    00544      */
    00545     struct PatternInfo {
    00546         UnicodeString firstPart;
    00547         UnicodeString secondPart;
    00561         UBool         laterDateFirst;
    00562     };
    00563
    00564
    00569     DateIntervalFormat();
    00570
    00590     DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo,
    00591                        const UnicodeString* skeleton, UErrorCode& status);
    00592
    00593
    00607     static DateIntervalFormat* U_EXPORT2 create(const Locale& locale,
    00608                                                 DateIntervalInfo* dtitvinf,
    00609                                                 const UnicodeString* skeleton,
    00610                                                 UErrorCode& status);
    00611
    00625     static SimpleDateFormat* U_EXPORT2 createSDFPatternInstance(
    00626                                         const UnicodeString& skeleton,
    00627                                         const Locale& locale,
    00628                                         DateTimePatternGenerator* dtpng,
    00629                                         UErrorCode& status);
    00630
    00631
    00655     UnicodeString& fallbackFormat(Calendar& fromCalendar,
    00656                                   Calendar& toCalendar,
    00657                                   UnicodeString& appendTo,
    00658                                   FieldPosition& pos,
    00659                                   UErrorCode& status) const;
    00660
    00661
    00662
    00698     void initializePattern(UErrorCode& status);
    00699
    00700
    00701
    00710     void setFallbackPattern(UCalendarDateFields field,
    00711                             const UnicodeString& skeleton,
    00712                             UErrorCode& status);
    00713
    00714
    00715
    00741     static void  U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton,
    00742                                     UnicodeString& date,
    00743                                     UnicodeString& normalizedDate,
    00744                                     UnicodeString& time,
    00745                                     UnicodeString& normalizedTime);
    00746
    00747
    00748
    00773     UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,
    00774                                  const UnicodeString& timeSkeleton);
    00775
    00776
    00777
    00778
    00803     UBool setIntervalPattern(UCalendarDateFields field,
    00804                              const UnicodeString* skeleton,
    00805                              const UnicodeString* bestSkeleton,
    00806                              int8_t differenceInfo,
    00807                              UnicodeString* extendedSkeleton = NULL,
    00808                              UnicodeString* extendedBestSkeleton = NULL);
    00809
    00839     static void U_EXPORT2 adjustFieldWidth(
    00840                             const UnicodeString& inputSkeleton,
    00841                             const UnicodeString& bestMatchSkeleton,
    00842                             const UnicodeString& bestMatchIntervalPattern,
    00843                             int8_t differenceInfo,
    00844                             UnicodeString& adjustedIntervalPattern);
    00845
    00859     void concatSingleDate2TimeInterval(const UChar* format,
    00860                                        int32_t formatLen,
    00861                                        const UnicodeString& datePattern,
    00862                                        UCalendarDateFields field,
    00863                                        UErrorCode& status);
    00864
    00872     static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field,
    00873                                                  const UnicodeString& skeleton);
    00874
    00875
    00882     static int32_t  U_EXPORT2 splitPatternInto2Part(const UnicodeString& intervalPattern);
    00883
    00884
    00891     void setIntervalPattern(UCalendarDateFields field,
    00892                             const UnicodeString& intervalPattern);
    00893
    00894
    00902     void setIntervalPattern(UCalendarDateFields field,
    00903                             const UnicodeString& intervalPattern,
    00904                             UBool laterDateFirst);
    00905
    00906
    00917     void setPatternInfo(UCalendarDateFields field,
    00918                         const UnicodeString* firstPart,
    00919                         const UnicodeString* secondpart,
    00920                         UBool laterDateFirst);
    00921
    00922
    00923     // from calendar field to pattern letter
    00924     static const UChar fgCalendarFieldToPatternLetter[];
    00925
    00926
    00930     DateIntervalInfo*     fInfo;
    00931
    00935     SimpleDateFormat*     fDateFormat;
    00936
    00942     Calendar* fFromCalendar;
    00943     Calendar* fToCalendar;
    00944
    00948     DateTimePatternGenerator* fDtpng;
    00949
    00953     UnicodeString fSkeleton;
    00954     PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX];
    00955 };
    00956
    00957
    00958
    00959
    00960
    00961
    00962 inline UBool
    00963 DateIntervalFormat::operator!=(const Format& other) const  {
    00964     return !operator==(other);
    00965 }
    00966
    00967 U_NAMESPACE_END
    00968
    00969 #endif /* #if !UCONFIG_NO_FORMATTING */
    00970
    00971 #endif // _DTITVFMT_H__
    00972 //eof