time_zone_lookup_test.cc 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447
  1. // Copyright 2016 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "cctz/time_zone.h"
  15. #include <chrono>
  16. #include <cstddef>
  17. #include <cstdlib>
  18. #include <future>
  19. #include <limits>
  20. #include <string>
  21. #include <thread>
  22. #include <vector>
  23. #include "cctz/civil_time.h"
  24. #include "gtest/gtest.h"
  25. namespace chrono = std::chrono;
  26. namespace cctz {
  27. namespace {
  28. // A list of known time-zone names.
  29. const char* const kTimeZoneNames[] = {
  30. "Africa/Abidjan",
  31. "Africa/Accra",
  32. "Africa/Addis_Ababa",
  33. "Africa/Algiers",
  34. "Africa/Asmara",
  35. "Africa/Asmera",
  36. "Africa/Bamako",
  37. "Africa/Bangui",
  38. "Africa/Banjul",
  39. "Africa/Bissau",
  40. "Africa/Blantyre",
  41. "Africa/Brazzaville",
  42. "Africa/Bujumbura",
  43. "Africa/Cairo",
  44. "Africa/Casablanca",
  45. "Africa/Ceuta",
  46. "Africa/Conakry",
  47. "Africa/Dakar",
  48. "Africa/Dar_es_Salaam",
  49. "Africa/Djibouti",
  50. "Africa/Douala",
  51. "Africa/El_Aaiun",
  52. "Africa/Freetown",
  53. "Africa/Gaborone",
  54. "Africa/Harare",
  55. "Africa/Johannesburg",
  56. "Africa/Juba",
  57. "Africa/Kampala",
  58. "Africa/Khartoum",
  59. "Africa/Kigali",
  60. "Africa/Kinshasa",
  61. "Africa/Lagos",
  62. "Africa/Libreville",
  63. "Africa/Lome",
  64. "Africa/Luanda",
  65. "Africa/Lubumbashi",
  66. "Africa/Lusaka",
  67. "Africa/Malabo",
  68. "Africa/Maputo",
  69. "Africa/Maseru",
  70. "Africa/Mbabane",
  71. "Africa/Mogadishu",
  72. "Africa/Monrovia",
  73. "Africa/Nairobi",
  74. "Africa/Ndjamena",
  75. "Africa/Niamey",
  76. "Africa/Nouakchott",
  77. "Africa/Ouagadougou",
  78. "Africa/Porto-Novo",
  79. "Africa/Sao_Tome",
  80. "Africa/Timbuktu",
  81. "Africa/Tripoli",
  82. "Africa/Tunis",
  83. "Africa/Windhoek",
  84. "America/Adak",
  85. "America/Anchorage",
  86. "America/Anguilla",
  87. "America/Antigua",
  88. "America/Araguaina",
  89. "America/Argentina/Buenos_Aires",
  90. "America/Argentina/Catamarca",
  91. "America/Argentina/ComodRivadavia",
  92. "America/Argentina/Cordoba",
  93. "America/Argentina/Jujuy",
  94. "America/Argentina/La_Rioja",
  95. "America/Argentina/Mendoza",
  96. "America/Argentina/Rio_Gallegos",
  97. "America/Argentina/Salta",
  98. "America/Argentina/San_Juan",
  99. "America/Argentina/San_Luis",
  100. "America/Argentina/Tucuman",
  101. "America/Argentina/Ushuaia",
  102. "America/Aruba",
  103. "America/Asuncion",
  104. "America/Atikokan",
  105. "America/Atka",
  106. "America/Bahia",
  107. "America/Bahia_Banderas",
  108. "America/Barbados",
  109. "America/Belem",
  110. "America/Belize",
  111. "America/Blanc-Sablon",
  112. "America/Boa_Vista",
  113. "America/Bogota",
  114. "America/Boise",
  115. "America/Buenos_Aires",
  116. "America/Cambridge_Bay",
  117. "America/Campo_Grande",
  118. "America/Cancun",
  119. "America/Caracas",
  120. "America/Catamarca",
  121. "America/Cayenne",
  122. "America/Cayman",
  123. "America/Chicago",
  124. "America/Chihuahua",
  125. "America/Coral_Harbour",
  126. "America/Cordoba",
  127. "America/Costa_Rica",
  128. "America/Creston",
  129. "America/Cuiaba",
  130. "America/Curacao",
  131. "America/Danmarkshavn",
  132. "America/Dawson",
  133. "America/Dawson_Creek",
  134. "America/Denver",
  135. "America/Detroit",
  136. "America/Dominica",
  137. "America/Edmonton",
  138. "America/Eirunepe",
  139. "America/El_Salvador",
  140. "America/Ensenada",
  141. "America/Fort_Nelson",
  142. "America/Fort_Wayne",
  143. "America/Fortaleza",
  144. "America/Glace_Bay",
  145. "America/Godthab",
  146. "America/Goose_Bay",
  147. "America/Grand_Turk",
  148. "America/Grenada",
  149. "America/Guadeloupe",
  150. "America/Guatemala",
  151. "America/Guayaquil",
  152. "America/Guyana",
  153. "America/Halifax",
  154. "America/Havana",
  155. "America/Hermosillo",
  156. "America/Indiana/Indianapolis",
  157. "America/Indiana/Knox",
  158. "America/Indiana/Marengo",
  159. "America/Indiana/Petersburg",
  160. "America/Indiana/Tell_City",
  161. "America/Indiana/Vevay",
  162. "America/Indiana/Vincennes",
  163. "America/Indiana/Winamac",
  164. "America/Indianapolis",
  165. "America/Inuvik",
  166. "America/Iqaluit",
  167. "America/Jamaica",
  168. "America/Jujuy",
  169. "America/Juneau",
  170. "America/Kentucky/Louisville",
  171. "America/Kentucky/Monticello",
  172. "America/Knox_IN",
  173. "America/Kralendijk",
  174. "America/La_Paz",
  175. "America/Lima",
  176. "America/Los_Angeles",
  177. "America/Louisville",
  178. "America/Lower_Princes",
  179. "America/Maceio",
  180. "America/Managua",
  181. "America/Manaus",
  182. "America/Marigot",
  183. "America/Martinique",
  184. "America/Matamoros",
  185. "America/Mazatlan",
  186. "America/Mendoza",
  187. "America/Menominee",
  188. "America/Merida",
  189. "America/Metlakatla",
  190. "America/Mexico_City",
  191. "America/Miquelon",
  192. "America/Moncton",
  193. "America/Monterrey",
  194. "America/Montevideo",
  195. "America/Montreal",
  196. "America/Montserrat",
  197. "America/Nassau",
  198. "America/New_York",
  199. "America/Nipigon",
  200. "America/Nome",
  201. "America/Noronha",
  202. "America/North_Dakota/Beulah",
  203. "America/North_Dakota/Center",
  204. "America/North_Dakota/New_Salem",
  205. "America/Nuuk",
  206. "America/Ojinaga",
  207. "America/Panama",
  208. "America/Pangnirtung",
  209. "America/Paramaribo",
  210. "America/Phoenix",
  211. "America/Port-au-Prince",
  212. "America/Port_of_Spain",
  213. "America/Porto_Acre",
  214. "America/Porto_Velho",
  215. "America/Puerto_Rico",
  216. "America/Punta_Arenas",
  217. "America/Rainy_River",
  218. "America/Rankin_Inlet",
  219. "America/Recife",
  220. "America/Regina",
  221. "America/Resolute",
  222. "America/Rio_Branco",
  223. "America/Rosario",
  224. "America/Santa_Isabel",
  225. "America/Santarem",
  226. "America/Santiago",
  227. "America/Santo_Domingo",
  228. "America/Sao_Paulo",
  229. "America/Scoresbysund",
  230. "America/Shiprock",
  231. "America/Sitka",
  232. "America/St_Barthelemy",
  233. "America/St_Johns",
  234. "America/St_Kitts",
  235. "America/St_Lucia",
  236. "America/St_Thomas",
  237. "America/St_Vincent",
  238. "America/Swift_Current",
  239. "America/Tegucigalpa",
  240. "America/Thule",
  241. "America/Thunder_Bay",
  242. "America/Tijuana",
  243. "America/Toronto",
  244. "America/Tortola",
  245. "America/Vancouver",
  246. "America/Virgin",
  247. "America/Whitehorse",
  248. "America/Winnipeg",
  249. "America/Yakutat",
  250. "America/Yellowknife",
  251. "Antarctica/Casey",
  252. "Antarctica/Davis",
  253. "Antarctica/DumontDUrville",
  254. "Antarctica/Macquarie",
  255. "Antarctica/Mawson",
  256. "Antarctica/McMurdo",
  257. "Antarctica/Palmer",
  258. "Antarctica/Rothera",
  259. "Antarctica/South_Pole",
  260. "Antarctica/Syowa",
  261. "Antarctica/Troll",
  262. "Antarctica/Vostok",
  263. "Arctic/Longyearbyen",
  264. "Asia/Aden",
  265. "Asia/Almaty",
  266. "Asia/Amman",
  267. "Asia/Anadyr",
  268. "Asia/Aqtau",
  269. "Asia/Aqtobe",
  270. "Asia/Ashgabat",
  271. "Asia/Ashkhabad",
  272. "Asia/Atyrau",
  273. "Asia/Baghdad",
  274. "Asia/Bahrain",
  275. "Asia/Baku",
  276. "Asia/Bangkok",
  277. "Asia/Barnaul",
  278. "Asia/Beirut",
  279. "Asia/Bishkek",
  280. "Asia/Brunei",
  281. "Asia/Calcutta",
  282. "Asia/Chita",
  283. "Asia/Choibalsan",
  284. "Asia/Chongqing",
  285. "Asia/Chungking",
  286. "Asia/Colombo",
  287. "Asia/Dacca",
  288. "Asia/Damascus",
  289. "Asia/Dhaka",
  290. "Asia/Dili",
  291. "Asia/Dubai",
  292. "Asia/Dushanbe",
  293. "Asia/Famagusta",
  294. "Asia/Gaza",
  295. "Asia/Harbin",
  296. "Asia/Hebron",
  297. "Asia/Ho_Chi_Minh",
  298. "Asia/Hong_Kong",
  299. "Asia/Hovd",
  300. "Asia/Irkutsk",
  301. "Asia/Istanbul",
  302. "Asia/Jakarta",
  303. "Asia/Jayapura",
  304. "Asia/Jerusalem",
  305. "Asia/Kabul",
  306. "Asia/Kamchatka",
  307. "Asia/Karachi",
  308. "Asia/Kashgar",
  309. "Asia/Kathmandu",
  310. "Asia/Katmandu",
  311. "Asia/Khandyga",
  312. "Asia/Kolkata",
  313. "Asia/Krasnoyarsk",
  314. "Asia/Kuala_Lumpur",
  315. "Asia/Kuching",
  316. "Asia/Kuwait",
  317. "Asia/Macao",
  318. "Asia/Macau",
  319. "Asia/Magadan",
  320. "Asia/Makassar",
  321. "Asia/Manila",
  322. "Asia/Muscat",
  323. "Asia/Nicosia",
  324. "Asia/Novokuznetsk",
  325. "Asia/Novosibirsk",
  326. "Asia/Omsk",
  327. "Asia/Oral",
  328. "Asia/Phnom_Penh",
  329. "Asia/Pontianak",
  330. "Asia/Pyongyang",
  331. "Asia/Qatar",
  332. "Asia/Qostanay",
  333. "Asia/Qyzylorda",
  334. "Asia/Rangoon",
  335. "Asia/Riyadh",
  336. "Asia/Saigon",
  337. "Asia/Sakhalin",
  338. "Asia/Samarkand",
  339. "Asia/Seoul",
  340. "Asia/Shanghai",
  341. "Asia/Singapore",
  342. "Asia/Srednekolymsk",
  343. "Asia/Taipei",
  344. "Asia/Tashkent",
  345. "Asia/Tbilisi",
  346. "Asia/Tehran",
  347. "Asia/Tel_Aviv",
  348. "Asia/Thimbu",
  349. "Asia/Thimphu",
  350. "Asia/Tokyo",
  351. "Asia/Tomsk",
  352. "Asia/Ujung_Pandang",
  353. "Asia/Ulaanbaatar",
  354. "Asia/Ulan_Bator",
  355. "Asia/Urumqi",
  356. "Asia/Ust-Nera",
  357. "Asia/Vientiane",
  358. "Asia/Vladivostok",
  359. "Asia/Yakutsk",
  360. "Asia/Yangon",
  361. "Asia/Yekaterinburg",
  362. "Asia/Yerevan",
  363. "Atlantic/Azores",
  364. "Atlantic/Bermuda",
  365. "Atlantic/Canary",
  366. "Atlantic/Cape_Verde",
  367. "Atlantic/Faeroe",
  368. "Atlantic/Faroe",
  369. "Atlantic/Jan_Mayen",
  370. "Atlantic/Madeira",
  371. "Atlantic/Reykjavik",
  372. "Atlantic/South_Georgia",
  373. "Atlantic/St_Helena",
  374. "Atlantic/Stanley",
  375. "Australia/ACT",
  376. "Australia/Adelaide",
  377. "Australia/Brisbane",
  378. "Australia/Broken_Hill",
  379. "Australia/Canberra",
  380. "Australia/Currie",
  381. "Australia/Darwin",
  382. "Australia/Eucla",
  383. "Australia/Hobart",
  384. "Australia/LHI",
  385. "Australia/Lindeman",
  386. "Australia/Lord_Howe",
  387. "Australia/Melbourne",
  388. "Australia/NSW",
  389. "Australia/North",
  390. "Australia/Perth",
  391. "Australia/Queensland",
  392. "Australia/South",
  393. "Australia/Sydney",
  394. "Australia/Tasmania",
  395. "Australia/Victoria",
  396. "Australia/West",
  397. "Australia/Yancowinna",
  398. "Brazil/Acre",
  399. "Brazil/DeNoronha",
  400. "Brazil/East",
  401. "Brazil/West",
  402. "CET",
  403. "CST6CDT",
  404. "Canada/Atlantic",
  405. "Canada/Central",
  406. "Canada/Eastern",
  407. "Canada/Mountain",
  408. "Canada/Newfoundland",
  409. "Canada/Pacific",
  410. "Canada/Saskatchewan",
  411. "Canada/Yukon",
  412. "Chile/Continental",
  413. "Chile/EasterIsland",
  414. "Cuba",
  415. "EET",
  416. "EST",
  417. "EST5EDT",
  418. "Egypt",
  419. "Eire",
  420. "Etc/GMT",
  421. "Etc/GMT+0",
  422. "Etc/GMT+1",
  423. "Etc/GMT+10",
  424. "Etc/GMT+11",
  425. "Etc/GMT+12",
  426. "Etc/GMT+2",
  427. "Etc/GMT+3",
  428. "Etc/GMT+4",
  429. "Etc/GMT+5",
  430. "Etc/GMT+6",
  431. "Etc/GMT+7",
  432. "Etc/GMT+8",
  433. "Etc/GMT+9",
  434. "Etc/GMT-0",
  435. "Etc/GMT-1",
  436. "Etc/GMT-10",
  437. "Etc/GMT-11",
  438. "Etc/GMT-12",
  439. "Etc/GMT-13",
  440. "Etc/GMT-14",
  441. "Etc/GMT-2",
  442. "Etc/GMT-3",
  443. "Etc/GMT-4",
  444. "Etc/GMT-5",
  445. "Etc/GMT-6",
  446. "Etc/GMT-7",
  447. "Etc/GMT-8",
  448. "Etc/GMT-9",
  449. "Etc/GMT0",
  450. "Etc/Greenwich",
  451. "Etc/UCT",
  452. "Etc/UTC",
  453. "Etc/Universal",
  454. "Etc/Zulu",
  455. "Europe/Amsterdam",
  456. "Europe/Andorra",
  457. "Europe/Astrakhan",
  458. "Europe/Athens",
  459. "Europe/Belfast",
  460. "Europe/Belgrade",
  461. "Europe/Berlin",
  462. "Europe/Bratislava",
  463. "Europe/Brussels",
  464. "Europe/Bucharest",
  465. "Europe/Budapest",
  466. "Europe/Busingen",
  467. "Europe/Chisinau",
  468. "Europe/Copenhagen",
  469. "Europe/Dublin",
  470. "Europe/Gibraltar",
  471. "Europe/Guernsey",
  472. "Europe/Helsinki",
  473. "Europe/Isle_of_Man",
  474. "Europe/Istanbul",
  475. "Europe/Jersey",
  476. "Europe/Kaliningrad",
  477. "Europe/Kiev",
  478. "Europe/Kirov",
  479. "Europe/Lisbon",
  480. "Europe/Ljubljana",
  481. "Europe/London",
  482. "Europe/Luxembourg",
  483. "Europe/Madrid",
  484. "Europe/Malta",
  485. "Europe/Mariehamn",
  486. "Europe/Minsk",
  487. "Europe/Monaco",
  488. "Europe/Moscow",
  489. "Europe/Nicosia",
  490. "Europe/Oslo",
  491. "Europe/Paris",
  492. "Europe/Podgorica",
  493. "Europe/Prague",
  494. "Europe/Riga",
  495. "Europe/Rome",
  496. "Europe/Samara",
  497. "Europe/San_Marino",
  498. "Europe/Sarajevo",
  499. "Europe/Saratov",
  500. "Europe/Simferopol",
  501. "Europe/Skopje",
  502. "Europe/Sofia",
  503. "Europe/Stockholm",
  504. "Europe/Tallinn",
  505. "Europe/Tirane",
  506. "Europe/Tiraspol",
  507. "Europe/Ulyanovsk",
  508. "Europe/Uzhgorod",
  509. "Europe/Vaduz",
  510. "Europe/Vatican",
  511. "Europe/Vienna",
  512. "Europe/Vilnius",
  513. "Europe/Volgograd",
  514. "Europe/Warsaw",
  515. "Europe/Zagreb",
  516. "Europe/Zaporozhye",
  517. "Europe/Zurich",
  518. "GB",
  519. "GB-Eire",
  520. "GMT",
  521. "GMT+0",
  522. "GMT-0",
  523. "GMT0",
  524. "Greenwich",
  525. "HST",
  526. "Hongkong",
  527. "Iceland",
  528. "Indian/Antananarivo",
  529. "Indian/Chagos",
  530. "Indian/Christmas",
  531. "Indian/Cocos",
  532. "Indian/Comoro",
  533. "Indian/Kerguelen",
  534. "Indian/Mahe",
  535. "Indian/Maldives",
  536. "Indian/Mauritius",
  537. "Indian/Mayotte",
  538. "Indian/Reunion",
  539. "Iran",
  540. "Israel",
  541. "Jamaica",
  542. "Japan",
  543. "Kwajalein",
  544. "Libya",
  545. "MET",
  546. "MST",
  547. "MST7MDT",
  548. "Mexico/BajaNorte",
  549. "Mexico/BajaSur",
  550. "Mexico/General",
  551. "NZ",
  552. "NZ-CHAT",
  553. "Navajo",
  554. "PRC",
  555. "PST8PDT",
  556. "Pacific/Apia",
  557. "Pacific/Auckland",
  558. "Pacific/Bougainville",
  559. "Pacific/Chatham",
  560. "Pacific/Chuuk",
  561. "Pacific/Easter",
  562. "Pacific/Efate",
  563. "Pacific/Enderbury",
  564. "Pacific/Fakaofo",
  565. "Pacific/Fiji",
  566. "Pacific/Funafuti",
  567. "Pacific/Galapagos",
  568. "Pacific/Gambier",
  569. "Pacific/Guadalcanal",
  570. "Pacific/Guam",
  571. "Pacific/Honolulu",
  572. "Pacific/Johnston",
  573. "Pacific/Kiritimati",
  574. "Pacific/Kosrae",
  575. "Pacific/Kwajalein",
  576. "Pacific/Majuro",
  577. "Pacific/Marquesas",
  578. "Pacific/Midway",
  579. "Pacific/Nauru",
  580. "Pacific/Niue",
  581. "Pacific/Norfolk",
  582. "Pacific/Noumea",
  583. "Pacific/Pago_Pago",
  584. "Pacific/Palau",
  585. "Pacific/Pitcairn",
  586. "Pacific/Pohnpei",
  587. "Pacific/Ponape",
  588. "Pacific/Port_Moresby",
  589. "Pacific/Rarotonga",
  590. "Pacific/Saipan",
  591. "Pacific/Samoa",
  592. "Pacific/Tahiti",
  593. "Pacific/Tarawa",
  594. "Pacific/Tongatapu",
  595. "Pacific/Truk",
  596. "Pacific/Wake",
  597. "Pacific/Wallis",
  598. "Pacific/Yap",
  599. "Poland",
  600. "Portugal",
  601. "ROC",
  602. "ROK",
  603. "Singapore",
  604. "Turkey",
  605. "UCT",
  606. "US/Alaska",
  607. "US/Aleutian",
  608. "US/Arizona",
  609. "US/Central",
  610. "US/East-Indiana",
  611. "US/Eastern",
  612. "US/Hawaii",
  613. "US/Indiana-Starke",
  614. "US/Michigan",
  615. "US/Mountain",
  616. "US/Pacific",
  617. "US/Samoa",
  618. "UTC",
  619. "Universal",
  620. "W-SU",
  621. "WET",
  622. "Zulu",
  623. nullptr
  624. };
  625. // Helper to return a loaded time zone by value (UTC on error).
  626. time_zone LoadZone(const std::string& name) {
  627. time_zone tz;
  628. load_time_zone(name, &tz);
  629. return tz;
  630. }
  631. // This helper is a macro so that failed expectations show up with the
  632. // correct line numbers.
  633. #define ExpectTime(tp, tz, y, m, d, hh, mm, ss, off, isdst, zone) \
  634. do { \
  635. time_zone::absolute_lookup al = tz.lookup(tp); \
  636. EXPECT_EQ(y, al.cs.year()); \
  637. EXPECT_EQ(m, al.cs.month()); \
  638. EXPECT_EQ(d, al.cs.day()); \
  639. EXPECT_EQ(hh, al.cs.hour()); \
  640. EXPECT_EQ(mm, al.cs.minute()); \
  641. EXPECT_EQ(ss, al.cs.second()); \
  642. EXPECT_EQ(off, al.offset); \
  643. EXPECT_TRUE(isdst == al.is_dst); \
  644. /* EXPECT_STREQ(zone, al.abbr); */ \
  645. } while (0)
  646. // These tests sometimes run on platforms that have zoneinfo data so old
  647. // that the transition we are attempting to check does not exist, most
  648. // notably Android emulators. Fortunately, AndroidZoneInfoSource supports
  649. // time_zone::version() so, in cases where we've learned that it matters,
  650. // we can make the check conditionally.
  651. int VersionCmp(time_zone tz, const std::string& target) {
  652. std::string version = tz.version();
  653. if (version.empty() && !target.empty()) return 1; // unknown > known
  654. return version.compare(target);
  655. }
  656. } // namespace
  657. TEST(TimeZones, LoadZonesConcurrently) {
  658. std::promise<void> ready_promise;
  659. std::shared_future<void> ready_future(ready_promise.get_future());
  660. auto load_zones = [ready_future](std::promise<void>* started,
  661. std::set<std::string>* failures) {
  662. started->set_value();
  663. ready_future.wait();
  664. for (const char* const* np = kTimeZoneNames; *np != nullptr; ++np) {
  665. std::string zone = *np;
  666. time_zone tz;
  667. if (load_time_zone(zone, &tz)) {
  668. EXPECT_EQ(zone, tz.name());
  669. } else {
  670. failures->insert(zone);
  671. }
  672. }
  673. };
  674. const std::size_t n_threads = 128;
  675. std::vector<std::thread> threads;
  676. std::vector<std::set<std::string>> thread_failures(n_threads);
  677. for (std::size_t i = 0; i != n_threads; ++i) {
  678. std::promise<void> started;
  679. threads.emplace_back(load_zones, &started, &thread_failures[i]);
  680. started.get_future().wait();
  681. }
  682. ready_promise.set_value();
  683. for (auto& thread : threads) {
  684. thread.join();
  685. }
  686. // Allow a small number of failures to account for skew between
  687. // the contents of kTimeZoneNames and the zoneinfo data source.
  688. #if defined(__ANDROID__)
  689. // Cater to the possibility of using an even older zoneinfo data
  690. // source when running on Android, where it is difficult to override
  691. // the bionic tzdata provided by the test environment.
  692. const std::size_t max_failures = 20;
  693. #else
  694. const std::size_t max_failures = 3;
  695. #endif
  696. std::set<std::string> failures;
  697. for (const auto& thread_failure : thread_failures) {
  698. failures.insert(thread_failure.begin(), thread_failure.end());
  699. }
  700. EXPECT_LE(failures.size(), max_failures) << testing::PrintToString(failures);
  701. }
  702. TEST(TimeZone, UTC) {
  703. const time_zone utc = utc_time_zone();
  704. time_zone loaded_utc;
  705. EXPECT_TRUE(load_time_zone("UTC", &loaded_utc));
  706. EXPECT_EQ(loaded_utc, utc);
  707. time_zone loaded_utc0;
  708. EXPECT_TRUE(load_time_zone("UTC0", &loaded_utc0));
  709. EXPECT_EQ(loaded_utc0, utc);
  710. }
  711. TEST(TimeZone, NamedTimeZones) {
  712. const time_zone utc = utc_time_zone();
  713. EXPECT_EQ("UTC", utc.name());
  714. const time_zone nyc = LoadZone("America/New_York");
  715. EXPECT_EQ("America/New_York", nyc.name());
  716. const time_zone syd = LoadZone("Australia/Sydney");
  717. EXPECT_EQ("Australia/Sydney", syd.name());
  718. const time_zone fixed0 = fixed_time_zone(cctz::seconds::zero());
  719. EXPECT_EQ("UTC", fixed0.name());
  720. const time_zone fixed_pos = fixed_time_zone(
  721. chrono::hours(3) + chrono::minutes(25) + chrono::seconds(45));
  722. EXPECT_EQ("Fixed/UTC+03:25:45", fixed_pos.name());
  723. const time_zone fixed_neg = fixed_time_zone(
  724. -(chrono::hours(12) + chrono::minutes(34) + chrono::seconds(56)));
  725. EXPECT_EQ("Fixed/UTC-12:34:56", fixed_neg.name());
  726. }
  727. TEST(TimeZone, Failures) {
  728. time_zone tz;
  729. EXPECT_FALSE(load_time_zone(":America/Los_Angeles", &tz));
  730. tz = LoadZone("America/Los_Angeles");
  731. EXPECT_FALSE(load_time_zone("Invalid/TimeZone", &tz));
  732. EXPECT_EQ(chrono::system_clock::from_time_t(0),
  733. convert(civil_second(1970, 1, 1, 0, 0, 0), tz)); // UTC
  734. // Ensures that the load still fails on a subsequent attempt.
  735. tz = LoadZone("America/Los_Angeles");
  736. EXPECT_FALSE(load_time_zone("Invalid/TimeZone", &tz));
  737. EXPECT_EQ(chrono::system_clock::from_time_t(0),
  738. convert(civil_second(1970, 1, 1, 0, 0, 0), tz)); // UTC
  739. // Loading an empty string timezone should fail.
  740. tz = LoadZone("America/Los_Angeles");
  741. EXPECT_FALSE(load_time_zone("", &tz));
  742. EXPECT_EQ(chrono::system_clock::from_time_t(0),
  743. convert(civil_second(1970, 1, 1, 0, 0, 0), tz)); // UTC
  744. }
  745. TEST(TimeZone, Equality) {
  746. const time_zone a;
  747. const time_zone b;
  748. EXPECT_EQ(a, b);
  749. EXPECT_EQ(a.name(), b.name());
  750. const time_zone implicit_utc;
  751. const time_zone explicit_utc = utc_time_zone();
  752. EXPECT_EQ(implicit_utc, explicit_utc);
  753. EXPECT_EQ(implicit_utc.name(), explicit_utc.name());
  754. const time_zone fixed_zero = fixed_time_zone(cctz::seconds::zero());
  755. EXPECT_EQ(fixed_zero, LoadZone(fixed_zero.name()));
  756. EXPECT_EQ(fixed_zero, explicit_utc);
  757. const time_zone fixed_utc = LoadZone("Fixed/UTC+00:00:00");
  758. EXPECT_EQ(fixed_utc, LoadZone(fixed_utc.name()));
  759. EXPECT_EQ(fixed_utc, explicit_utc);
  760. const time_zone fixed_pos = fixed_time_zone(
  761. chrono::hours(3) + chrono::minutes(25) + chrono::seconds(45));
  762. EXPECT_EQ(fixed_pos, LoadZone(fixed_pos.name()));
  763. EXPECT_NE(fixed_pos, explicit_utc);
  764. const time_zone fixed_neg = fixed_time_zone(
  765. -(chrono::hours(12) + chrono::minutes(34) + chrono::seconds(56)));
  766. EXPECT_EQ(fixed_neg, LoadZone(fixed_neg.name()));
  767. EXPECT_NE(fixed_neg, explicit_utc);
  768. const time_zone fixed_lim = fixed_time_zone(chrono::hours(24));
  769. EXPECT_EQ(fixed_lim, LoadZone(fixed_lim.name()));
  770. EXPECT_NE(fixed_lim, explicit_utc);
  771. const time_zone fixed_ovfl =
  772. fixed_time_zone(chrono::hours(24) + chrono::seconds(1));
  773. EXPECT_EQ(fixed_ovfl, LoadZone(fixed_ovfl.name()));
  774. EXPECT_EQ(fixed_ovfl, explicit_utc);
  775. EXPECT_EQ(fixed_time_zone(chrono::seconds(1)),
  776. fixed_time_zone(chrono::seconds(1)));
  777. const time_zone local = local_time_zone();
  778. EXPECT_EQ(local, LoadZone(local.name()));
  779. time_zone la = LoadZone("America/Los_Angeles");
  780. time_zone nyc = LoadZone("America/New_York");
  781. EXPECT_NE(la, nyc);
  782. }
  783. TEST(StdChronoTimePoint, TimeTAlignment) {
  784. // Ensures that the Unix epoch and the system clock epoch are an integral
  785. // number of seconds apart. This simplifies conversions to/from time_t.
  786. auto diff = chrono::system_clock::time_point() -
  787. chrono::system_clock::from_time_t(0);
  788. EXPECT_EQ(chrono::system_clock::time_point::duration::zero(),
  789. diff % chrono::seconds(1));
  790. }
  791. TEST(BreakTime, TimePointResolution) {
  792. const time_zone utc = utc_time_zone();
  793. const auto t0 = chrono::system_clock::from_time_t(0);
  794. ExpectTime(chrono::time_point_cast<chrono::nanoseconds>(t0), utc,
  795. 1970, 1, 1, 0, 0, 0, 0, false, "UTC");
  796. ExpectTime(chrono::time_point_cast<chrono::microseconds>(t0), utc,
  797. 1970, 1, 1, 0, 0, 0, 0, false, "UTC");
  798. ExpectTime(chrono::time_point_cast<chrono::milliseconds>(t0), utc,
  799. 1970, 1, 1, 0, 0, 0, 0, false, "UTC");
  800. ExpectTime(chrono::time_point_cast<chrono::seconds>(t0), utc,
  801. 1970, 1, 1, 0, 0, 0, 0, false, "UTC");
  802. ExpectTime(chrono::time_point_cast<cctz::seconds>(t0), utc,
  803. 1970, 1, 1, 0, 0, 0, 0, false, "UTC");
  804. ExpectTime(chrono::time_point_cast<chrono::minutes>(t0), utc,
  805. 1970, 1, 1, 0, 0, 0, 0, false, "UTC");
  806. ExpectTime(chrono::time_point_cast<chrono::hours>(t0), utc,
  807. 1970, 1, 1, 0, 0, 0, 0, false, "UTC");
  808. }
  809. TEST(BreakTime, LocalTimeInUTC) {
  810. const time_zone tz = utc_time_zone();
  811. const auto tp = chrono::system_clock::from_time_t(0);
  812. ExpectTime(tp, tz, 1970, 1, 1, 0, 0, 0, 0, false, "UTC");
  813. EXPECT_EQ(weekday::thursday, get_weekday(convert(tp, tz)));
  814. }
  815. TEST(BreakTime, LocalTimeInUTCUnaligned) {
  816. const time_zone tz = utc_time_zone();
  817. const auto tp =
  818. chrono::system_clock::from_time_t(0) - chrono::milliseconds(500);
  819. ExpectTime(tp, tz, 1969, 12, 31, 23, 59, 59, 0, false, "UTC");
  820. EXPECT_EQ(weekday::wednesday, get_weekday(convert(tp, tz)));
  821. }
  822. TEST(BreakTime, LocalTimePosix) {
  823. // See IEEE Std 1003.1-1988 B.2.3 General Terms, Epoch.
  824. const time_zone tz = utc_time_zone();
  825. const auto tp = chrono::system_clock::from_time_t(536457599);
  826. ExpectTime(tp, tz, 1986, 12, 31, 23, 59, 59, 0, false, "UTC");
  827. EXPECT_EQ(weekday::wednesday, get_weekday(convert(tp, tz)));
  828. }
  829. TEST(TimeZoneImpl, LocalTimeInFixed) {
  830. const cctz::seconds offset =
  831. -(chrono::hours(8) + chrono::minutes(33) + chrono::seconds(47));
  832. const time_zone tz = fixed_time_zone(offset);
  833. const auto tp = chrono::system_clock::from_time_t(0);
  834. ExpectTime(tp, tz, 1969, 12, 31, 15, 26, 13, offset.count(), false,
  835. "-083347");
  836. EXPECT_EQ(weekday::wednesday, get_weekday(convert(tp, tz)));
  837. }
  838. TEST(BreakTime, LocalTimeInNewYork) {
  839. const time_zone tz = LoadZone("America/New_York");
  840. const auto tp = chrono::system_clock::from_time_t(45);
  841. ExpectTime(tp, tz, 1969, 12, 31, 19, 0, 45, -5 * 60 * 60, false, "EST");
  842. EXPECT_EQ(weekday::wednesday, get_weekday(convert(tp, tz)));
  843. }
  844. TEST(BreakTime, LocalTimeInMTV) {
  845. const time_zone tz = LoadZone("America/Los_Angeles");
  846. const auto tp = chrono::system_clock::from_time_t(1380855729);
  847. ExpectTime(tp, tz, 2013, 10, 3, 20, 2, 9, -7 * 60 * 60, true, "PDT");
  848. EXPECT_EQ(weekday::thursday, get_weekday(convert(tp, tz)));
  849. }
  850. TEST(BreakTime, LocalTimeInSydney) {
  851. const time_zone tz = LoadZone("Australia/Sydney");
  852. const auto tp = chrono::system_clock::from_time_t(90);
  853. ExpectTime(tp, tz, 1970, 1, 1, 10, 1, 30, 10 * 60 * 60, false, "AEST");
  854. EXPECT_EQ(weekday::thursday, get_weekday(convert(tp, tz)));
  855. }
  856. TEST(MakeTime, TimePointResolution) {
  857. const time_zone utc = utc_time_zone();
  858. const time_point<chrono::nanoseconds> tp_ns =
  859. convert(civil_second(2015, 1, 2, 3, 4, 5), utc);
  860. EXPECT_EQ("04:05", cctz::format("%M:%E*S", tp_ns, utc));
  861. const time_point<chrono::microseconds> tp_us =
  862. convert(civil_second(2015, 1, 2, 3, 4, 5), utc);
  863. EXPECT_EQ("04:05", cctz::format("%M:%E*S", tp_us, utc));
  864. const time_point<chrono::milliseconds> tp_ms =
  865. convert(civil_second(2015, 1, 2, 3, 4, 5), utc);
  866. EXPECT_EQ("04:05", cctz::format("%M:%E*S", tp_ms, utc));
  867. const time_point<chrono::seconds> tp_s =
  868. convert(civil_second(2015, 1, 2, 3, 4, 5), utc);
  869. EXPECT_EQ("04:05", cctz::format("%M:%E*S", tp_s, utc));
  870. const time_point<cctz::seconds> tp_s64 =
  871. convert(civil_second(2015, 1, 2, 3, 4, 5), utc);
  872. EXPECT_EQ("04:05", cctz::format("%M:%E*S", tp_s64, utc));
  873. // These next two require chrono::time_point_cast because the conversion
  874. // from a resolution of seconds (the return value of convert()) to a
  875. // coarser resolution requires an explicit cast.
  876. const time_point<chrono::minutes> tp_m =
  877. chrono::time_point_cast<chrono::minutes>(
  878. convert(civil_second(2015, 1, 2, 3, 4, 5), utc));
  879. EXPECT_EQ("04:00", cctz::format("%M:%E*S", tp_m, utc));
  880. const time_point<chrono::hours> tp_h =
  881. chrono::time_point_cast<chrono::hours>(
  882. convert(civil_second(2015, 1, 2, 3, 4, 5), utc));
  883. EXPECT_EQ("00:00", cctz::format("%M:%E*S", tp_h, utc));
  884. }
  885. TEST(MakeTime, Normalization) {
  886. const time_zone tz = LoadZone("America/New_York");
  887. const auto tp = convert(civil_second(2009, 2, 13, 18, 31, 30), tz);
  888. EXPECT_EQ(chrono::system_clock::from_time_t(1234567890), tp);
  889. // Now requests for the same time_point but with out-of-range fields.
  890. EXPECT_EQ(tp, convert(civil_second(2008, 14, 13, 18, 31, 30), tz)); // month
  891. EXPECT_EQ(tp, convert(civil_second(2009, 1, 44, 18, 31, 30), tz)); // day
  892. EXPECT_EQ(tp, convert(civil_second(2009, 2, 12, 42, 31, 30), tz)); // hour
  893. EXPECT_EQ(tp, convert(civil_second(2009, 2, 13, 17, 91, 30), tz)); // minute
  894. EXPECT_EQ(tp, convert(civil_second(2009, 2, 13, 18, 30, 90), tz)); // second
  895. }
  896. // NOTE: Run this with -ftrapv to detect overflow problems.
  897. TEST(MakeTime, SysSecondsLimits) {
  898. const char RFC3339[] = "%Y-%m-%d%ET%H:%M:%S%Ez";
  899. const time_zone utc = utc_time_zone();
  900. const time_zone east = fixed_time_zone(chrono::hours(14));
  901. const time_zone west = fixed_time_zone(-chrono::hours(14));
  902. time_point<cctz::seconds> tp;
  903. // Approach the maximal time_point<cctz::seconds> value from below.
  904. tp = convert(civil_second(292277026596, 12, 4, 15, 30, 6), utc);
  905. EXPECT_EQ("292277026596-12-04T15:30:06+00:00", cctz::format(RFC3339, tp, utc));
  906. tp = convert(civil_second(292277026596, 12, 4, 15, 30, 7), utc);
  907. EXPECT_EQ("292277026596-12-04T15:30:07+00:00", cctz::format(RFC3339, tp, utc));
  908. EXPECT_EQ(time_point<cctz::seconds>::max(), tp);
  909. tp = convert(civil_second(292277026596, 12, 4, 15, 30, 8), utc);
  910. EXPECT_EQ(time_point<cctz::seconds>::max(), tp);
  911. tp = convert(civil_second::max(), utc);
  912. EXPECT_EQ(time_point<cctz::seconds>::max(), tp);
  913. // Checks that we can also get the maximal value for a far-east zone.
  914. tp = convert(civil_second(292277026596, 12, 5, 5, 30, 7), east);
  915. EXPECT_EQ("292277026596-12-05T05:30:07+14:00", cctz::format(RFC3339, tp, east));
  916. EXPECT_EQ(time_point<cctz::seconds>::max(), tp);
  917. tp = convert(civil_second(292277026596, 12, 5, 5, 30, 8), east);
  918. EXPECT_EQ(time_point<cctz::seconds>::max(), tp);
  919. tp = convert(civil_second::max(), east);
  920. EXPECT_EQ(time_point<cctz::seconds>::max(), tp);
  921. // Checks that we can also get the maximal value for a far-west zone.
  922. tp = convert(civil_second(292277026596, 12, 4, 1, 30, 7), west);
  923. EXPECT_EQ("292277026596-12-04T01:30:07-14:00", cctz::format(RFC3339, tp, west));
  924. EXPECT_EQ(time_point<cctz::seconds>::max(), tp);
  925. tp = convert(civil_second(292277026596, 12, 4, 7, 30, 8), west);
  926. EXPECT_EQ(time_point<cctz::seconds>::max(), tp);
  927. tp = convert(civil_second::max(), west);
  928. EXPECT_EQ(time_point<cctz::seconds>::max(), tp);
  929. // Approach the minimal time_point<cctz::seconds> value from above.
  930. tp = convert(civil_second(-292277022657, 1, 27, 8, 29, 53), utc);
  931. EXPECT_EQ("-292277022657-01-27T08:29:53+00:00", cctz::format(RFC3339, tp, utc));
  932. tp = convert(civil_second(-292277022657, 1, 27, 8, 29, 52), utc);
  933. EXPECT_EQ("-292277022657-01-27T08:29:52+00:00", cctz::format(RFC3339, tp, utc));
  934. EXPECT_EQ(time_point<cctz::seconds>::min(), tp);
  935. tp = convert(civil_second(-292277022657, 1, 27, 8, 29, 51), utc);
  936. EXPECT_EQ(time_point<cctz::seconds>::min(), tp);
  937. tp = convert(civil_second::min(), utc);
  938. EXPECT_EQ(time_point<cctz::seconds>::min(), tp);
  939. // Checks that we can also get the minimal value for a far-east zone.
  940. tp = convert(civil_second(-292277022657, 1, 27, 22, 29, 52), east);
  941. EXPECT_EQ("-292277022657-01-27T22:29:52+14:00", cctz::format(RFC3339, tp, east));
  942. EXPECT_EQ(time_point<cctz::seconds>::min(), tp);
  943. tp = convert(civil_second(-292277022657, 1, 27, 22, 29, 51), east);
  944. EXPECT_EQ(time_point<cctz::seconds>::min(), tp);
  945. tp = convert(civil_second::min(), east);
  946. EXPECT_EQ(time_point<cctz::seconds>::min(), tp);
  947. // Checks that we can also get the minimal value for a far-west zone.
  948. tp = convert(civil_second(-292277022657, 1, 26, 18, 29, 52), west);
  949. EXPECT_EQ("-292277022657-01-26T18:29:52-14:00", cctz::format(RFC3339, tp, west));
  950. EXPECT_EQ(time_point<cctz::seconds>::min(), tp);
  951. tp = convert(civil_second(-292277022657, 1, 26, 18, 29, 51), west);
  952. EXPECT_EQ(time_point<cctz::seconds>::min(), tp);
  953. tp = convert(civil_second::min(), west);
  954. EXPECT_EQ(time_point<cctz::seconds>::min(), tp);
  955. // Some similar checks for the "libc" time-zone implementation.
  956. if (sizeof(std::time_t) >= 8) {
  957. // Checks that "tm_year + 1900", as used by the "libc" implementation,
  958. // can produce year values beyond the range on an int without overflow.
  959. #if defined(_WIN32) || defined(_WIN64)
  960. // localtime_s() and gmtime_s() don't believe in years outside [1970:3000].
  961. #else
  962. const time_zone cut = LoadZone("libc:UTC");
  963. const year_t max_tm_year = year_t{std::numeric_limits<int>::max()} + 1900;
  964. tp = convert(civil_second(max_tm_year, 12, 31, 23, 59, 59), cut);
  965. #if defined(__FreeBSD__) || defined(__OpenBSD__)
  966. // The BSD gmtime_r() fails on extreme positive tm_year values.
  967. #else
  968. EXPECT_EQ("2147485547-12-31T23:59:59+00:00", cctz::format(RFC3339, tp, cut));
  969. #endif
  970. const year_t min_tm_year = year_t{std::numeric_limits<int>::min()} + 1900;
  971. tp = convert(civil_second(min_tm_year, 1, 1, 0, 0, 0), cut);
  972. EXPECT_EQ("-2147481748-01-01T00:00:00+00:00", cctz::format(RFC3339, tp, cut));
  973. #endif
  974. }
  975. }
  976. TEST(MakeTime, LocalTimeLibC) {
  977. // Checks that cctz and libc agree on transition points in [1970:2037].
  978. //
  979. // We limit this test case to environments where:
  980. // 1) we know how to change the time zone used by localtime()/mktime(),
  981. // 2) cctz and localtime()/mktime() will use similar-enough tzdata, and
  982. // 3) we have some idea about how mktime() behaves during transitions.
  983. #if defined(__linux__) && !defined(__ANDROID__) && defined(CCTZ_TEST_LIBC_LOCALTIME)
  984. const char* const ep = getenv("TZ");
  985. std::string tz_name = (ep != nullptr) ? ep : "";
  986. for (const char* const* np = kTimeZoneNames; *np != nullptr; ++np) {
  987. ASSERT_EQ(0, setenv("TZ", *np, 1)); // change what "localtime" means
  988. const auto zi = local_time_zone();
  989. const auto lc = LoadZone("libc:localtime");
  990. time_zone::civil_transition transition;
  991. for (auto tp = zi.lookup(civil_second()).trans;
  992. zi.next_transition(tp, &transition);
  993. tp = zi.lookup(transition.to).trans) {
  994. const auto fcl = zi.lookup(transition.from);
  995. const auto tcl = zi.lookup(transition.to);
  996. civil_second cs; // compare cs in zi and lc
  997. if (fcl.kind == time_zone::civil_lookup::UNIQUE) {
  998. if (tcl.kind == time_zone::civil_lookup::UNIQUE) {
  999. // Both unique; must be an is_dst or abbr change.
  1000. ASSERT_EQ(transition.from, transition.to);
  1001. const auto trans = fcl.trans;
  1002. const auto tal = zi.lookup(trans);
  1003. const auto tprev = trans - cctz::seconds(1);
  1004. const auto pal = zi.lookup(tprev);
  1005. if (pal.is_dst == tal.is_dst) {
  1006. ASSERT_STRNE(pal.abbr, tal.abbr);
  1007. }
  1008. continue;
  1009. }
  1010. ASSERT_EQ(time_zone::civil_lookup::REPEATED, tcl.kind);
  1011. cs = transition.to;
  1012. } else {
  1013. ASSERT_EQ(time_zone::civil_lookup::UNIQUE, tcl.kind);
  1014. ASSERT_EQ(time_zone::civil_lookup::SKIPPED, fcl.kind);
  1015. cs = transition.from;
  1016. }
  1017. if (cs.year() > 2037) break; // limit test time (and to 32-bit time_t)
  1018. const auto cl_zi = zi.lookup(cs);
  1019. if (zi.lookup(cl_zi.pre).is_dst == zi.lookup(cl_zi.post).is_dst) {
  1020. // The "libc" implementation cannot correctly classify transitions
  1021. // that don't change the "tm_isdst" flag. In Europe/Volgograd, for
  1022. // example, there is a SKIPPED transition from +03 to +04 with dst=F
  1023. // on both sides ...
  1024. // 1540681199 = 2018-10-28 01:59:59 +03:00:00 [dst=F off=10800]
  1025. // 1540681200 = 2018-10-28 03:00:00 +04:00:00 [dst=F off=14400]
  1026. // but std::mktime(2018-10-28 02:00:00, tm_isdst=0) fails, unlike,
  1027. // say, the similar Europe/Chisinau transition from +02 to +03 ...
  1028. // 1521935999 = 2018-03-25 01:59:59 +02:00:00 [dst=F off=7200]
  1029. // 1521936000 = 2018-03-25 03:00:00 +03:00:00 [dst=T off=10800]
  1030. // where std::mktime(2018-03-25 02:00:00, tm_isdst=0) succeeds and
  1031. // returns 1521936000.
  1032. continue;
  1033. }
  1034. if (cs == civil_second(2037, 10, 4, 2, 0, 0)) {
  1035. const std::string tzname = *np;
  1036. if (tzname == "Africa/Casablanca" || tzname == "Africa/El_Aaiun") {
  1037. // The "libc" implementation gets this transition wrong (at least
  1038. // until 2018g when it was removed), returning an offset of 3600
  1039. // instead of 0. TODO: Revert this when 2018g is ubiquitous.
  1040. continue;
  1041. }
  1042. }
  1043. const auto cl_lc = lc.lookup(cs);
  1044. SCOPED_TRACE(testing::Message() << "For " << cs << " in " << *np);
  1045. EXPECT_EQ(cl_zi.kind, cl_lc.kind);
  1046. EXPECT_EQ(cl_zi.pre, cl_lc.pre);
  1047. EXPECT_EQ(cl_zi.trans, cl_lc.trans);
  1048. EXPECT_EQ(cl_zi.post, cl_lc.post);
  1049. }
  1050. }
  1051. if (ep == nullptr) {
  1052. ASSERT_EQ(0, unsetenv("TZ"));
  1053. } else {
  1054. ASSERT_EQ(0, setenv("TZ", tz_name.c_str(), 1));
  1055. }
  1056. #endif
  1057. }
  1058. TEST(NextTransition, UTC) {
  1059. const auto tz = utc_time_zone();
  1060. time_zone::civil_transition trans;
  1061. auto tp = time_point<cctz::seconds>::min();
  1062. EXPECT_FALSE(tz.next_transition(tp, &trans));
  1063. tp = time_point<cctz::seconds>::max();
  1064. EXPECT_FALSE(tz.next_transition(tp, &trans));
  1065. }
  1066. TEST(PrevTransition, UTC) {
  1067. const auto tz = utc_time_zone();
  1068. time_zone::civil_transition trans;
  1069. auto tp = time_point<cctz::seconds>::max();
  1070. EXPECT_FALSE(tz.prev_transition(tp, &trans));
  1071. tp = time_point<cctz::seconds>::min();
  1072. EXPECT_FALSE(tz.prev_transition(tp, &trans));
  1073. }
  1074. TEST(NextTransition, AmericaNewYork) {
  1075. const auto tz = LoadZone("America/New_York");
  1076. time_zone::civil_transition trans;
  1077. auto tp = convert(civil_second(2018, 6, 30, 0, 0, 0), tz);
  1078. EXPECT_TRUE(tz.next_transition(tp, &trans));
  1079. EXPECT_EQ(civil_second(2018, 11, 4, 2, 0, 0), trans.from);
  1080. EXPECT_EQ(civil_second(2018, 11, 4, 1, 0, 0), trans.to);
  1081. tp = time_point<cctz::seconds>::max();
  1082. EXPECT_FALSE(tz.next_transition(tp, &trans));
  1083. tp = time_point<cctz::seconds>::min();
  1084. EXPECT_TRUE(tz.next_transition(tp, &trans));
  1085. if (trans.from == civil_second(1918, 3, 31, 2, 0, 0)) {
  1086. // It looks like the tzdata is only 32 bit (probably macOS),
  1087. // which bottoms out at 1901-12-13T20:45:52+00:00.
  1088. EXPECT_EQ(civil_second(1918, 3, 31, 3, 0, 0), trans.to);
  1089. } else {
  1090. EXPECT_EQ(civil_second(1883, 11, 18, 12, 3, 58), trans.from);
  1091. EXPECT_EQ(civil_second(1883, 11, 18, 12, 0, 0), trans.to);
  1092. }
  1093. }
  1094. TEST(PrevTransition, AmericaNewYork) {
  1095. const auto tz = LoadZone("America/New_York");
  1096. time_zone::civil_transition trans;
  1097. auto tp = convert(civil_second(2018, 6, 30, 0, 0, 0), tz);
  1098. EXPECT_TRUE(tz.prev_transition(tp, &trans));
  1099. EXPECT_EQ(civil_second(2018, 3, 11, 2, 0, 0), trans.from);
  1100. EXPECT_EQ(civil_second(2018, 3, 11, 3, 0, 0), trans.to);
  1101. tp = time_point<cctz::seconds>::min();
  1102. EXPECT_FALSE(tz.prev_transition(tp, &trans));
  1103. tp = time_point<cctz::seconds>::max();
  1104. EXPECT_TRUE(tz.prev_transition(tp, &trans));
  1105. // We have a transition but we don't know which one.
  1106. }
  1107. TEST(TimeZoneEdgeCase, AmericaNewYork) {
  1108. const time_zone tz = LoadZone("America/New_York");
  1109. // Spring 1:59:59 -> 3:00:00
  1110. auto tp = convert(civil_second(2013, 3, 10, 1, 59, 59), tz);
  1111. ExpectTime(tp, tz, 2013, 3, 10, 1, 59, 59, -5 * 3600, false, "EST");
  1112. tp += cctz::seconds(1);
  1113. ExpectTime(tp, tz, 2013, 3, 10, 3, 0, 0, -4 * 3600, true, "EDT");
  1114. // Fall 1:59:59 -> 1:00:00
  1115. tp = convert(civil_second(2013, 11, 3, 1, 59, 59), tz);
  1116. ExpectTime(tp, tz, 2013, 11, 3, 1, 59, 59, -4 * 3600, true, "EDT");
  1117. tp += cctz::seconds(1);
  1118. ExpectTime(tp, tz, 2013, 11, 3, 1, 0, 0, -5 * 3600, false, "EST");
  1119. }
  1120. TEST(TimeZoneEdgeCase, AmericaLosAngeles) {
  1121. const time_zone tz = LoadZone("America/Los_Angeles");
  1122. // Spring 1:59:59 -> 3:00:00
  1123. auto tp = convert(civil_second(2013, 3, 10, 1, 59, 59), tz);
  1124. ExpectTime(tp, tz, 2013, 3, 10, 1, 59, 59, -8 * 3600, false, "PST");
  1125. tp += cctz::seconds(1);
  1126. ExpectTime(tp, tz, 2013, 3, 10, 3, 0, 0, -7 * 3600, true, "PDT");
  1127. // Fall 1:59:59 -> 1:00:00
  1128. tp = convert(civil_second(2013, 11, 3, 1, 59, 59), tz);
  1129. ExpectTime(tp, tz, 2013, 11, 3, 1, 59, 59, -7 * 3600, true, "PDT");
  1130. tp += cctz::seconds(1);
  1131. ExpectTime(tp, tz, 2013, 11, 3, 1, 0, 0, -8 * 3600, false, "PST");
  1132. }
  1133. TEST(TimeZoneEdgeCase, ArizonaNoTransition) {
  1134. const time_zone tz = LoadZone("America/Phoenix");
  1135. // No transition in Spring.
  1136. auto tp = convert(civil_second(2013, 3, 10, 1, 59, 59), tz);
  1137. ExpectTime(tp, tz, 2013, 3, 10, 1, 59, 59, -7 * 3600, false, "MST");
  1138. tp += cctz::seconds(1);
  1139. ExpectTime(tp, tz, 2013, 3, 10, 2, 0, 0, -7 * 3600, false, "MST");
  1140. // No transition in Fall.
  1141. tp = convert(civil_second(2013, 11, 3, 1, 59, 59), tz);
  1142. ExpectTime(tp, tz, 2013, 11, 3, 1, 59, 59, -7 * 3600, false, "MST");
  1143. tp += cctz::seconds(1);
  1144. ExpectTime(tp, tz, 2013, 11, 3, 2, 0, 0, -7 * 3600, false, "MST");
  1145. }
  1146. TEST(TimeZoneEdgeCase, AsiaKathmandu) {
  1147. const time_zone tz = LoadZone("Asia/Kathmandu");
  1148. // A non-DST offset change from +0530 to +0545
  1149. //
  1150. // 504901799 == Tue, 31 Dec 1985 23:59:59 +0530 (+0530)
  1151. // 504901800 == Wed, 1 Jan 1986 00:15:00 +0545 (+0545)
  1152. auto tp = convert(civil_second(1985, 12, 31, 23, 59, 59), tz);
  1153. ExpectTime(tp, tz, 1985, 12, 31, 23, 59, 59, 5.5 * 3600, false, "+0530");
  1154. tp += cctz::seconds(1);
  1155. ExpectTime(tp, tz, 1986, 1, 1, 0, 15, 0, 5.75 * 3600, false, "+0545");
  1156. }
  1157. TEST(TimeZoneEdgeCase, PacificChatham) {
  1158. const time_zone tz = LoadZone("Pacific/Chatham");
  1159. // One-hour DST offset changes, but at atypical values
  1160. //
  1161. // 1365256799 == Sun, 7 Apr 2013 03:44:59 +1345 (+1345)
  1162. // 1365256800 == Sun, 7 Apr 2013 02:45:00 +1245 (+1245)
  1163. auto tp = convert(civil_second(2013, 4, 7, 3, 44, 59), tz);
  1164. ExpectTime(tp, tz, 2013, 4, 7, 3, 44, 59, 13.75 * 3600, true, "+1345");
  1165. tp += cctz::seconds(1);
  1166. ExpectTime(tp, tz, 2013, 4, 7, 2, 45, 0, 12.75 * 3600, false, "+1245");
  1167. // 1380376799 == Sun, 29 Sep 2013 02:44:59 +1245 (+1245)
  1168. // 1380376800 == Sun, 29 Sep 2013 03:45:00 +1345 (+1345)
  1169. tp = convert(civil_second(2013, 9, 29, 2, 44, 59), tz);
  1170. ExpectTime(tp, tz, 2013, 9, 29, 2, 44, 59, 12.75 * 3600, false, "+1245");
  1171. tp += cctz::seconds(1);
  1172. ExpectTime(tp, tz, 2013, 9, 29, 3, 45, 0, 13.75 * 3600, true, "+1345");
  1173. }
  1174. TEST(TimeZoneEdgeCase, AustraliaLordHowe) {
  1175. const time_zone tz = LoadZone("Australia/Lord_Howe");
  1176. // Half-hour DST offset changes
  1177. //
  1178. // 1365260399 == Sun, 7 Apr 2013 01:59:59 +1100 (+11)
  1179. // 1365260400 == Sun, 7 Apr 2013 01:30:00 +1030 (+1030)
  1180. auto tp = convert(civil_second(2013, 4, 7, 1, 59, 59), tz);
  1181. ExpectTime(tp, tz, 2013, 4, 7, 1, 59, 59, 11 * 3600, true, "+11");
  1182. tp += cctz::seconds(1);
  1183. ExpectTime(tp, tz, 2013, 4, 7, 1, 30, 0, 10.5 * 3600, false, "+1030");
  1184. // 1380986999 == Sun, 6 Oct 2013 01:59:59 +1030 (+1030)
  1185. // 1380987000 == Sun, 6 Oct 2013 02:30:00 +1100 (+11)
  1186. tp = convert(civil_second(2013, 10, 6, 1, 59, 59), tz);
  1187. ExpectTime(tp, tz, 2013, 10, 6, 1, 59, 59, 10.5 * 3600, false, "+1030");
  1188. tp += cctz::seconds(1);
  1189. ExpectTime(tp, tz, 2013, 10, 6, 2, 30, 0, 11 * 3600, true, "+11");
  1190. }
  1191. TEST(TimeZoneEdgeCase, PacificApia) {
  1192. const time_zone tz = LoadZone("Pacific/Apia");
  1193. // At the end of December 2011, Samoa jumped forward by one day,
  1194. // skipping 30 December from the local calendar, when the nation
  1195. // moved to the west of the International Date Line.
  1196. //
  1197. // A one-day, non-DST offset change
  1198. //
  1199. // 1325239199 == Thu, 29 Dec 2011 23:59:59 -1000 (-10)
  1200. // 1325239200 == Sat, 31 Dec 2011 00:00:00 +1400 (+14)
  1201. auto tp = convert(civil_second(2011, 12, 29, 23, 59, 59), tz);
  1202. ExpectTime(tp, tz, 2011, 12, 29, 23, 59, 59, -10 * 3600, true, "-10");
  1203. EXPECT_EQ(363, get_yearday(convert(tp, tz)));
  1204. tp += cctz::seconds(1);
  1205. ExpectTime(tp, tz, 2011, 12, 31, 0, 0, 0, 14 * 3600, true, "+14");
  1206. EXPECT_EQ(365, get_yearday(convert(tp, tz)));
  1207. }
  1208. TEST(TimeZoneEdgeCase, AfricaCairo) {
  1209. const time_zone tz = LoadZone("Africa/Cairo");
  1210. if (VersionCmp(tz, "2014c") >= 0) {
  1211. // An interesting case of midnight not existing.
  1212. //
  1213. // 1400191199 == Thu, 15 May 2014 23:59:59 +0200 (EET)
  1214. // 1400191200 == Fri, 16 May 2014 01:00:00 +0300 (EEST)
  1215. auto tp = convert(civil_second(2014, 5, 15, 23, 59, 59), tz);
  1216. ExpectTime(tp, tz, 2014, 5, 15, 23, 59, 59, 2 * 3600, false, "EET");
  1217. tp += cctz::seconds(1);
  1218. ExpectTime(tp, tz, 2014, 5, 16, 1, 0, 0, 3 * 3600, true, "EEST");
  1219. }
  1220. }
  1221. TEST(TimeZoneEdgeCase, AfricaMonrovia) {
  1222. const time_zone tz = LoadZone("Africa/Monrovia");
  1223. if (VersionCmp(tz, "2017b") >= 0) {
  1224. // Strange offset change -00:44:30 -> +00:00:00 (non-DST)
  1225. //
  1226. // 63593069 == Thu, 6 Jan 1972 23:59:59 -0044 (MMT)
  1227. // 63593070 == Fri, 7 Jan 1972 00:44:30 +0000 (GMT)
  1228. auto tp = convert(civil_second(1972, 1, 6, 23, 59, 59), tz);
  1229. ExpectTime(tp, tz, 1972, 1, 6, 23, 59, 59, -44.5 * 60, false, "MMT");
  1230. tp += cctz::seconds(1);
  1231. ExpectTime(tp, tz, 1972, 1, 7, 0, 44, 30, 0 * 60, false, "GMT");
  1232. }
  1233. }
  1234. TEST(TimeZoneEdgeCase, AmericaJamaica) {
  1235. // Jamaica discontinued DST transitions in 1983, and is now at a
  1236. // constant -0500. This makes it an interesting edge-case target.
  1237. // Note that the 32-bit times used in a (tzh_version == 0) zoneinfo
  1238. // file cannot represent the abbreviation-only transition of 1890,
  1239. // so we ignore the abbreviation by expecting what we received.
  1240. const time_zone tz = LoadZone("America/Jamaica");
  1241. // Before the first transition.
  1242. if (!tz.version().empty() && VersionCmp(tz, "2018d") >= 0) {
  1243. // We avoid the expectations on the -18430 offset below unless we are
  1244. // certain we have commit 907241e (Fix off-by-1 error for Jamaica and
  1245. // T&C before 1913) from 2018d. TODO: Remove the "version() not empty"
  1246. // part when 2018d is generally available from /usr/share/zoneinfo.
  1247. auto tp = convert(civil_second(1889, 12, 31, 0, 0, 0), tz);
  1248. ExpectTime(tp, tz, 1889, 12, 31, 0, 0, 0, -18430, false,
  1249. tz.lookup(tp).abbr);
  1250. // Over the first (abbreviation-change only) transition.
  1251. // -2524503170 == Tue, 31 Dec 1889 23:59:59 -0507 (LMT)
  1252. // -2524503169 == Wed, 1 Jan 1890 00:00:00 -0507 (KMT)
  1253. tp = convert(civil_second(1889, 12, 31, 23, 59, 59), tz);
  1254. ExpectTime(tp, tz, 1889, 12, 31, 23, 59, 59, -18430, false,
  1255. tz.lookup(tp).abbr);
  1256. tp += cctz::seconds(1);
  1257. ExpectTime(tp, tz, 1890, 1, 1, 0, 0, 0, -18430, false, "KMT");
  1258. }
  1259. // Over the last (DST) transition.
  1260. // 436341599 == Sun, 30 Oct 1983 01:59:59 -0400 (EDT)
  1261. // 436341600 == Sun, 30 Oct 1983 01:00:00 -0500 (EST)
  1262. auto tp = convert(civil_second(1983, 10, 30, 1, 59, 59), tz);
  1263. ExpectTime(tp, tz, 1983, 10, 30, 1, 59, 59, -4 * 3600, true, "EDT");
  1264. tp += cctz::seconds(1);
  1265. ExpectTime(tp, tz, 1983, 10, 30, 1, 0, 0, -5 * 3600, false, "EST");
  1266. // After the last transition.
  1267. tp = convert(civil_second(1983, 12, 31, 23, 59, 59), tz);
  1268. ExpectTime(tp, tz, 1983, 12, 31, 23, 59, 59, -5 * 3600, false, "EST");
  1269. }
  1270. TEST(TimeZoneEdgeCase, WET) {
  1271. // Cover some non-existent times within forward transitions.
  1272. const time_zone tz = LoadZone("WET");
  1273. // Before the first transition.
  1274. auto tp = convert(civil_second(1977, 1, 1, 0, 0, 0), tz);
  1275. ExpectTime(tp, tz, 1977, 1, 1, 0, 0, 0, 0, false, "WET");
  1276. // Over the first transition.
  1277. // 228877199 == Sun, 3 Apr 1977 00:59:59 +0000 (WET)
  1278. // 228877200 == Sun, 3 Apr 1977 02:00:00 +0100 (WEST)
  1279. tp = convert(civil_second(1977, 4, 3, 0, 59, 59), tz);
  1280. ExpectTime(tp, tz, 1977, 4, 3, 0, 59, 59, 0, false, "WET");
  1281. tp += cctz::seconds(1);
  1282. ExpectTime(tp, tz, 1977, 4, 3, 2, 0, 0, 1 * 3600, true, "WEST");
  1283. // A non-existent time within the first transition.
  1284. time_zone::civil_lookup cl1 = tz.lookup(civil_second(1977, 4, 3, 1, 15, 0));
  1285. EXPECT_EQ(time_zone::civil_lookup::SKIPPED, cl1.kind);
  1286. ExpectTime(cl1.pre, tz, 1977, 4, 3, 2, 15, 0, 1 * 3600, true, "WEST");
  1287. ExpectTime(cl1.trans, tz, 1977, 4, 3, 2, 0, 0, 1 * 3600, true, "WEST");
  1288. ExpectTime(cl1.post, tz, 1977, 4, 3, 0, 15, 0, 0 * 3600, false, "WET");
  1289. // A non-existent time within the second forward transition.
  1290. time_zone::civil_lookup cl2 = tz.lookup(civil_second(1978, 4, 2, 1, 15, 0));
  1291. EXPECT_EQ(time_zone::civil_lookup::SKIPPED, cl2.kind);
  1292. ExpectTime(cl2.pre, tz, 1978, 4, 2, 2, 15, 0, 1 * 3600, true, "WEST");
  1293. ExpectTime(cl2.trans, tz, 1978, 4, 2, 2, 0, 0, 1 * 3600, true, "WEST");
  1294. ExpectTime(cl2.post, tz, 1978, 4, 2, 0, 15, 0, 0 * 3600, false, "WET");
  1295. }
  1296. TEST(TimeZoneEdgeCase, FixedOffsets) {
  1297. const time_zone gmtm5 = LoadZone("Etc/GMT+5"); // -0500
  1298. auto tp = convert(civil_second(1970, 1, 1, 0, 0, 0), gmtm5);
  1299. ExpectTime(tp, gmtm5, 1970, 1, 1, 0, 0, 0, -5 * 3600, false, "-05");
  1300. EXPECT_EQ(chrono::system_clock::from_time_t(5 * 3600), tp);
  1301. const time_zone gmtp5 = LoadZone("Etc/GMT-5"); // +0500
  1302. tp = convert(civil_second(1970, 1, 1, 0, 0, 0), gmtp5);
  1303. ExpectTime(tp, gmtp5, 1970, 1, 1, 0, 0, 0, 5 * 3600, false, "+05");
  1304. EXPECT_EQ(chrono::system_clock::from_time_t(-5 * 3600), tp);
  1305. }
  1306. TEST(TimeZoneEdgeCase, NegativeYear) {
  1307. // Tests transition from year 0 (aka 1BCE) to year -1.
  1308. const time_zone tz = utc_time_zone();
  1309. auto tp = convert(civil_second(0, 1, 1, 0, 0, 0), tz);
  1310. ExpectTime(tp, tz, 0, 1, 1, 0, 0, 0, 0 * 3600, false, "UTC");
  1311. EXPECT_EQ(weekday::saturday, get_weekday(convert(tp, tz)));
  1312. tp -= cctz::seconds(1);
  1313. ExpectTime(tp, tz, -1, 12, 31, 23, 59, 59, 0 * 3600, false, "UTC");
  1314. EXPECT_EQ(weekday::friday, get_weekday(convert(tp, tz)));
  1315. }
  1316. TEST(TimeZoneEdgeCase, UTC32bitLimit) {
  1317. const time_zone tz = utc_time_zone();
  1318. // Limits of signed 32-bit time_t
  1319. //
  1320. // 2147483647 == Tue, 19 Jan 2038 03:14:07 +0000 (UTC)
  1321. // 2147483648 == Tue, 19 Jan 2038 03:14:08 +0000 (UTC)
  1322. auto tp = convert(civil_second(2038, 1, 19, 3, 14, 7), tz);
  1323. ExpectTime(tp, tz, 2038, 1, 19, 3, 14, 7, 0 * 3600, false, "UTC");
  1324. tp += cctz::seconds(1);
  1325. ExpectTime(tp, tz, 2038, 1, 19, 3, 14, 8, 0 * 3600, false, "UTC");
  1326. }
  1327. TEST(TimeZoneEdgeCase, UTC5DigitYear) {
  1328. const time_zone tz = utc_time_zone();
  1329. // Rollover to 5-digit year
  1330. //
  1331. // 253402300799 == Fri, 31 Dec 9999 23:59:59 +0000 (UTC)
  1332. // 253402300800 == Sat, 1 Jan 1000 00:00:00 +0000 (UTC)
  1333. auto tp = convert(civil_second(9999, 12, 31, 23, 59, 59), tz);
  1334. ExpectTime(tp, tz, 9999, 12, 31, 23, 59, 59, 0 * 3600, false, "UTC");
  1335. tp += cctz::seconds(1);
  1336. ExpectTime(tp, tz, 10000, 1, 1, 0, 0, 0, 0 * 3600, false, "UTC");
  1337. }
  1338. } // namespace cctz