|
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 nsDateTimeFormatWin_h__ |
|
8 #define nsDateTimeFormatWin_h__ |
|
9 |
|
10 |
|
11 #include "nsIDateTimeFormat.h" |
|
12 #include <windows.h> |
|
13 |
|
14 |
|
15 // Locale sensitive date and time format interface |
|
16 // |
|
17 class nsDateTimeFormatWin : 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 nsDateTimeFormatWin() {mLocale.SetLength(0);mAppLocale.SetLength(0);} |
|
51 |
|
52 |
|
53 virtual ~nsDateTimeFormatWin() {} |
|
54 |
|
55 private: |
|
56 // init this interface to a specified locale |
|
57 NS_IMETHOD Initialize(nsILocale* locale); |
|
58 |
|
59 // call GetTimeFormatW or TimeFormatA |
|
60 int nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTime, |
|
61 const char* format, char16_t *timeStr, int cchTime); |
|
62 |
|
63 // call GetDateFormatW or GetDateFormatA |
|
64 int nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDate, |
|
65 const char* format, char16_t *dateStr, int cchDate); |
|
66 |
|
67 nsString mLocale; |
|
68 nsString mAppLocale; |
|
69 uint32_t mLCID; // Windows platform locale ID |
|
70 }; |
|
71 |
|
72 #endif /* nsDateTimeFormatWin_h__ */ |