138ac8defSOliver Tappe /* 22a5e33a9SAdrien Destugues * Copyright 2010-2014, Haiku, Inc. 338ac8defSOliver Tappe * Distributed under the terms of the MIT Licence. 438ac8defSOliver Tappe */ 538ac8defSOliver Tappe #ifndef _B_DATE_TIME_FORMAT_H_ 638ac8defSOliver Tappe #define _B_DATE_TIME_FORMAT_H_ 738ac8defSOliver Tappe 82a5e33a9SAdrien Destugues 938ac8defSOliver Tappe #include <Format.h> 1038ac8defSOliver Tappe 1138ac8defSOliver Tappe 1238ac8defSOliver Tappe class BString; 134a3a4742SAdrien Destugues class BTimeZone; 144a3a4742SAdrien Destugues 154a3a4742SAdrien Destugues 164a3a4742SAdrien Destugues enum BDateElement { 174a3a4742SAdrien Destugues B_DATE_ELEMENT_INVALID = 0, 184a3a4742SAdrien Destugues B_DATE_ELEMENT_YEAR = 1 << 0, 194a3a4742SAdrien Destugues B_DATE_ELEMENT_MONTH = 1 << 1, 204a3a4742SAdrien Destugues B_DATE_ELEMENT_WEEKDAY = 1 << 2, 214a3a4742SAdrien Destugues B_DATE_ELEMENT_DAY = 1 << 3, 224a3a4742SAdrien Destugues B_DATE_ELEMENT_AM_PM = 1 << 4, 234a3a4742SAdrien Destugues B_DATE_ELEMENT_HOUR = 1 << 5, 244a3a4742SAdrien Destugues B_DATE_ELEMENT_MINUTE = 1 << 6, 254a3a4742SAdrien Destugues B_DATE_ELEMENT_SECOND = 1 << 7, 264a3a4742SAdrien Destugues B_DATE_ELEMENT_TIMEZONE = 1 << 8 274a3a4742SAdrien Destugues }; 284a3a4742SAdrien Destugues 2938ac8defSOliver Tappe 302a5e33a9SAdrien Destugues 3138ac8defSOliver Tappe class BDateTimeFormat : public BFormat { 3238ac8defSOliver Tappe public: 335d5ec05bSAdrien Destugues BDateTimeFormat(const BLocale* locale = NULL); 345d5ec05bSAdrien Destugues BDateTimeFormat(const BLanguage& language, 355d5ec05bSAdrien Destugues const BFormattingConventions& conventions); 3638ac8defSOliver Tappe BDateTimeFormat(const BDateTimeFormat &other); 3738ac8defSOliver Tappe virtual ~BDateTimeFormat(); 3838ac8defSOliver Tappe 394a3a4742SAdrien Destugues void SetDateTimeFormat(BDateFormatStyle dateStyle, 404a3a4742SAdrien Destugues BTimeFormatStyle timeStyle, 414a3a4742SAdrien Destugues int32 elements); 424a3a4742SAdrien Destugues 4338ac8defSOliver Tappe // formatting 4438ac8defSOliver Tappe 45e3857211SAdrien Destugues ssize_t Format(char* target, const size_t maxSize, 46e3857211SAdrien Destugues const time_t time, 47e3857211SAdrien Destugues BDateFormatStyle dateStyle, 48e3857211SAdrien Destugues BTimeFormatStyle timeStyle) const; 49e3857211SAdrien Destugues status_t Format(BString& buffer, const time_t time, 50e3857211SAdrien Destugues BDateFormatStyle dateStyle, 51e3857211SAdrien Destugues BTimeFormatStyle timeStyle, 52e3857211SAdrien Destugues const BTimeZone* timeZone = NULL) const; 5338ac8defSOliver Tappe 54e3857211SAdrien Destugues private: 55*73de5837SJérôme Duval U_ICU_NAMESPACE::DateFormat* _CreateDateTimeFormatter( 56e3857211SAdrien Destugues const BString& format) const; 5738ac8defSOliver Tappe }; 5838ac8defSOliver Tappe 5938ac8defSOliver Tappe 6038ac8defSOliver Tappe #endif // _B_DATE_TIME_FORMAT_H_ 61