ICU 56.1: dtitvfmt.h Source File

ICU 56.1 56.1

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

- File List
- Globals

dtitvfmt.h
Go to the documentation of this file.
1 /********************************************************************************
2 * Copyright (C) 2008-2013,2015, 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
220 class U_I18N_API DateIntervalFormat : public Format {
221 public:
222
236 static DateIntervalFormat* U_EXPORT2 createInstance(
237 const UnicodeString& skeleton,
238 UErrorCode& status);
239
274 static DateIntervalFormat* U_EXPORT2 createInstance(
275 const UnicodeString& skeleton,
276 const Locale& locale,
277 UErrorCode& status);
278
294 static DateIntervalFormat* U_EXPORT2 createInstance(
295 const UnicodeString& skeleton,
296 const DateIntervalInfo& dtitvinf,
297 UErrorCode& status);
298
339 static DateIntervalFormat* U_EXPORT2 createInstance(
340 const UnicodeString& skeleton,
341 const Locale& locale,
342 const DateIntervalInfo& dtitvinf,
343 UErrorCode& status);
344
349 virtual ~DateIntervalFormat();
350
357 virtual Format* clone(void) const;
358
366 virtual UBool operator==(const Format& other) const;
367
375 UBool operator!=(const Format& other) const;
376
377
378 using Format::format;
379
399 virtual UnicodeString& format(const Formattable& obj,
400 UnicodeString& appendTo,
401 FieldPosition& fieldPosition,
402 UErrorCode& status) const ;
403
404
405
421 UnicodeString& format(const DateInterval* dtInterval,
422 UnicodeString& appendTo,
423 FieldPosition& fieldPosition,
424 UErrorCode& status) const ;
425
426
450 UnicodeString& format(Calendar& fromCalendar,
451 Calendar& toCalendar,
452 UnicodeString& appendTo,
453 FieldPosition& fieldPosition,
454 UErrorCode& status) const ;
455
482 virtual void parseObject(const UnicodeString& source,
483 Formattable& result,
484 ParsePosition& parse_pos) const;
485
486
493 const DateIntervalInfo* getDateIntervalInfo(void) const;
494
495
502 void setDateIntervalInfo(const DateIntervalInfo& newIntervalPatterns,
503 UErrorCode& status);
504
505
511 const DateFormat* getDateFormat(void) const;
512
518 virtual const TimeZone& getTimeZone(void) const;
519
526 virtual void adoptTimeZone(TimeZone* zoneToAdopt);
527
533 virtual void setTimeZone(const TimeZone& zone);
534
546 static UClassID U_EXPORT2 getStaticClassID(void);
547
559 virtual UClassID getDynamicClassID(void) const;
560
561 protected:
562
567 DateIntervalFormat(const DateIntervalFormat&);
568
573 DateIntervalFormat& operator=(const DateIntervalFormat&);
574
575 private:
576
577 /*
578 * This is for ICU internal use only. Please do not use.
579 * Save the interval pattern information.
580 * Interval pattern consists of 2 single date patterns and the separator.
581 * For example, interval pattern "MMM d - MMM d, yyyy" consists
582 * a single date pattern "MMM d", another single date pattern "MMM d, yyyy",
583 * and a separator "-".
584 * The pattern is divided into 2 parts. For above example,
585 * the first part is "MMM d - ", and the second part is "MMM d, yyyy".
586 * Also, the first date appears in an interval pattern could be
587 * the earlier date or the later date.
588 * And such information is saved in the interval pattern as well.
589 */
590 struct PatternInfo {
591 UnicodeString firstPart;
592 UnicodeString secondPart;
606 UBool laterDateFirst;
607 };
608
609
614 DateIntervalFormat();
615
634 DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo,
635 const UnicodeString* skeleton, UErrorCode& status);
636
637
650 static DateIntervalFormat* U_EXPORT2 create(const Locale& locale,
651 DateIntervalInfo* dtitvinf,
652 const UnicodeString* skeleton,
653 UErrorCode& status);
654
675 static void
676 adjustPosition(UnicodeString& combiningPattern, // has {0} and {1} in it
677 UnicodeString& pat0, FieldPosition& pos0, // pattern and pos corresponding to {0}
678 UnicodeString& pat1, FieldPosition& pos1, // pattern and pos corresponding to {1}
679 FieldPosition& posResult);
680
681
701 UnicodeString& fallbackFormat(Calendar& fromCalendar,
702 Calendar& toCalendar,
703 UBool fromToOnSameDay,
704 UnicodeString& appendTo,
705 FieldPosition& pos,
706 UErrorCode& status) const;
707
708
709
744 void initializePattern(UErrorCode& status);
745
746
747
755 void setFallbackPattern(UCalendarDateFields field,
756 const UnicodeString& skeleton,
757 UErrorCode& status);
758
759
760
785 static void U_EXPORT2 getDateTimeSkeleton(const UnicodeString& skeleton,
786 UnicodeString& date,
787 UnicodeString& normalizedDate,
788 UnicodeString& time,
789 UnicodeString& normalizedTime);
790
791
792
816 UBool setSeparateDateTimePtn(const UnicodeString& dateSkeleton,
817 const UnicodeString& timeSkeleton);
818
819
820
821
845 UBool setIntervalPattern(UCalendarDateFields field,
846 const UnicodeString* skeleton,
847 const UnicodeString* bestSkeleton,
848 int8_t differenceInfo,
849 UnicodeString* extendedSkeleton = NULL,
850 UnicodeString* extendedBestSkeleton = NULL);
851
880 static void U_EXPORT2 adjustFieldWidth(
881 const UnicodeString& inputSkeleton,
882 const UnicodeString& bestMatchSkeleton,
883 const UnicodeString& bestMatchIntervalPattern,
884 int8_t differenceInfo,
885 UnicodeString& adjustedIntervalPattern);
886
898 void concatSingleDate2TimeInterval(UnicodeString& format,
899 const UnicodeString& datePattern,
900 UCalendarDateFields field,
901 UErrorCode& status);
902
909 static UBool U_EXPORT2 fieldExistsInSkeleton(UCalendarDateFields field,
910 const UnicodeString& skeleton);
911
912
918 static int32_t U_EXPORT2 splitPatternInto2Part(const UnicodeString& intervalPattern);
919
920
926 void setIntervalPattern(UCalendarDateFields field,
927 const UnicodeString& intervalPattern);
928
929
936 void setIntervalPattern(UCalendarDateFields field,
937 const UnicodeString& intervalPattern,
938 UBool laterDateFirst);
939
940
950 void setPatternInfo(UCalendarDateFields field,
951 const UnicodeString* firstPart,
952 const UnicodeString* secondPart,
953 UBool laterDateFirst);
954
955
956 // from calendar field to pattern letter
957 static const UChar fgCalendarFieldToPatternLetter[];
958
959
963 DateIntervalInfo* fInfo;
964
968 SimpleDateFormat* fDateFormat;
969
975 Calendar* fFromCalendar;
976 Calendar* fToCalendar;
977
978 Locale fLocale;
979
983 UnicodeString fSkeleton;
984 PatternInfo fIntervalPatterns[DateIntervalInfo::kIPI_MAX_INDEX];
985
989 UnicodeString* fDatePattern;
990 UnicodeString* fTimePattern;
991 UnicodeString* fDateTimeFormat;
992 };
993
994 inline UBool
995 DateIntervalFormat::operator!=(const Format& other) const {
996 return !operator==(other);
997 }
998
999 U_NAMESPACE_END
1000
1001 #endif /* #if !UCONFIG_NO_FORMATTING */
1002
1003 #endif // _DTITVFMT_H__
1004 //eof
icu::Format
Base class for all formats.
Definition: format.h:94
UCalendarDateFields
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:183
icu::DateIntervalFormat
DateIntervalFormat is a class for formatting and parsing date intervals in a language-independent man...
Definition: dtitvfmt.h:220
ucal.h
C API: Calendar.
dtptngen.h
C++ API: Date/Time Pattern Generator.
icu::DateIntervalInfo
DateIntervalInfo is a public class for encapsulating localizable date time interval patterns...
Definition: dtitvinf.h:151
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
icu::Calendar
Calendar is an abstract base class for converting between a UDate object and a set of integer fields ...
Definition: calendar.h:200
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
icu::TimeZone
TimeZone represents a time zone offset, and also figures out daylight savings.
Definition: timezone.h:129
icu::DateInterval
This class represents a date interval.
Definition: dtintrv.h:32
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
smpdtfmt.h
C++ API: Format and parse dates in a language-independent manner.
icu::operator!=
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
NULL
#define NULL
Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
Definition: utypes.h:186
icu::Format::format
UnicodeString & format(const Formattable &obj, UnicodeString &appendTo, UErrorCode &status) const
Formats an object to produce a string.
UChar
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:312
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
icu::Format::parseObject
virtual void parseObject(const UnicodeString &source, Formattable &result, ParsePosition &parse_pos) const =0
Parse a string to produce an object.
icu::Format::operator==
virtual UBool operator==(const Format &other) const =0
Return true if the given Format objects are semantically equal.
dtintrv.h
C++ API: Date Interval data type.
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
icu::SimpleDateFormat
SimpleDateFormat is a concrete class for formatting and parsing dates in a language-independent manne...
Definition: smpdtfmt.h:717
icu::FieldPosition
FieldPosition is a simple class used by Format and its subclasses to identify fields in formatted out...
Definition: fieldpos.h:106
icu::ParsePosition
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:47
icu::DateFormat
DateFormat is an abstract class for a family of classes that convert dates and times from their inter...
Definition: datefmt.h:147
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
dtitvinf.h
C++ API: Date/Time interval patterns for formatting date/time interval.
icu::Format::operator=
Format & operator=(const Format &)
icu::Format::operator!=
UBool operator!=(const Format &other) const
Return true if the given Format objects are not semantically equal.
Definition: format.h:119
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:293
icu::Formattable
Formattable objects can be passed to the Format class or its subclasses for formatting.
Definition: fmtable.h:66
icu::Format::clone
virtual Format * clone() const =0
Clone this object polymorphically.
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185