23 #ifndef __ccxx_DateTimeFormat_hxx 24 #define __ccxx_DateTimeFormat_hxx 109 String timeFormat =
"%T");
116 { _parseFormat(format, _dateTimeFormat); }
120 { _parseFormat(dateFormat, _dateFormat); }
124 { _parseFormat(timeFormat, _timeFormat); }
142 size_t format(
const Date& value,
char* buf,
size_t bufsz)
const;
160 size_t format(
const Time& value,
char* buf,
size_t bufsz)
const;
178 size_t format(
const DateTime& value,
char* buf,
size_t bufsz)
const;
187 void parse(
Date& value,
const String& text)
const;
196 void parse(
Time& value,
const String& text)
const;
211 static String _monthNames[12];
212 static String _monthNamesLong[12];
213 static String _weekdayNames[7];
214 static String _weekdayNamesLong[7];
215 static String _meridiemUpper[2];
216 static String _meridiemLower[2];
217 static bool _cacheStrings();
218 static bool _stringsCached;
220 enum TokenCode { TOK_INVALID = -1, TOK_LITERAL = 0, TOK_HOURS,
221 TOK_HOURS12, TOK_MINUTES, TOK_SECONDS, TOK_MSEC,
222 TOK_AMPM_LOWER, TOK_AMPM_UPPER, TOK_MONTH, TOK_DAY,
223 TOK_DAYNUM, TOK_YEAR, TOK_YEAR_4, TOK_WEEKDAY,
224 TOK_WEEKNUM, TOK_TZ, TOK_DATE, TOK_TIME };
226 enum TokenFormat { FMT_INVALID = -1, FMT_NUMERIC, FMT_NUMERIC_0,
227 FMT_NUMERIC_SPC, FMT_STRING, FMT_STRING_LONG };
239 Token(TokenCode token, TokenFormat format,
const char* text = NULL,
241 : _token(token), _format(format)
245 _text =
new char[len + 1];
246 std::memcpy(_text, text, len);
258 inline TokenCode getType()
const 261 inline TokenFormat getFormat()
const 264 inline const char *getText()
const 270 TokenFormat format)
const;
271 void _parseFormat(
const String& format, TokenList* tokens);
272 String _format(
const TokenList* tokens,
const DateTime& value)
const;
273 size_t _format(
const TokenList* tokens,
const DateTime& value,
275 void _parse(
const TokenList* tokens,
DateTime& value,
const char* buf)
const;
277 int _parseInt(
const char*& p,
uint_t& pos,
int min,
int max)
const;
278 int _parseString(
const char*& p,
uint_t& pos,
const String* list,
280 void _skip(
const char*& p,
uint_t& pos,
uint_t count)
const;
282 TokenList* _dateFormat;
283 TokenList* _timeFormat;
284 TokenList* _dateTimeFormat;
289 #endif // __ccxx_DateTimeFormat_hxx
A representation of a calendar date.
Definition: Date.h++:35
A utility class for constructing C-style strings.
Definition: CStringBuilder.h++:42
unsigned int uint_t
An alias for unsigned int.
Definition: Integers.h++:74
A representation of a clock time.
Definition: Time.h++:37
#define COMMONCPP_API
Definition: Common.h++:126
A flexible, reference counted, copy-on-write, thread-safe, nullable string.
Definition: String.h++:50
A representation of a calendar date and clock time.
Definition: DateTime.h++:38
#define NUL
The NUL character (ASCII value 0).
Definition: Common.h++:240
Definition: AllocationMap.c++:25