File: hello.cc

package info (click to toggle)
cctz 2.4%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 756 kB
  • sloc: cpp: 8,193; makefile: 62; ansic: 17; sh: 16
file content (39 lines) | stat: -rw-r--r-- 1,264 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// 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
//
//   https://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.

#include <chrono>
#include <iostream>
#include <string>

#include "cctz/civil_time.h"
#include "cctz/time_zone.h"

int main() {
  cctz::time_zone syd;
  if (!cctz::load_time_zone("Australia/Sydney", &syd)) return -1;

  // Neil Armstrong first walks on the moon
  const auto tp1 =
      cctz::convert(cctz::civil_second(1969, 7, 21, 12, 56, 0), syd);

  const std::string s = cctz::format("%Y-%m-%d %H:%M:%S %z", tp1, syd);
  std::cout << s << "\n";

  cctz::time_zone nyc;
  cctz::load_time_zone("America/New_York", &nyc);

  const auto tp2 =
      cctz::convert(cctz::civil_second(1969, 7, 20, 22, 56, 0), nyc);
  return tp2 == tp1 ? 0 : 1;
}