|
1 |
|
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
3 * |
|
4 * This Source Code Form is subject to the terms of the Mozilla Public |
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
7 #ifndef nsDateTimeFormatUnix_h__ |
|
8 #define nsDateTimeFormatUnix_h__ |
|
9 |
|
10 |
|
11 #include "nsICharsetConverterManager.h" |
|
12 #include "nsCOMPtr.h" |
|
13 #include "nsIDateTimeFormat.h" |
|
14 |
|
15 #define kPlatformLocaleLength 64 |
|
16 |
|
17 class nsDateTimeFormatUnix : public nsIDateTimeFormat { |
|
18 |
|
19 public: |
|
20 NS_DECL_THREADSAFE_ISUPPORTS |
|
21 |
|
22 // performs a locale sensitive date formatting operation on the time_t parameter |
|
23 NS_IMETHOD FormatTime(nsILocale* locale, |
|
24 const nsDateFormatSelector dateFormatSelector, |
|
25 const nsTimeFormatSelector timeFormatSelector, |
|
26 const time_t timetTime, |
|
27 nsAString& stringOut); |
|
28 |
|
29 // performs a locale sensitive date formatting operation on the struct tm parameter |
|
30 NS_IMETHOD FormatTMTime(nsILocale* locale, |
|
31 const nsDateFormatSelector dateFormatSelector, |
|
32 const nsTimeFormatSelector timeFormatSelector, |
|
33 const struct tm* tmTime, |
|
34 nsAString& stringOut); |
|
35 |
|
36 // performs a locale sensitive date formatting operation on the PRTime parameter |
|
37 NS_IMETHOD FormatPRTime(nsILocale* locale, |
|
38 const nsDateFormatSelector dateFormatSelector, |
|
39 const nsTimeFormatSelector timeFormatSelector, |
|
40 const PRTime prTime, |
|
41 nsAString& stringOut); |
|
42 |
|
43 // performs a locale sensitive date formatting operation on the PRExplodedTime parameter |
|
44 NS_IMETHOD FormatPRExplodedTime(nsILocale* locale, |
|
45 const nsDateFormatSelector dateFormatSelector, |
|
46 const nsTimeFormatSelector timeFormatSelector, |
|
47 const PRExplodedTime* explodedTime, |
|
48 nsAString& stringOut); |
|
49 |
|
50 |
|
51 nsDateTimeFormatUnix() {mLocale.Truncate();mAppLocale.Truncate();} |
|
52 |
|
53 virtual ~nsDateTimeFormatUnix() {} |
|
54 |
|
55 private: |
|
56 // init this interface to a specified locale |
|
57 NS_IMETHOD Initialize(nsILocale* locale); |
|
58 |
|
59 void LocalePreferred24hour(); |
|
60 |
|
61 nsString mLocale; |
|
62 nsString mAppLocale; |
|
63 nsCString mCharset; // in order to convert API result to unicode |
|
64 nsCString mPlatformLocale; // for setlocale |
|
65 bool mLocalePreferred24hour; // true if 24 hour format is preferred by current locale |
|
66 bool mLocaleAMPMfirst; // true if AM/PM string is preferred before the time |
|
67 nsCOMPtr <nsIUnicodeDecoder> mDecoder; |
|
68 }; |
|
69 |
|
70 #endif /* nsDateTimeFormatUnix_h__ */ |