Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds civil-time classes and new time-zone interfaces. These are being proposed for C++ standardization.
- Loading branch information
Showing
40 changed files
with
3,201 additions
and
1,588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
# Copyright 2016 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
### libraries | ||
|
||
cc_library( | ||
name = "cctz", | ||
srcs = [ | ||
"src/time_zone_format.cc", | ||
"src/time_zone_if.cc", | ||
"src/time_zone_if.h", | ||
"src/time_zone_impl.cc", | ||
"src/time_zone_impl.h", | ||
"src/time_zone_info.cc", | ||
"src/time_zone_info.h", | ||
"src/time_zone_libc.cc", | ||
"src/time_zone_libc.h", | ||
"src/time_zone_lookup.cc", | ||
"src/time_zone_posix.cc", | ||
"src/time_zone_posix.h", | ||
"src/tzfile.h", | ||
], | ||
hdrs = [ | ||
"src/civil_time.h", | ||
"src/time_zone.h", | ||
], | ||
includes = ["src"], | ||
linkopts = [ | ||
"-lm", | ||
"-lpthread", | ||
], | ||
textual_hdrs = ["src/civil_time_detail.h"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
### tests | ||
|
||
# Builds the Google Test source that was fetched from another repository. | ||
cc_library( | ||
name = "gtest", | ||
srcs = glob( | ||
[ | ||
"google*/src/*.cc", | ||
], | ||
exclude = glob([ | ||
"google*/src/*-all.cc", | ||
"googlemock/src/gmock_main.cc", | ||
]), | ||
), | ||
hdrs = glob(["*/include/**/*.h"]), | ||
includes = [ | ||
"googlemock/", | ||
"googlemock/include", | ||
"googletest/", | ||
"googletest/include", | ||
], | ||
linkopts = ["-pthread"], | ||
textual_hdrs = ["googletest/src/gtest-internal-inl.h"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_test( | ||
name = "civil_time_test", | ||
size = "small", | ||
srcs = ["src/civil_time_test.cc"], | ||
deps = [ | ||
"@gtest//:gtest", | ||
":cctz", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "time_zone_format_test", | ||
size = "small", | ||
srcs = ["src/time_zone_format_test.cc"], | ||
deps = [ | ||
"@gtest//:gtest", | ||
":cctz", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "time_zone_lookup_test", | ||
size = "small", | ||
srcs = ["src/time_zone_lookup_test.cc"], | ||
deps = [ | ||
"@gtest//:gtest", | ||
":cctz", | ||
], | ||
) | ||
|
||
### examples | ||
|
||
cc_binary( | ||
name = "classic", | ||
srcs = ["examples/classic.cc"], | ||
) | ||
|
||
cc_binary( | ||
name = "epoch_shift", | ||
srcs = ["examples/epoch_shift.cc"], | ||
deps = [ | ||
":cctz", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "example1", | ||
srcs = ["examples/example1.cc"], | ||
deps = [ | ||
":cctz", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "example2", | ||
srcs = ["examples/example2.cc"], | ||
deps = [ | ||
":cctz", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "example3", | ||
srcs = ["examples/example3.cc"], | ||
deps = [ | ||
":cctz", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "example4", | ||
srcs = ["examples/example4.cc"], | ||
deps = [ | ||
":cctz", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "hello", | ||
srcs = ["examples/hello.cc"], | ||
deps = [ | ||
":cctz", | ||
], | ||
) | ||
|
||
### binaries | ||
|
||
cc_binary( | ||
name = "time_tool", | ||
srcs = ["src/time_tool.cc"], | ||
deps = [ | ||
":cctz", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
Want to contribute? Great! First, read this page (including the small print at the end). | ||
Want to contribute? Great! First, read this page (including the small print at | ||
the end). | ||
|
||
### Before you contribute | ||
Before we can use your code, you must sign the | ||
[Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1) | ||
(CLA), which you can do online. The CLA is necessary mainly because you own the | ||
copyright to your changes, even after your contribution becomes part of our | ||
codebase, so we need your permission to use and distribute your code. We also | ||
need to be sure of various other things—for instance that you'll tell us if you | ||
know that your code infringes on other people's patents. You don't have to sign | ||
the CLA until after you've submitted your code for review and a member has | ||
approved it, but you must do it before we can put your code into our codebase. | ||
Before you start working on a larger contribution, you should get in touch with | ||
us first through the issue tracker with your idea so that we can help out and | ||
possibly guide you. Coordinating up front makes it much easier to avoid | ||
frustration later on. | ||
|
||
Before we can use your code, you must sign the [Google Individual Contributor | ||
License Agreement] | ||
(https://developers.google.com/open-source/cla/individual?csw=1) (CLA), which | ||
you can do online. The CLA is necessary mainly because you own the copyright to | ||
your changes, even after your contribution becomes part of our codebase, so we | ||
need your permission to use and distribute your code. We also need to be sure of | ||
various other things—for instance that you'll tell us if you know that | ||
your code infringes on other people's patents. You don't have to sign the CLA | ||
until after you've submitted your code for review and a member has approved it, | ||
but you must do it before we can put your code into our codebase. Before you | ||
start working on a larger contribution, you should get in touch with us first | ||
through the issue tracker with your idea so that we can help out and possibly | ||
guide you. Coordinating up front makes it much easier to avoid frustration later | ||
on. | ||
|
||
### Code reviews | ||
|
||
All submissions, including submissions by project members, require review. We | ||
use Github pull requests for this purpose. | ||
|
||
### The small print | ||
Contributions made by corporations are covered by a different agreement than | ||
the one above, the Software Grant and Corporate Contributor License Agreement. | ||
|
||
Contributions made by corporations are covered by a different agreement than the | ||
one above, the Software Grant and Corporate Contributor License Agreement. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Copyright 2016 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
CC = $(CXX) | ||
OPT = -g | ||
# TEST_FLAGS = | ||
# TEST_LIBS = | ||
CPPFLAGS = -Isrc $(TEST_FLAGS) -Wall -std=c++11 -pthread $(OPT) -fPIC | ||
VPATH = examples:src | ||
LDFLAGS = -pthread | ||
LDLIBS = $(TEST_LIBS) -lm | ||
ARFLAGS = rcs | ||
PREFIX = /usr/local | ||
|
||
CCTZ_LIB = libcctz.a | ||
|
||
CCTZ_HDRS = \ | ||
civil_time.h \ | ||
civil_time_detail.h \ | ||
time_zone.h | ||
|
||
CCTZ_OBJS = \ | ||
time_zone_format.o \ | ||
time_zone_if.o \ | ||
time_zone_impl.o \ | ||
time_zone_info.o \ | ||
time_zone_libc.o \ | ||
time_zone_lookup.o \ | ||
time_zone_posix.o | ||
|
||
# TESTS = civil_time_test time_zone_lookup_test time_zone_format_test | ||
TOOLS = time_tool | ||
EXAMPLES = classic epoch_shift hello example1 example2 example3 example4 | ||
|
||
all: $(TESTS) $(TOOLS) $(EXAMPLES) | ||
|
||
$(TESTS) $(TOOLS) $(EXAMPLES): $(CCTZ_LIB) | ||
|
||
$(CCTZ_LIB): $(CCTZ_OBJS) | ||
$(AR) $(ARFLAGS) $@ $(CCTZ_OBJS) | ||
|
||
install: $(CCTZ_HDRS) $(CCTZ_LIB) | ||
sudo cp -p $(CCTZ_HDRS) $(PREFIX)/include | ||
sudo cp -p $(CCTZ_LIB) $(PREFIX)/lib | ||
|
||
clean: | ||
@$(RM) $(EXAMPLES:=.o) $(EXAMPLES) | ||
@$(RM) $(TOOLS:=.o) $(TOOLS) | ||
@$(RM) $(TESTS:=.o) $(TESTS) | ||
@$(RM) $(CCTZ_OBJS) $(CCTZ_LIB) | ||
|
||
# dependencies | ||
|
||
time_zone_format.o: time_zone.h civil_time.h time_zone_if.h | ||
time_zone_if.o: time_zone_if.h time_zone.h civil_time.h \ | ||
time_zone_info.h time_zone_libc.h tzfile.h | ||
time_zone_impl.o: time_zone_impl.h time_zone.h civil_time.h \ | ||
time_zone_info.h time_zone_if.h tzfile.h | ||
time_zone_info.o: time_zone_info.h time_zone.h civil_time.h \ | ||
time_zone_posix.h time_zone_if.h tzfile.h | ||
time_zone_libc.o: time_zone_libc.h time_zone.h civil_time.h \ | ||
time_zone_if.h | ||
time_zone_lookup.o: time_zone.h civil_time.h \ | ||
time_zone_impl.h time_zone_info.h time_zone_if.h tzfile.h | ||
time_zone_posix.o: time_zone_posix.h | ||
|
||
civil_time_test.o: civil_time.h | ||
time_zone_lookup_test.o: time_zone.h civil_time.h | ||
time_zone_format_test.o: time_zone.h civil_time.h | ||
|
||
time_tool.o: time_zone.h civil_time.h | ||
|
||
hello.o: time_zone.h civil_time.h | ||
example1.o: time_zone.h civil_time.h | ||
example2.o: time_zone.h civil_time.h | ||
example3.o: time_zone.h civil_time.h | ||
example4.o: time_zone.h civil_time.h | ||
|
||
civil_time.h: civil_time_detail.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.