Import of CCTZ from GitHub.

PiperOrigin-RevId: 450445030
Change-Id: I1c1e5ed67f81a181454f7fc6751bf42a3bc2bc48
pull/1186/head
Abseil Team 3 years ago committed by Copybara-Service
parent 9e408e050f
commit 09eac4d507
  1. 16
      absl/time/internal/cctz/src/time_zone_format_test.cc
  2. 10
      absl/time/internal/cctz/src/time_zone_lookup_test.cc

@ -18,11 +18,15 @@
#include <sstream>
#include <string>
#include "absl/base/config.h"
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
#if defined(__linux__)
#include <features.h>
#endif
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/config.h"
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
namespace chrono = std::chrono;
@ -183,8 +187,10 @@ TEST(Format, PosixConversions) {
TestFormatSpecifier(tp, tz, "%F", "1970-01-01");
TestFormatSpecifier(tp, tz, "%g", "70");
TestFormatSpecifier(tp, tz, "%G", "1970");
#if defined(__GLIBC__)
TestFormatSpecifier(tp, tz, "%k", " 0");
TestFormatSpecifier(tp, tz, "%l", "12");
#endif
TestFormatSpecifier(tp, tz, "%n", "\n");
TestFormatSpecifier(tp, tz, "%R", "00:00");
TestFormatSpecifier(tp, tz, "%t", "\t");
@ -216,7 +222,9 @@ TEST(Format, LocaleSpecific) {
#if defined(__linux__)
// SU/C99/TZ extensions
TestFormatSpecifier(tp, tz, "%h", "Jan"); // Same as %b
#if defined(__GLIBC__)
TestFormatSpecifier(tp, tz, "%P", "am");
#endif
TestFormatSpecifier(tp, tz, "%r", "12:00:00 AM");
// Modified conversion specifiers %E_
@ -1045,9 +1053,11 @@ TEST(Parse, LocaleSpecific) {
EXPECT_TRUE(parse("%h", "Feb", tz, &tp));
EXPECT_EQ(2, convert(tp, tz).month()); // Equivalent to %b
#if defined(__GLIBC__)
tp = reset;
EXPECT_TRUE(parse("%l %p", "5 PM", tz, &tp));
EXPECT_EQ(17, convert(tp, tz).hour());
#endif
tp = reset;
EXPECT_TRUE(parse("%r", "03:44:55 PM", tz, &tp));
@ -1055,6 +1065,7 @@ TEST(Parse, LocaleSpecific) {
EXPECT_EQ(44, convert(tp, tz).minute());
EXPECT_EQ(55, convert(tp, tz).second());
#if defined(__GLIBC__)
tp = reset;
EXPECT_TRUE(parse("%Ec", "Tue Nov 19 05:06:07 2013", tz, &tp));
EXPECT_EQ(convert(civil_second(2013, 11, 19, 5, 6, 7), tz), tp);
@ -1126,6 +1137,7 @@ TEST(Parse, LocaleSpecific) {
EXPECT_TRUE(parse("%Oy", "04", tz, &tp));
EXPECT_EQ(2004, convert(tp, tz).year());
#endif
#endif
}
TEST(Parse, ExtendedSeconds) {

@ -21,10 +21,14 @@
#include <thread>
#include <vector>
#include "gtest/gtest.h"
#include "absl/base/config.h"
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
#include "absl/time/internal/cctz/include/cctz/time_zone.h"
#if defined(__linux__)
#include <features.h>
#endif
#include "gtest/gtest.h"
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
namespace chrono = std::chrono;
@ -1043,7 +1047,7 @@ TEST(MakeTime, LocalTimeLibC) {
// 1) we know how to change the time zone used by localtime()/mktime(),
// 2) cctz and localtime()/mktime() will use similar-enough tzdata, and
// 3) we have some idea about how mktime() behaves during transitions.
#if defined(__linux__) && !defined(__ANDROID__)
#if defined(__linux__) && defined(__GLIBC__) && !defined(__ANDROID__)
const char* const ep = getenv("TZ");
std::string tz_name = (ep != nullptr) ? ep : "";
for (const char* const* np = kTimeZoneNames; *np != nullptr; ++np) {

Loading…
Cancel
Save