1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 1997-2009, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
13 #include "unicode/utypes.h"
15 #if !UCONFIG_NO_FORMATTING
17 #include "unicode/unistr.h"
18 #include "unicode/calendar.h"
19 #include "unicode/datefmt.h"
23 * This class doesn't perform any tests, but provides utility methods to its subclasses.
25 class CalendarTimeZoneTest
: public IntlTest
28 static void cleanup();
30 // Return true if the given status indicates failure. Also has the side effect
31 // of calling errln(). Msg should be of the form "Class::Method" in general.
32 UBool
failure(UErrorCode status
, const char* msg
, UBool possibleDataError
=FALSE
);
34 // Utility method for formatting dates for printing; useful for Java->C++ conversion.
35 // Tries to mimic the Java Date.toString() format.
36 UnicodeString
dateToString(UDate d
);
37 UnicodeString
& dateToString(UDate d
, UnicodeString
& str
);
38 UnicodeString
& dateToString(UDate d
, UnicodeString
& str
, const TimeZone
& z
);
40 // Utility methods to create a date. This is useful for converting Java constructs
41 // which create a Date object. Returns a Date in the current local time.
42 UDate
date(int32_t y
, int32_t m
, int32_t d
, int32_t hr
=0, int32_t min
=0, int32_t sec
=0);
44 // Utility methods to create a date. Returns a Date in UTC. This will differ
45 // from local dates returned by date() by the current default zone offset.
46 // Date utcDate(int y, int m, int d, int hr=0, int min=0, int sec=0);
48 // Utility method to get the fields of a date; similar to Date.getYear() etc.
49 void dateToFields(UDate date
, int32_t& y
, int32_t& m
, int32_t& d
, int32_t& hr
, int32_t& min
, int32_t& sec
);
52 static DateFormat
* fgDateFormat
;
53 static Calendar
* fgCalendar
;
55 // the 'get()' functions are not static because they can call errln().
56 // they are effectively static otherwise.
57 DateFormat
* getDateFormat(void);
58 static void releaseDateFormat(DateFormat
*f
);
60 Calendar
* getCalendar(void);
61 static void releaseCalendar(Calendar
*c
);
64 #endif /* #if !UCONFIG_NO_FORMATTING */