nsDateTimeFormatWin.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #ifndef nsDateTimeFormatWin_h__
  7. #define nsDateTimeFormatWin_h__
  8. #include "nsIDateTimeFormat.h"
  9. #include <windows.h>
  10. // Locale sensitive date and time format interface
  11. //
  12. class nsDateTimeFormatWin : public nsIDateTimeFormat {
  13. virtual ~nsDateTimeFormatWin() {}
  14. public:
  15. NS_DECL_THREADSAFE_ISUPPORTS
  16. // performs a locale sensitive date formatting operation on the time_t parameter
  17. NS_IMETHOD FormatTime(nsILocale* locale,
  18. const nsDateFormatSelector dateFormatSelector,
  19. const nsTimeFormatSelector timeFormatSelector,
  20. const time_t timetTime,
  21. nsAString& stringOut);
  22. // performs a locale sensitive date formatting operation on the struct tm parameter
  23. NS_IMETHOD FormatTMTime(nsILocale* locale,
  24. const nsDateFormatSelector dateFormatSelector,
  25. const nsTimeFormatSelector timeFormatSelector,
  26. const struct tm* tmTime,
  27. nsAString& stringOut);
  28. // performs a locale sensitive date formatting operation on the PRTime parameter
  29. NS_IMETHOD FormatPRTime(nsILocale* locale,
  30. const nsDateFormatSelector dateFormatSelector,
  31. const nsTimeFormatSelector timeFormatSelector,
  32. const PRTime prTime,
  33. nsAString& stringOut);
  34. // performs a locale sensitive date formatting operation on the PRExplodedTime parameter
  35. NS_IMETHOD FormatPRExplodedTime(nsILocale* locale,
  36. const nsDateFormatSelector dateFormatSelector,
  37. const nsTimeFormatSelector timeFormatSelector,
  38. const PRExplodedTime* explodedTime,
  39. nsAString& stringOut);
  40. nsDateTimeFormatWin() {mLocale.SetLength(0);mAppLocale.SetLength(0);}
  41. private:
  42. // init this interface to a specified locale
  43. NS_IMETHOD Initialize(nsILocale* locale);
  44. // call GetTimeFormatW or TimeFormatA
  45. int nsGetTimeFormatW(DWORD dwFlags, const SYSTEMTIME *lpTime,
  46. const char* format, char16_t *timeStr, int cchTime);
  47. // call GetDateFormatW or GetDateFormatA
  48. int nsGetDateFormatW(DWORD dwFlags, const SYSTEMTIME *lpDate,
  49. const char* format, char16_t *dateStr, int cchDate);
  50. nsString mLocale;
  51. nsString mAppLocale;
  52. uint32_t mLCID; // Windows platform locale ID
  53. };
  54. #endif /* nsDateTimeFormatWin_h__ */