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

- File List
- Globals

# dtitvfmt.h

Go to the documentation of this file.

    00001 /********************************************************************************
    00002 * Copyright (C) 2008-2010, International Business Machines Corporation and
    00003 * others. All Rights Reserved.
    00004 *******************************************************************************
    00005 *
    00006 * File DTITVFMT.H
    00007 *
    00008 *******************************************************************************
    00009 */
    00010
    00011 #ifndef __DTITVFMT_H__
    00012 #define __DTITVFMT_H__
    00013
    00014
    00015 #include "unicode/utypes.h"
    00016
    00022 #if !UCONFIG_NO_FORMATTING
    00023
    00024 #include "unicode/ucal.h"
    00025 #include "unicode/smpdtfmt.h"
    00026 #include "unicode/dtintrv.h"
    00027 #include "unicode/dtitvinf.h"
    00028 #include "unicode/dtptngen.h"
    00029
    00030 U_NAMESPACE_BEGIN
    00031
    00032
    00033
    00219 class U_I18N_API DateIntervalFormat : public Format {
    00220 public:
    00221
    00235     static DateIntervalFormat* U_EXPORT2 createInstance(
    00236                                                const UnicodeString& skeleton,
    00237                                                UErrorCode& status);
    00238
    00268     static DateIntervalFormat* U_EXPORT2 createInstance(
    00269                                                const UnicodeString& skeleton,
    00270                                                const Locale& locale,
    00271                                                UErrorCode& status);
    00272
    00288     static DateIntervalFormat* U_EXPORT2 createInstance(
    00289                                               const UnicodeString& skeleton,
    00290                                               const DateIntervalInfo& dtitvinf,
    00291                                               UErrorCode& status);
    00292
    00328     static DateIntervalFormat* U_EXPORT2 createInstance(
    00329                                               const UnicodeString& skeleton,
    00330                                               const Locale& locale,
    00331                                               const DateIntervalInfo& dtitvinf,
    00332                                               UErrorCode& status);
    00333
    00338     virtual ~DateIntervalFormat();
    00339
    00346     virtual Format* clone(void) const;
    00347
    00355     virtual UBool operator==(const Format& other) const;
    00356
    00364     UBool operator!=(const Format& other) const;
    00365
    00366
    00367     using Format::format;
    00368
    00385     virtual UnicodeString& format(const Formattable& obj,
    00386                                   UnicodeString& appendTo,
    00387                                   FieldPosition& fieldPosition,
    00388                                   UErrorCode& status) const ;
    00389
    00390
    00391
    00404     UnicodeString& format(const DateInterval* dtInterval,
    00405                           UnicodeString& appendTo,
    00406                           FieldPosition& fieldPosition,
    00407                           UErrorCode& status) const ;
    00408
    00409
    00430     UnicodeString& format(Calendar& fromCalendar,
    00431                           Calendar& toCalendar,
    00432                           UnicodeString& appendTo,
    00433                           FieldPosition& fieldPosition,
    00434                           UErrorCode& status) const ;
    00435
    00462     virtual void parseObject(const UnicodeString& source,
    00463                              Formattable& result,
    00464                              ParsePosition& parse_pos) const;
    00465
    00466
    00473     const DateIntervalInfo* getDateIntervalInfo(void) const;
    00474
    00475
    00482     void setDateIntervalInfo(const DateIntervalInfo& newIntervalPatterns,
    00483                              UErrorCode& status);
    00484
    00485
    00491     const DateFormat* getDateFormat(void) const;
    00492
    00504     static UClassID U_EXPORT2 getStaticClassID(void);
    00505
    00517     virtual UClassID getDynamicClassID(void) const;
    00518
    00519 protected:
    00520
    00525     DateIntervalFormat(const DateIntervalFormat&);
    00526
    00531     DateIntervalFormat& operator=(const DateIntervalFormat&);
    00532
    00533 private:
    00534
    00535     /*
    00536      * This is for ICU internal use only. Please do not use.
    00537      * Save the interval pattern information.
    00538      * Interval pattern consists of 2 single date patterns and the separator.
    00539      * For example, interval pattern "MMM d - MMM d, yyyy" consists
    00540      * a single date pattern "MMM d", another single date pattern "MMM d, yyyy",
    00541      * and a separator "-".
    00542      * The pattern is divided into 2 parts. For above example,
    00543      * the first part is "MMM d - ", and the second part is "MMM d, yyyy".
    00544      * Also, the first date appears in an interval pattern could be
    00545      * the earlier date or the later date.
    00546      * And such information is saved in the interval pattern as well.
    00547      * @internal ICU 4.0
    00548      */
    00549     struct PatternInfo {
    00550         UnicodeString firstPart;
    00551         UnicodeString secondPart;
    00565         UBool         laterDateFirst;
    00566     };
    00567
    00568
    00573     DateIntervalFormat();
    00574
    00594     DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo,
    00595                        const UnicodeString* skeleton, UErrorCode& status);
    00596
    00597
    00611     static DateIntervalFormat* U_EXPORT2 create(const Locale& locale,
    00612                                                 DateIntervalInfo* dtitvinf,
    00613                                                 const UnicodeString* skeleton,
    00614                                                 UErrorCode& status);
    00615
    00629     static SimpleDateFormat* U_EXPORT2 createSDFPatternInstance(
    00630                                         const UnicodeString& skeleton,
    00631                                         const Locale& locale,
    00632                                         DateTimePatternGenerator* dtpng,
    00633                                         UErrorCode& status);
    00634
    00635
    00659     UnicodeString& fallbackFormat(Calendar& fromCalendar,
    00660                                   Calendar& toCalendar,
    00661                                   UnicodeString& appendTo,
    00662                                   FieldPosition& pos,
    00663                                   UErrorCode& status) const;
    00664
    00665
    00666
    00702     void initializePattern(UErrorCode& status);
    00703
    00704
    00705
    00714     void setFallbackPattern(UCalendarDateFields field,
    00715                             const UnicodeString& skeleton,
    00716                             UErrorCode& status);
    00717
    00718
    00719
    00745     static void  U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton,
    00746                                     UnicodeString& date,
    00747                                     UnicodeString& normalizedDate,
    00748                                     UnicodeString& time,
    00749                                     UnicodeString& normalizedTime);
    00750
    00751
    00752
    00777     UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,
    00778                                  const UnicodeString& timeSkeleton);
    00779
    00780
    00781
    00782
    00807     UBool setIntervalPattern(UCalendarDateFields field,
    00808                              const UnicodeString* skeleton,
    00809                              const UnicodeString* bestSkeleton,
    00810                              int8_t differenceInfo,
    00811                              UnicodeString* extendedSkeleton = NULL,
    00812                              UnicodeString* extendedBestSkeleton = NULL);
    00813
    00843     static void U_EXPORT2 adjustFieldWidth(
    00844                             const UnicodeString& inputSkeleton,
    00845                             const UnicodeString& bestMatchSkeleton,
    00846                             const UnicodeString& bestMatchIntervalPattern,
    00847                             int8_t differenceInfo,
    00848                             UnicodeString& adjustedIntervalPattern);
    00849
    00863     void concatSingleDate2TimeInterval(const UChar* format,
    00864                                        int32_t formatLen,
    00865                                        const UnicodeString& datePattern,
    00866                                        UCalendarDateFields field,
    00867                                        UErrorCode& status);
    00868
    00876     static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field,
    00877                                                  const UnicodeString& skeleton);
    00878
    00879
    00886     static int32_t  U_EXPORT2 splitPatternInto2Part(const UnicodeString& intervalPattern);
    00887
    00888
    00895     void setIntervalPattern(UCalendarDateFields field,
    00896                             const UnicodeString& intervalPattern);
    00897
    00898
    00906     void setIntervalPattern(UCalendarDateFields field,
    00907                             const UnicodeString& intervalPattern,
    00908                             UBool laterDateFirst);
    00909
    00910
    00921     void setPatternInfo(UCalendarDateFields field,
    00922                         const UnicodeString* firstPart,
    00923                         const UnicodeString* secondpart,
    00924                         UBool laterDateFirst);
    00925
    00926
    00927     // from calendar field to pattern letter
    00928     static const UChar fgCalendarFieldToPatternLetter[];
    00929
    00930
    00934     DateIntervalInfo*     fInfo;
    00935
    00939     SimpleDateFormat*     fDateFormat;
    00940
    00946     Calendar* fFromCalendar;
    00947     Calendar* fToCalendar;
    00948
    00952     DateTimePatternGenerator* fDtpng;
    00953
    00957     UnicodeString fSkeleton;
    00958     PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX];
    00959 };
    00960
    00961 inline UBool
    00962 DateIntervalFormat::operator!=(const Format& other) const  {
    00963     return !operator==(other);
    00964 }
    00965
    00966 U_NAMESPACE_END
    00967
    00968 #endif /* #if !UCONFIG_NO_FORMATTING */
    00969
    00970 #endif // _DTITVFMT_H__
    00971 //eof

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines