Commit b9b082ba authored by estade@chromium.org's avatar estade@chromium.org

Add a timezone utility file to base/.

Currently there's just one function exported, which checks the system timezone and returns a 2-character ASCII country code for it.

BUG=303368

Review URL: https://codereview.chromium.org/26315008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235823 0039d316-1c4b-4281-b951-d872f2087c98
parent 1bd1f989
......@@ -347,6 +347,8 @@
'i18n/string_search.h',
'i18n/time_formatting.cc',
'i18n/time_formatting.h',
'i18n/timezone.cc',
'i18n/timezone.h',
],
},
{
......@@ -529,6 +531,7 @@
'i18n/rtl_unittest.cc',
'i18n/string_search_unittest.cc',
'i18n/time_formatting_unittest.cc',
'i18n/timezone_unittest.cc',
'ini_parser_unittest.cc',
'ios/device_util_unittest.mm',
'json/json_parser_unittest.cc',
......
This diff is collapsed.
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_I18N_TIMEZONE_H_
#define BASE_I18N_TIMEZONE_H_
#include <string>
#include "base/i18n/base_i18n_export.h"
namespace base {
// Checks the system timezone and turns it into a two-character ASCII country
// code. If this fails for some reason (for example, it will always fail on
// Android), it will return an empty string.
BASE_I18N_EXPORT std::string CountryCodeForCurrentTimezone();
} // namespace base
#endif // BASE_TIME_TIMEZONE_H_
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/i18n/timezone.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
namespace {
#if defined(OS_ANDROID)
// icu's timezone utility doesn't work on Android.
#define MAYBE_CountryCodeForCurrentTimezone DISABLED_CountryCodeForCurrentTimezone
#else
#define MAYBE_CountryCodeForCurrentTimezone CountryCodeForCurrentTimezone
#endif
TEST(TimezoneTest, MAYBE_CountryCodeForCurrentTimezone) {
std::string country_code = CountryCodeForCurrentTimezone();
EXPECT_EQ(2U, country_code.size());
}
} // namespace
} // namespace base
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment