1999-01-27 00:19:24 +00:00
|
|
|
|
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-01-27 00:19:24 +00:00
|
|
|
#ifndef nsDateTimeFormatUnix_h__
|
|
|
|
#define nsDateTimeFormatUnix_h__
|
|
|
|
|
|
|
|
|
2001-02-22 23:27:53 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-01-27 00:19:24 +00:00
|
|
|
#include "nsIDateTimeFormat.h"
|
2014-05-08 09:32:00 +00:00
|
|
|
#include "nsIUnicodeDecoder.h"
|
1999-01-27 00:19:24 +00:00
|
|
|
|
1999-09-10 18:34:06 +00:00
|
|
|
#define kPlatformLocaleLength 64
|
1999-01-27 00:19:24 +00:00
|
|
|
|
|
|
|
class nsDateTimeFormatUnix : public nsIDateTimeFormat {
|
|
|
|
|
|
|
|
public:
|
2013-07-19 02:23:32 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
1999-01-27 00:19:24 +00:00
|
|
|
|
|
|
|
// performs a locale sensitive date formatting operation on the time_t parameter
|
1999-02-03 01:35:11 +00:00
|
|
|
NS_IMETHOD FormatTime(nsILocale* locale,
|
1999-01-27 00:19:24 +00:00
|
|
|
const nsDateFormatSelector dateFormatSelector,
|
|
|
|
const nsTimeFormatSelector timeFormatSelector,
|
|
|
|
const time_t timetTime,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsAString& stringOut) override;
|
1999-01-27 00:19:24 +00:00
|
|
|
|
|
|
|
// performs a locale sensitive date formatting operation on the struct tm parameter
|
1999-02-03 01:35:11 +00:00
|
|
|
NS_IMETHOD FormatTMTime(nsILocale* locale,
|
1999-01-27 00:19:24 +00:00
|
|
|
const nsDateFormatSelector dateFormatSelector,
|
|
|
|
const nsTimeFormatSelector timeFormatSelector,
|
|
|
|
const struct tm* tmTime,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsAString& stringOut) override;
|
1999-01-27 00:19:24 +00:00
|
|
|
|
1999-07-14 16:53:17 +00:00
|
|
|
// performs a locale sensitive date formatting operation on the PRTime parameter
|
|
|
|
NS_IMETHOD FormatPRTime(nsILocale* locale,
|
|
|
|
const nsDateFormatSelector dateFormatSelector,
|
|
|
|
const nsTimeFormatSelector timeFormatSelector,
|
|
|
|
const PRTime prTime,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsAString& stringOut) override;
|
1999-07-14 16:53:17 +00:00
|
|
|
|
|
|
|
// performs a locale sensitive date formatting operation on the PRExplodedTime parameter
|
|
|
|
NS_IMETHOD FormatPRExplodedTime(nsILocale* locale,
|
|
|
|
const nsDateFormatSelector dateFormatSelector,
|
|
|
|
const nsTimeFormatSelector timeFormatSelector,
|
|
|
|
const PRExplodedTime* explodedTime,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsAString& stringOut) override;
|
1999-07-14 16:53:17 +00:00
|
|
|
|
1999-09-10 18:34:06 +00:00
|
|
|
|
2003-01-08 20:50:04 +00:00
|
|
|
nsDateTimeFormatUnix() {mLocale.Truncate();mAppLocale.Truncate();}
|
1999-09-10 18:34:06 +00:00
|
|
|
|
2014-06-23 22:40:02 +00:00
|
|
|
private:
|
1999-09-10 18:34:06 +00:00
|
|
|
virtual ~nsDateTimeFormatUnix() {}
|
|
|
|
|
|
|
|
// init this interface to a specified locale
|
|
|
|
NS_IMETHOD Initialize(nsILocale* locale);
|
|
|
|
|
2002-06-19 02:32:43 +00:00
|
|
|
void LocalePreferred24hour();
|
2000-03-16 22:59:43 +00:00
|
|
|
|
1999-09-10 18:34:06 +00:00
|
|
|
nsString mLocale;
|
|
|
|
nsString mAppLocale;
|
2003-06-11 18:16:03 +00:00
|
|
|
nsCString mCharset; // in order to convert API result to unicode
|
|
|
|
nsCString mPlatformLocale; // for setlocale
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mLocalePreferred24hour; // true if 24 hour format is preferred by current locale
|
|
|
|
bool mLocaleAMPMfirst; // true if AM/PM string is preferred before the time
|
2001-02-22 23:27:53 +00:00
|
|
|
nsCOMPtr <nsIUnicodeDecoder> mDecoder;
|
1999-01-27 00:19:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsDateTimeFormatUnix_h__ */
|