mirror of
https://github.com/HowardHinnant/date.git
synced 2025-06-25 01:01:33 +02:00
Compare commits
582 Commits
v1.0.0
...
esp-idf-re
Author | SHA1 | Date | |
---|---|---|---|
1658637448 | |||
4bbbffdf4c | |||
8ec7f3a36d | |||
b1a75847d5 | |||
49d78d1837 | |||
a32ff4f07e | |||
3be6b76d70 | |||
bf79dd5a81 | |||
26fc2bd372 | |||
97246a638a | |||
432bab81f9 | |||
215cacff56 | |||
3cbfa4318f | |||
115dd428cf | |||
7848566815 | |||
393b52f21b | |||
0b72599bd4 | |||
ba99134b8a | |||
5e18488899 | |||
313189b0a8 | |||
057b441ceb | |||
d7a0bf1fa7 | |||
8140d979cd | |||
7990eae740 | |||
1ec2ea0295 | |||
658a3b9495 | |||
e7969c32e8 | |||
569b2d6785 | |||
abe3ada04f | |||
9537addfc4 | |||
6952fb50a6 | |||
fe2f9c7eac | |||
a6243ce56f | |||
a55f1a103b | |||
d544e5af25 | |||
cac99da8dc | |||
a088baf9a5 | |||
e6adff6754 | |||
d784766640 | |||
9343e31599 | |||
f43c39fcf1 | |||
e12095f26f | |||
7d811743e0 | |||
a2fdba1adc | |||
4c1968b8f0 | |||
9cc3a7bca1 | |||
9a0ee25428 | |||
c8d311f6f1 | |||
fe63f0bb5f | |||
9502bc27a3 | |||
66a5aa482e | |||
b9cd9c3fde | |||
a184309786 | |||
fc4cf092f9 | |||
48433b9892 | |||
4c95165298 | |||
940f4a5ceb | |||
018a50bcd0 | |||
3e376be2e9 | |||
224c71a899 | |||
67e272a54e | |||
d399e10cba | |||
96ffe23f72 | |||
48f1455cd2 | |||
e3186e36c2 | |||
3f0f9b3cbe | |||
23fa1bb86d | |||
4481c75192 | |||
e6d2c08159 | |||
a5c4b4ebf8 | |||
44344000f0 | |||
6d5ff9b958 | |||
375579eac1 | |||
2ced83ceff | |||
718cbe3f9b | |||
961bf06c32 | |||
fe491eff1c | |||
c56f915cc3 | |||
5e57a19abe | |||
9454aeda2b | |||
3a343adf6a | |||
d21333f636 | |||
cb4bf26fc7 | |||
b87eb970c1 | |||
5a0057587d | |||
5345d135b7 | |||
7c020642fb | |||
1d721d9afd | |||
141ba85614 | |||
dca8ddc659 | |||
1f5c192f4a | |||
46ccd69c9c | |||
c0e7b4e2f7 | |||
09d90a8b5e | |||
6f0b645df1 | |||
7ef1a55143 | |||
27d1e1e54e | |||
7817ebf45a | |||
a029f1105d | |||
44215f6781 | |||
ed0368fc75 | |||
429d9ba739 | |||
081e9af55b | |||
8a563041fa | |||
9dc96fd9b5 | |||
8b69087d35 | |||
d5e96f0991 | |||
5ba1c1ad85 | |||
10ab6ae9e5 | |||
e31daf8093 | |||
cb7ca96f68 | |||
b5d025ea2f | |||
f782ae98f0 | |||
d6c5d02068 | |||
16077472af | |||
5a62c405e0 | |||
09a19a09f4 | |||
9cb0013aef | |||
f1326968af | |||
61c3d35634 | |||
4e7e76b981 | |||
90d0440884 | |||
2cb4c34009 | |||
7231a182a4 | |||
0e85704e47 | |||
5f34c40523 | |||
23b1f007fe | |||
a22125ca40 | |||
8f91ef27ed | |||
4b46deb4f9 | |||
54e8516af2 | |||
1eed461d06 | |||
591f572b67 | |||
69e9cd612f | |||
6b51ca8271 | |||
3e82a52d66 | |||
6a4d93a0bd | |||
39d6730665 | |||
de6a03d337 | |||
e86edc3820 | |||
1b32e316db | |||
f46885e632 | |||
2d282e35fa | |||
d50970b32a | |||
af2b2b70b3 | |||
3933a0122d | |||
07876e4433 | |||
0197889505 | |||
b86def339e | |||
aa0494b980 | |||
df31560701 | |||
4b687f4c04 | |||
db60c5eb8e | |||
9f1c4b0110 | |||
da15227f6c | |||
d4fb7eb76d | |||
0e3e84fd56 | |||
3eac2d376e | |||
f5f4d76936 | |||
c7b69d949a | |||
48baa942fc | |||
af415701ba | |||
be2ec2310b | |||
40b83654b6 | |||
6c4d333026 | |||
1fdda81a30 | |||
f33e179936 | |||
328cecaa56 | |||
5d15157bbb | |||
a91ceefb4e | |||
88c661e9f3 | |||
c665992a6e | |||
9d0bcdb63f | |||
973bd393bc | |||
d53db7a1cb | |||
e5c69d84ab | |||
b48a18a1d9 | |||
cdb4b276d9 | |||
1d9e49ea21 | |||
0125d330ab | |||
e7e1482087 | |||
d6b95dc301 | |||
700489e475 | |||
e6941697eb | |||
c311db2f1a | |||
fffa52ac0e | |||
f105595f04 | |||
20f0595b32 | |||
674a9e6953 | |||
bc8cf368e5 | |||
1e8ab50f82 | |||
38c5ca38bb | |||
0bde4ba8c8 | |||
afe61df277 | |||
43d8a4eab0 | |||
ca4036a4b0 | |||
a1ceec19fe | |||
5524dd1ae8 | |||
4ada98d247 | |||
040eed838b | |||
2acf403bcd | |||
637e5d8007 | |||
362cd8f27e | |||
a4ce4bc2d3 | |||
3e5a57467a | |||
3b8372f4fa | |||
6941691de4 | |||
09b78ba92c | |||
28c1c61ac2 | |||
55289f0d73 | |||
b7e58e193f | |||
2b6ee6378c | |||
7d80d89a44 | |||
d9052cffa2 | |||
447687870f | |||
dbd6e6e388 | |||
9178193ad2 | |||
44c2515280 | |||
0af7654764 | |||
1eeb4cd652 | |||
b49bdc3ca7 | |||
c7e5a4d08e | |||
5653e9e3a9 | |||
d3b8d4af8d | |||
c2e139ef53 | |||
a3e8f399c4 | |||
443a29df53 | |||
1902b8e8fb | |||
c513a20691 | |||
87ed7f83cf | |||
f8cc62c396 | |||
2d2b65906a | |||
53629fa30c | |||
748a1fd5a9 | |||
524517b369 | |||
98ae1e5241 | |||
9b88763dbf | |||
f3741d68ff | |||
080df4988f | |||
1f27fb7d42 | |||
3e47883c41 | |||
3a33cdca7d | |||
3c4f0b5ada | |||
c0a3e528a3 | |||
9c67d94f2f | |||
9c39772731 | |||
15a63ec819 | |||
543315b700 | |||
7c69f1570d | |||
dd91be668e | |||
b13c859ff1 | |||
d4592bd497 | |||
9910f5fcc3 | |||
58a4a9518a | |||
5a9b44a37a | |||
a9d2907fa1 | |||
bf5a4f3cd5 | |||
e1099ef3ab | |||
4614ebda4a | |||
c286981b3b | |||
9ca582d9da | |||
f4b12ab023 | |||
bd51baf31e | |||
16439a8ce2 | |||
d97bc984c7 | |||
c9ef0a8f05 | |||
4832ea0ddb | |||
ec514101a6 | |||
517c0f2704 | |||
e12f7c66f0 | |||
3a5e8c9384 | |||
fa6529a2fc | |||
4b73a42d02 | |||
25696b7fb3 | |||
9381e894a5 | |||
5563d31b2e | |||
202041e531 | |||
0b7d9c6dbe | |||
66a97f907e | |||
94eb182256 | |||
f328d8c84a | |||
8b9f0515b5 | |||
ce975cadb0 | |||
2032fccbb7 | |||
2e213abb76 | |||
3acb299f3f | |||
22a229af91 | |||
fc917fe303 | |||
bff551b2a5 | |||
9f6c8d8c10 | |||
3c3ba68906 | |||
c5e58fd015 | |||
ef6d53595d | |||
0f658db2cd | |||
481771ef5e | |||
5f01382e24 | |||
41563c46e8 | |||
bba9aeafab | |||
4cb893c780 | |||
c09d35534d | |||
272d487b3d | |||
aad6010831 | |||
0707cc4932 | |||
d3fcf00d55 | |||
2402a0bd25 | |||
873aa0515e | |||
49b50c43d9 | |||
38c24b4090 | |||
2515dfd1b5 | |||
c3ab69ee0d | |||
be871e6c85 | |||
eced00fc1c | |||
859a50a70e | |||
80a142407a | |||
d4d6eda861 | |||
07ada69385 | |||
e7c3ca0e90 | |||
82de27d339 | |||
922abf1299 | |||
c4dcd5eb78 | |||
9c181a1440 | |||
e2a38e600c | |||
4ae416f06a | |||
5726b70bb7 | |||
e6b1e0fe58 | |||
170ebfd354 | |||
a5b77bb0fe | |||
5a53cb38a3 | |||
494fee4e1b | |||
a034eeed23 | |||
a1b19a2ed6 | |||
496497d16e | |||
a828109809 | |||
2129b813c9 | |||
c8d3cc14da | |||
893cf51fd8 | |||
6067371127 | |||
0c8b1f5967 | |||
16dd16e64e | |||
ea0158c779 | |||
a0b8883763 | |||
156bdf8bc6 | |||
2d1d8f2255 | |||
e0c962a8ce | |||
7cbc4d8013 | |||
090b66beb8 | |||
791de2d9fc | |||
77a703afe2 | |||
bee4f27d4a | |||
56cec17500 | |||
d359399090 | |||
a003ad28fa | |||
012f2c6135 | |||
edcd9bd9c1 | |||
9f0d511be6 | |||
ccd857ff6d | |||
88890939d5 | |||
1139c9b64f | |||
ec412a1de0 | |||
aa4dafcc46 | |||
cc81c9ea50 | |||
a610f087c1 | |||
5132385454 | |||
5c38ad84e8 | |||
8b743db4b6 | |||
9c9ddeba37 | |||
0fb3921e5b | |||
83c8b4d522 | |||
f493bd67f2 | |||
cf0481b9af | |||
f57432d7b4 | |||
e8f0dca452 | |||
44f6dfc58e | |||
ec7db09085 | |||
cb83bc2501 | |||
faec35eaf1 | |||
20efec5b16 | |||
b2dc8b1f6e | |||
2f8997d3ed | |||
c64d69b1e1 | |||
885910375f | |||
d15491103b | |||
05db422ca9 | |||
2c094f5559 | |||
096bad2622 | |||
fc3d4d97fe | |||
4f27361378 | |||
a4eef8e20c | |||
1fd0806757 | |||
3daf8c1ffe | |||
c4c2550b29 | |||
f30450b4c5 | |||
d29cd4e343 | |||
5afd241be6 | |||
f044cb0583 | |||
3495c513a1 | |||
3ab6510cab | |||
5eff31acdd | |||
5e86f2c5ba | |||
dbee0e7da4 | |||
d110f07f59 | |||
9e1120c676 | |||
f4292e6aca | |||
a811a20748 | |||
3df43424ac | |||
1e7e7a214d | |||
ffc8cd0a3b | |||
e9d36c6200 | |||
3233cbaf9a | |||
3e906a2409 | |||
c7f2995d0b | |||
0d6de15043 | |||
5c09ae73f2 | |||
098223cf6d | |||
6a31edcb38 | |||
800ae143aa | |||
c1034550d2 | |||
3a9880999d | |||
ce67ee0997 | |||
2b8e6562ae | |||
186dbb2891 | |||
49a59e5665 | |||
095f66af28 | |||
ea1717e8ab | |||
659cdca5dc | |||
634b84eb60 | |||
41093d05d8 | |||
c6f3dd2832 | |||
e203304afd | |||
4e44539a59 | |||
09537c4e19 | |||
2935f80109 | |||
4a1c49152f | |||
07d9e8a0fe | |||
6889dc69fb | |||
628404b87c | |||
2216bfbe44 | |||
64ea0a5bc3 | |||
8a3aeb566b | |||
a5450e9d02 | |||
2310435582 | |||
6b3ea4516a | |||
298e9aff2d | |||
0cfa783b14 | |||
44e0480087 | |||
63e33bdf49 | |||
33f7cc6de4 | |||
27964fa642 | |||
887d7574b1 | |||
bae66f2bff | |||
1f7325ef7f | |||
9f7a438f7d | |||
9e25c2d74f | |||
806c29fddc | |||
501609bacf | |||
cfa55850c7 | |||
ff929570f9 | |||
fab89b205b | |||
2ba541b684 | |||
81b5cc65f0 | |||
381cbf9a7b | |||
f66af06870 | |||
d02f762e32 | |||
3f0540cefd | |||
19c83e47ed | |||
cedbe3c445 | |||
cb820f9090 | |||
69ec0bb134 | |||
3fb4d32922 | |||
641cd739c3 | |||
553affefa4 | |||
570a1e699c | |||
e107bcdef2 | |||
765d0e8f7a | |||
86446a9fac | |||
b2df8cade5 | |||
845ce25bb7 | |||
6cb8d59886 | |||
59d9cfa96d | |||
a7b6adae62 | |||
3b3a27efe1 | |||
ea9f664a06 | |||
32ca148d5c | |||
17ba481e71 | |||
8e2de8587e | |||
7816c3b48f | |||
3e25bd45f7 | |||
fcdca67c5b | |||
343e8299c7 | |||
2fae542f6a | |||
b3e3045211 | |||
ef57f27b38 | |||
ef8bba9818 | |||
e8f8a1ffac | |||
ebc20c139b | |||
7e9d9075d9 | |||
927fc619ef | |||
952857e721 | |||
78025bf922 | |||
4ee985fef3 | |||
0663b7aeb3 | |||
77435397cb | |||
137c317cc6 | |||
b4ca58d9a8 | |||
67bdd6ac14 | |||
1ace59fc98 | |||
f391001c10 | |||
d53be31f73 | |||
ebf3b0776a | |||
b7e997adba | |||
2d531230c5 | |||
52e2a0b2cf | |||
7331f36318 | |||
e54e4c64f8 | |||
7d1befb1db | |||
d252405747 | |||
33cdfc6485 | |||
1f2686e891 | |||
9435e7b687 | |||
91c05caaff | |||
de458e9b99 | |||
ffb876afa6 | |||
fc9d0bb99a | |||
55087c6cbd | |||
5aa704d5f7 | |||
b38d20e126 | |||
7ea9b420b0 | |||
33ddd7e51d | |||
fbbeef22d8 | |||
9f5c34698a | |||
5cc0c435b7 | |||
8f5e5e4110 | |||
ce4ceb6e9d | |||
f44e692540 | |||
3e0848bd04 | |||
7e66cb2e83 | |||
bf505cc66a | |||
10f2ae9e6c | |||
09cf3bba8d | |||
3293637e70 | |||
89727c901b | |||
6e73418647 | |||
1178d43d1a | |||
336f56391a | |||
39eae914f4 | |||
127ffdb35e | |||
c7960fbd89 | |||
ee96fe5c6d | |||
a89aab05cf | |||
630d67ce0d | |||
6fe8b4b7f3 | |||
ea2d0d3357 | |||
76bef1fe01 | |||
f60f61201c | |||
b0a23f2cff | |||
67c31d794e | |||
c0de8dc843 | |||
963f4dd80e | |||
6dd3c0f15d | |||
008178eee1 | |||
9fba53aa52 | |||
44fb676da2 | |||
78a882acdd | |||
abb1fcc365 | |||
76c906d779 | |||
823176c1ea | |||
a8d8776ec7 | |||
5e799d7992 | |||
8fc76f618e | |||
f5f0f80778 | |||
183b7a82f2 | |||
b1d507df79 | |||
4e2a7ac05b | |||
1e5d2fa8dd | |||
95271f8337 | |||
d8426940d7 | |||
70f7d52f88 | |||
cd79376546 | |||
e79634f61d | |||
e8f95dddb7 | |||
d3be73c664 | |||
a093521890 |
194
.gitignore
vendored
Normal file
194
.gitignore
vendored
Normal file
@ -0,0 +1,194 @@
|
||||
#ignore thumbnails created by windows
|
||||
Thumbs.db
|
||||
#Ignore files build by Visual Studio
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.lib
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
||||
.idea/
|
||||
*.opensdf
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
# User-specific folders
|
||||
*.sln.ide/
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
build/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
# Roslyn cache directories
|
||||
*.ide/
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
#NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
# JustCode is a .NET coding addin-in
|
||||
.JustCode
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
# Click-Once directory
|
||||
publish/
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# If using the old MSBuild-Integrated Package Restore, uncomment this:
|
||||
#!**/packages/repositories.config
|
||||
# Windows Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
bower_components/
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
*.suo
|
||||
*.vcxproj.filters
|
||||
*.npp
|
||||
CMakeFiles/*
|
||||
nbproject/*
|
||||
*.cd
|
||||
*.cd
|
||||
a.out
|
||||
cmake-build-debug/*
|
147
.travis.yml
Normal file
147
.travis.yml
Normal file
@ -0,0 +1,147 @@
|
||||
language: cpp
|
||||
|
||||
env:
|
||||
global:
|
||||
- CMAKE_EXTRA_CONF="-DCOMPILE_WITH_C_LOCALE=ON"
|
||||
- CTEST_OUTPUT_ON_FAILURE=1
|
||||
|
||||
matrix:
|
||||
include:
|
||||
|
||||
- name: "Ubuntu 16.04 LTS (Xenial Xerus) GCC 7"
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
|
||||
|
||||
- name: "Ubuntu 16.04 LTS (Xenial Xerus) GCC 8"
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
|
||||
|
||||
- name: "Ubuntu 16.04 LTS (Xenial Xerus) GCC 9"
|
||||
os: linux
|
||||
dist: xenial
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-9
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-9 && CXX=g++-9"
|
||||
|
||||
- name: "Ubuntu 18.04 LTS (Bionic Beaver) GCC 7"
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
|
||||
|
||||
- name: "Ubuntu 18.04 LTS (Bionic Beaver) GCC 8"
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
|
||||
|
||||
- name: "Ubuntu 18.04 LTS (Bionic Beaver) Clang 6"
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-bionic-6.0
|
||||
packages:
|
||||
- clang-6.0
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"
|
||||
|
||||
- name: "Ubuntu 18.04 LTS (Bionic Beaver) Clang 7"
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-bionic-7
|
||||
packages:
|
||||
- clang-7
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-7 && CXX=clang++-7"
|
||||
|
||||
- name: "Ubuntu 18.04 LTS (Bionic Beaver) Clang 8"
|
||||
os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-bionic-8
|
||||
packages:
|
||||
- clang-8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-8 && CXX=clang++-8"
|
||||
|
||||
- &macos
|
||||
name: xcode10
|
||||
os: osx
|
||||
osx_image: xcode10.2
|
||||
env:
|
||||
- CMAKE_EXTRA_CONF=""
|
||||
addons:
|
||||
homebrew:
|
||||
packages:
|
||||
- bash
|
||||
- ninja
|
||||
|
||||
- <<: *macos
|
||||
name: xcode9
|
||||
# xcode 9 only works if we tell it to use c++14 explicitly
|
||||
env:
|
||||
- CMAKE_EXTRA_CONF="-DCMAKE_CXX_STANDARD=14"
|
||||
osx_image: xcode9.4
|
||||
|
||||
- <<: *macos
|
||||
osx_image: xcode11
|
||||
name: xcode11
|
||||
|
||||
before_install:
|
||||
- eval "${MATRIX_EVAL}"
|
||||
- ci/install_cmake.sh 3.15.2
|
||||
- export OPENSSL_ROOT=$(brew --prefix openssl@1.1)
|
||||
- if [ "$(uname)" = "Darwin" ] ; then export PATH="$HOME/cmake/CMake.app/Contents/bin:${PATH}"; fi
|
||||
- if [ "$(uname)" = "Linux" ] ; then export PATH="$HOME/cmake/bin:${PATH}"; fi
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/cmake
|
||||
|
||||
script:
|
||||
- mkdir -p build
|
||||
- cd build
|
||||
- eval cmake -DENABLE_DATE_TESTING=ON -DBUILD_SHARED_LIBS=ON ${CMAKE_EXTRA_CONF} ..
|
||||
- cmake --build . --parallel
|
||||
- cmake --build . --parallel --target testit
|
||||
|
23
CMakeLists.txt
Normal file
23
CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
||||
if(DEFINED IDF_TARGET)
|
||||
idf_component_register(INCLUDE_DIRS include)
|
||||
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 23)
|
||||
target_compile_definitions(${COMPONENT_TARGET} INTERFACE HAS_UNCAUGHT_EXCEPTIONS=1)
|
||||
else()
|
||||
add_library(date
|
||||
include/date/chrono_io.h
|
||||
include/date/date.h
|
||||
include/date/ios.h
|
||||
include/date/islamic.h
|
||||
include/date/iso_week.h
|
||||
include/date/julian.h
|
||||
include/date/ptz.h
|
||||
include/date/solar_hijri.h
|
||||
include/date/tz.h
|
||||
include/date/tz_private.h
|
||||
src/tz.cpp
|
||||
)
|
||||
|
||||
target_include_directories(date PUBLIC
|
||||
include/
|
||||
)
|
||||
endif()
|
31
LICENSE.txt
Normal file
31
LICENSE.txt
Normal file
@ -0,0 +1,31 @@
|
||||
The source code in this project is released using the MIT License. There is no
|
||||
global license for the project because each file is licensed individually with
|
||||
different author names and/or dates.
|
||||
|
||||
If you contribute to this project, please add your name to the license of each
|
||||
file you modify. If you have already contributed to this project and forgot to
|
||||
add your name to the license, please feel free to submit a new P/R to add your
|
||||
name to the license in each file you modified.
|
||||
|
||||
For convenience, here is a copy of the MIT license found in each file except
|
||||
without author names or dates:
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
85
README.md
85
README.md
@ -1,11 +1,84 @@
|
||||
This is actually three separate C++11/C++14 libraries:
|
||||
# Date
|
||||
|
||||
1. `"date.h"` is a header-only library which builds upon `<chrono>`. It adds some new `duration` types, and new `time_point` types. It also adds "field" types such as `year_month_day` which is a struct `{year, month, day}`. And it provides convenient means to convert between the "field" types and the `time_point` types. See http://howardhinnant.github.io/date_v2.html for more details.
|
||||
[](https://travis-ci.org/HowardHinnant/date)
|
||||
[](https://gitter.im/HowardHinnant/date?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
Here is the Cppcon 2015 presentation on date.h: https://www.youtube.com/watch?v=tzyGjOm8AKo
|
||||
---
|
||||
|
||||
Here are the Cppcon 2015 slides on date.h: http://schd.ws/hosted_files/cppcon2015/43/hinnant_dates.pdf
|
||||
**[Try it out on wandbox!](https://wandbox.org/permlink/oyXjibyF680HHoyS)**
|
||||
|
||||
2. `"tz.h"` / `"tz.cpp"` are a timezone library built on top of the `"date.h"` library. This timezone library is a complete parser of the IANA timezone database. It provides for an easy way to access all of the data in this database, using the types from `"date.h"` and `<chrono>`. The IANA database also includes data on leap seconds, and this library provides utilities to compute with that information as well. See http://howardhinnant.github.io/tz.html for more details. See the `auto_download` branch for an experimental version of this library which auto-installs the latest version of the IANA timezone database (if you are connected to the internet).
|
||||
## Summary
|
||||
|
||||
3. `"iso_week.h"` is a header-only library built on top of the `"date.h"` library which implements the ISO week date calendar. See http://howardhinnant.github.io/iso_week.html for more details.
|
||||
This is actually several separate C++11/C++14/C++17 libraries:
|
||||
|
||||
1. `"date.h"` is a header-only library which builds upon `<chrono>`. It adds some new `duration` types, and new `time_point` types. It also adds "field" types such as `year_month_day` which is a struct `{year, month, day}`. And it provides convenient means to convert between the "field" types and the `time_point` types.
|
||||
|
||||
* Documentation: http://howardhinnant.github.io/date/date.html
|
||||
* Video: https://www.youtube.com/watch?v=tzyGjOm8AKo
|
||||
* Slides: http://schd.ws/hosted_files/cppcon2015/43/hinnant_dates.pdf
|
||||
|
||||
1. `"tz.h"` / `"tz.cpp"` are a timezone library built on top of the `"date.h"` library. This timezone library is a complete parser of the IANA timezone database. It provides for an easy way to access all of the data in this database, using the types from `"date.h"` and `<chrono>`. The IANA database also includes data on leap seconds, and this library provides utilities to compute with that information as well.
|
||||
|
||||
* Documentation: http://howardhinnant.github.io/date/tz.html
|
||||
* Video: https://www.youtube.com/watch?v=Vwd3pduVGKY
|
||||
* Slides: http://schd.ws/hosted_files/cppcon2016/0f/Welcome%20To%20The%20Time%20Zone%20-%20Howard%20Hinnant%20-%20CppCon%202016.pdf
|
||||
|
||||
1. `"iso_week.h"` is a header-only library built on top of the `"date.h"` library which implements the ISO week date calendar.
|
||||
|
||||
* Documentation: http://howardhinnant.github.io/date/iso_week.html
|
||||
|
||||
1. `"julian.h"` is a header-only library built on top of the `"date.h"` library which implements a proleptic Julian calendar which is fully interoperable with everything above.
|
||||
|
||||
* Documentation: http://howardhinnant.github.io/date/julian.html
|
||||
|
||||
1. `"islamic.h"` is a header-only library built on top of the `"date.h"` library which implements a proleptic Islamic calendar which is fully interoperable with everything above.
|
||||
|
||||
* Documentation: http://howardhinnant.github.io/date/islamic.html
|
||||
|
||||
## Standardization
|
||||
|
||||
Slightly modified versions of `"date.h"` and `"tz.h"` were voted into the C++20 working draft at the Jacksonville FL meeting on 2018-03-17:
|
||||
|
||||
* http://howardhinnant.github.io/date/d0355r7.html
|
||||
|
||||
## Build & Test
|
||||
|
||||
The recommended way to use any of these libraries besides `"tz.h"` is to just include it. These are header-only libraries (except `"tz.h"`).
|
||||
|
||||
To use `"tz.h"`, there is a single source file (`src/tz.cpp`) that needs to be compiled. Here are the recommended directions: https://howardhinnant.github.io/date/tz.html#Installation.
|
||||
|
||||
One can run tests by cd'ing into the `test` subdirectory and running `testit`. There are known failures on all platforms except for macOS. And even on macOS if C++11 is used. If any of these failures present problems for you, there exist workarounds.
|
||||
|
||||
Additionally there is unsupported support for [vcpkg](https://github.com/Microsoft/vcpkg) and [CMake](https://cmake.org/). I don't personally use or maintain these systems as for me they cause more problems than they solve (for this small project). If you would like to contribute to these build systems please feel free to file a PR.
|
||||
|
||||
You can download and install Date using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
vcpkg install date
|
||||
|
||||
The Date port in vcpkg is updated by Microsoft team members and community contributors. If the version falls behind, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
You can optionally build using [CMake](https://cmake.org/). Here is a guide of how to build and test using the CMake Makefile generator.
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ../
|
||||
cmake --build . --target testit # Consider '-- -j4' for multithreading
|
||||
```
|
||||
## Projects using this library
|
||||
|
||||
* www.safe.com
|
||||
* www.webtoolkit.eu/wt
|
||||
* https://github.com/ViewTouch/viewtouch
|
||||
* https://routinghub.com
|
||||
* https://github.com/valhalla
|
||||
* https://github.com/siodb/siodb
|
||||
* https://github.com/KomodoPlatform/atomicDEX-Pro
|
||||
* https://github.com/Kotlin/kotlinx-datetime
|
||||
* https://github.com/royalbee/jewish_date
|
||||
|
||||
If you would like your project (or product) on this list, just let me know.
|
||||
|
@ -1,453 +0,0 @@
|
||||
Copyright © 1991-2013 Unicode, Inc.
|
||||
CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
|
||||
For terms of use, see http://www.unicode.org/copyright.html
|
||||
|
||||
"AUS Central Standard Time","001","Australia/Darwin"
|
||||
"AUS Central Standard Time","AU","Australia/Darwin"
|
||||
"AUS Eastern Standard Time","001","Australia/Sydney"
|
||||
"AUS Eastern Standard Time","AU","Australia/Sydney Australia/Melbourne"
|
||||
"Afghanistan Standard Time","001","Asia/Kabul"
|
||||
"Afghanistan Standard Time","AF","Asia/Kabul"
|
||||
"Alaskan Standard Time","001","America/Anchorage"
|
||||
"Alaskan Standard Time","US","America/Anchorage America/Juneau America/Nome America/Sitka America/Yakutat"
|
||||
"Arab Standard Time","001","Asia/Riyadh"
|
||||
"Arab Standard Time","BH","Asia/Bahrain"
|
||||
"Arab Standard Time","KW","Asia/Kuwait"
|
||||
"Arab Standard Time","QA","Asia/Qatar"
|
||||
"Arab Standard Time","SA","Asia/Riyadh"
|
||||
"Arab Standard Time","YE","Asia/Aden"
|
||||
"Arabian Standard Time","001","Asia/Dubai"
|
||||
"Arabian Standard Time","AE","Asia/Dubai"
|
||||
"Arabian Standard Time","OM","Asia/Muscat"
|
||||
"Arabian Standard Time","ZZ","Etc/GMT-4"
|
||||
"Arabic Standard Time","001","Asia/Baghdad"
|
||||
"Arabic Standard Time","IQ","Asia/Baghdad"
|
||||
"Argentina Standard Time","001","America/Buenos_Aires"
|
||||
"Argentina Standard Time","AR","America/Buenos_Aires America/Argentina/La_Rioja America/Argentina/Rio_Gallegos America/Argentina/Salta America/Argentina/San_Juan America/Argentina/San_Luis America/Argentina/Tucuman America/Argentina/Ushuaia America/Catamarca America/Cordoba America/Jujuy America/Mendoza"
|
||||
"Atlantic Standard Time","001","America/Halifax"
|
||||
"Atlantic Standard Time","BM","Atlantic/Bermuda"
|
||||
"Atlantic Standard Time","CA","America/Halifax America/Glace_Bay America/Goose_Bay America/Moncton"
|
||||
"Atlantic Standard Time","GL","America/Thule"
|
||||
"Azerbaijan Standard Time","001","Asia/Baku"
|
||||
"Azerbaijan Standard Time","AZ","Asia/Baku"
|
||||
"Azores Standard Time","001","Atlantic/Azores"
|
||||
"Azores Standard Time","GL","America/Scoresbysund"
|
||||
"Azores Standard Time","PT","Atlantic/Azores"
|
||||
"Bahia Standard Time","001","America/Bahia"
|
||||
"Bahia Standard Time","BR","America/Bahia"
|
||||
"Bangladesh Standard Time","001","Asia/Dhaka"
|
||||
"Bangladesh Standard Time","BD","Asia/Dhaka"
|
||||
"Bangladesh Standard Time","BT","Asia/Thimphu"
|
||||
"Belarus Standard Time","001","Europe/Minsk"
|
||||
"Belarus Standard Time","BY","Europe/Minsk"
|
||||
"Canada Central Standard Time","001","America/Regina"
|
||||
"Canada Central Standard Time","CA","America/Regina America/Swift_Current"
|
||||
"Cape Verde Standard Time","001","Atlantic/Cape_Verde"
|
||||
"Cape Verde Standard Time","CV","Atlantic/Cape_Verde"
|
||||
"Cape Verde Standard Time","ZZ","Etc/GMT+1"
|
||||
"Caucasus Standard Time","001","Asia/Yerevan"
|
||||
"Caucasus Standard Time","AM","Asia/Yerevan"
|
||||
"Cen. Australia Standard Time","001","Australia/Adelaide"
|
||||
"Cen. Australia Standard Time","AU","Australia/Adelaide Australia/Broken_Hill"
|
||||
"Central America Standard Time","001","America/Guatemala"
|
||||
"Central America Standard Time","BZ","America/Belize"
|
||||
"Central America Standard Time","CR","America/Costa_Rica"
|
||||
"Central America Standard Time","EC","Pacific/Galapagos"
|
||||
"Central America Standard Time","GT","America/Guatemala"
|
||||
"Central America Standard Time","HN","America/Tegucigalpa"
|
||||
"Central America Standard Time","NI","America/Managua"
|
||||
"Central America Standard Time","SV","America/El_Salvador"
|
||||
"Central America Standard Time","ZZ","Etc/GMT+6"
|
||||
"Central Asia Standard Time","001","Asia/Almaty"
|
||||
"Central Asia Standard Time","AQ","Antarctica/Vostok"
|
||||
"Central Asia Standard Time","CN","Asia/Urumqi"
|
||||
"Central Asia Standard Time","IO","Indian/Chagos"
|
||||
"Central Asia Standard Time","KG","Asia/Bishkek"
|
||||
"Central Asia Standard Time","KZ","Asia/Almaty Asia/Qyzylorda"
|
||||
"Central Asia Standard Time","ZZ","Etc/GMT-6"
|
||||
"Central Brazilian Standard Time","001","America/Cuiaba"
|
||||
"Central Brazilian Standard Time","BR","America/Cuiaba America/Campo_Grande"
|
||||
"Central Europe Standard Time","001","Europe/Budapest"
|
||||
"Central Europe Standard Time","AL","Europe/Tirane"
|
||||
"Central Europe Standard Time","CZ","Europe/Prague"
|
||||
"Central Europe Standard Time","HU","Europe/Budapest"
|
||||
"Central Europe Standard Time","ME","Europe/Podgorica"
|
||||
"Central Europe Standard Time","RS","Europe/Belgrade"
|
||||
"Central Europe Standard Time","SI","Europe/Ljubljana"
|
||||
"Central Europe Standard Time","SK","Europe/Bratislava"
|
||||
"Central European Standard Time","001","Europe/Warsaw"
|
||||
"Central European Standard Time","BA","Europe/Sarajevo"
|
||||
"Central European Standard Time","HR","Europe/Zagreb"
|
||||
"Central European Standard Time","MK","Europe/Skopje"
|
||||
"Central European Standard Time","PL","Europe/Warsaw"
|
||||
"Central Pacific Standard Time","001","Pacific/Guadalcanal"
|
||||
"Central Pacific Standard Time","AU","Antarctica/Macquarie"
|
||||
"Central Pacific Standard Time","FM","Pacific/Ponape Pacific/Kosrae"
|
||||
"Central Pacific Standard Time","NC","Pacific/Noumea"
|
||||
"Central Pacific Standard Time","PG","Pacific/Bougainville"
|
||||
"Central Pacific Standard Time","SB","Pacific/Guadalcanal"
|
||||
"Central Pacific Standard Time","VU","Pacific/Efate"
|
||||
"Central Pacific Standard Time","ZZ","Etc/GMT-11"
|
||||
"Central Standard Time","001","America/Chicago"
|
||||
"Central Standard Time","CA","America/Winnipeg America/Rainy_River America/Rankin_Inlet America/Resolute"
|
||||
"Central Standard Time","MX","America/Matamoros"
|
||||
"Central Standard Time","US","America/Chicago America/Indiana/Knox America/Indiana/Tell_City America/Menominee America/North_Dakota/Beulah America/North_Dakota/Center America/North_Dakota/New_Salem"
|
||||
"Central Standard Time","ZZ","CST6CDT"
|
||||
"Central Standard Time (Mexico)","001","America/Mexico_City"
|
||||
"Central Standard Time (Mexico)","MX","America/Mexico_City America/Bahia_Banderas America/Merida America/Monterrey"
|
||||
"China Standard Time","001","Asia/Shanghai"
|
||||
"China Standard Time","CN","Asia/Shanghai"
|
||||
"China Standard Time","HK","Asia/Hong_Kong"
|
||||
"China Standard Time","MO","Asia/Macau"
|
||||
"Dateline Standard Time","001","Etc/GMT+12"
|
||||
"Dateline Standard Time","ZZ","Etc/GMT+12"
|
||||
"E. Africa Standard Time","001","Africa/Nairobi"
|
||||
"E. Africa Standard Time","AQ","Antarctica/Syowa"
|
||||
"E. Africa Standard Time","DJ","Africa/Djibouti"
|
||||
"E. Africa Standard Time","ER","Africa/Asmera"
|
||||
"E. Africa Standard Time","ET","Africa/Addis_Ababa"
|
||||
"E. Africa Standard Time","KE","Africa/Nairobi"
|
||||
"E. Africa Standard Time","KM","Indian/Comoro"
|
||||
"E. Africa Standard Time","MG","Indian/Antananarivo"
|
||||
"E. Africa Standard Time","SD","Africa/Khartoum"
|
||||
"E. Africa Standard Time","SO","Africa/Mogadishu"
|
||||
"E. Africa Standard Time","SS","Africa/Juba"
|
||||
"E. Africa Standard Time","TZ","Africa/Dar_es_Salaam"
|
||||
"E. Africa Standard Time","UG","Africa/Kampala"
|
||||
"E. Africa Standard Time","YT","Indian/Mayotte"
|
||||
"E. Africa Standard Time","ZZ","Etc/GMT-3"
|
||||
"E. Australia Standard Time","001","Australia/Brisbane"
|
||||
"E. Australia Standard Time","AU","Australia/Brisbane Australia/Lindeman"
|
||||
"E. South America Standard Time","001","America/Sao_Paulo"
|
||||
"E. South America Standard Time","BR","America/Sao_Paulo"
|
||||
"Eastern Standard Time","001","America/New_York"
|
||||
"Eastern Standard Time","BS","America/Nassau"
|
||||
"Eastern Standard Time","CA","America/Toronto America/Iqaluit America/Montreal America/Nipigon America/Pangnirtung America/Thunder_Bay"
|
||||
"Eastern Standard Time","CU","America/Havana"
|
||||
"Eastern Standard Time","HT","America/Port-au-Prince"
|
||||
"Eastern Standard Time","US","America/New_York America/Detroit America/Indiana/Petersburg America/Indiana/Vincennes America/Indiana/Winamac America/Kentucky/Monticello America/Louisville"
|
||||
"Eastern Standard Time","ZZ","EST5EDT"
|
||||
"Eastern Standard Time (Mexico)","001","America/Cancun"
|
||||
"Eastern Standard Time (Mexico)","MX","America/Cancun"
|
||||
"Egypt Standard Time","001","Africa/Cairo"
|
||||
"Egypt Standard Time","EG","Africa/Cairo"
|
||||
"Ekaterinburg Standard Time","001","Asia/Yekaterinburg"
|
||||
"Ekaterinburg Standard Time","RU","Asia/Yekaterinburg"
|
||||
"FLE Standard Time","001","Europe/Kiev"
|
||||
"FLE Standard Time","AX","Europe/Mariehamn"
|
||||
"FLE Standard Time","BG","Europe/Sofia"
|
||||
"FLE Standard Time","EE","Europe/Tallinn"
|
||||
"FLE Standard Time","FI","Europe/Helsinki"
|
||||
"FLE Standard Time","LT","Europe/Vilnius"
|
||||
"FLE Standard Time","LV","Europe/Riga"
|
||||
"FLE Standard Time","UA","Europe/Kiev Europe/Uzhgorod Europe/Zaporozhye"
|
||||
"Fiji Standard Time","001","Pacific/Fiji"
|
||||
"Fiji Standard Time","FJ","Pacific/Fiji"
|
||||
"GMT Standard Time","001","Europe/London"
|
||||
"GMT Standard Time","ES","Atlantic/Canary"
|
||||
"GMT Standard Time","FO","Atlantic/Faeroe"
|
||||
"GMT Standard Time","GB","Europe/London"
|
||||
"GMT Standard Time","GG","Europe/Guernsey"
|
||||
"GMT Standard Time","IE","Europe/Dublin"
|
||||
"GMT Standard Time","IM","Europe/Isle_of_Man"
|
||||
"GMT Standard Time","JE","Europe/Jersey"
|
||||
"GMT Standard Time","PT","Europe/Lisbon Atlantic/Madeira"
|
||||
"GTB Standard Time","001","Europe/Bucharest"
|
||||
"GTB Standard Time","CY","Asia/Nicosia"
|
||||
"GTB Standard Time","GR","Europe/Athens"
|
||||
"GTB Standard Time","MD","Europe/Chisinau"
|
||||
"GTB Standard Time","RO","Europe/Bucharest"
|
||||
"Georgian Standard Time","001","Asia/Tbilisi"
|
||||
"Georgian Standard Time","GE","Asia/Tbilisi"
|
||||
"Greenland Standard Time","001","America/Godthab"
|
||||
"Greenland Standard Time","GL","America/Godthab"
|
||||
"Greenwich Standard Time","001","Atlantic/Reykjavik"
|
||||
"Greenwich Standard Time","BF","Africa/Ouagadougou"
|
||||
"Greenwich Standard Time","CI","Africa/Abidjan"
|
||||
"Greenwich Standard Time","GH","Africa/Accra"
|
||||
"Greenwich Standard Time","GM","Africa/Banjul"
|
||||
"Greenwich Standard Time","GN","Africa/Conakry"
|
||||
"Greenwich Standard Time","GW","Africa/Bissau"
|
||||
"Greenwich Standard Time","IS","Atlantic/Reykjavik"
|
||||
"Greenwich Standard Time","LR","Africa/Monrovia"
|
||||
"Greenwich Standard Time","ML","Africa/Bamako"
|
||||
"Greenwich Standard Time","MR","Africa/Nouakchott"
|
||||
"Greenwich Standard Time","SH","Atlantic/St_Helena"
|
||||
"Greenwich Standard Time","SL","Africa/Freetown"
|
||||
"Greenwich Standard Time","SN","Africa/Dakar"
|
||||
"Greenwich Standard Time","ST","Africa/Sao_Tome"
|
||||
"Greenwich Standard Time","TG","Africa/Lome"
|
||||
"Hawaiian Standard Time","001","Pacific/Honolulu"
|
||||
"Hawaiian Standard Time","CK","Pacific/Rarotonga"
|
||||
"Hawaiian Standard Time","PF","Pacific/Tahiti"
|
||||
"Hawaiian Standard Time","UM","Pacific/Johnston"
|
||||
"Hawaiian Standard Time","US","Pacific/Honolulu"
|
||||
"Hawaiian Standard Time","ZZ","Etc/GMT+10"
|
||||
"India Standard Time","001","Asia/Calcutta"
|
||||
"India Standard Time","IN","Asia/Calcutta"
|
||||
"Iran Standard Time","001","Asia/Tehran"
|
||||
"Iran Standard Time","IR","Asia/Tehran"
|
||||
"Israel Standard Time","001","Asia/Jerusalem"
|
||||
"Israel Standard Time","IL","Asia/Jerusalem"
|
||||
"Jordan Standard Time","001","Asia/Amman"
|
||||
"Jordan Standard Time","JO","Asia/Amman"
|
||||
"Kaliningrad Standard Time","001","Europe/Kaliningrad"
|
||||
"Kaliningrad Standard Time","RU","Europe/Kaliningrad"
|
||||
"Korea Standard Time","001","Asia/Seoul"
|
||||
"Korea Standard Time","KP","Asia/Pyongyang"
|
||||
"Korea Standard Time","KR","Asia/Seoul"
|
||||
"Libya Standard Time","001","Africa/Tripoli"
|
||||
"Libya Standard Time","LY","Africa/Tripoli"
|
||||
"Line Islands Standard Time","001","Pacific/Kiritimati"
|
||||
"Line Islands Standard Time","KI","Pacific/Kiritimati"
|
||||
"Line Islands Standard Time","ZZ","Etc/GMT-14"
|
||||
"Magadan Standard Time","001","Asia/Magadan"
|
||||
"Magadan Standard Time","RU","Asia/Magadan"
|
||||
"Mauritius Standard Time","001","Indian/Mauritius"
|
||||
"Mauritius Standard Time","MU","Indian/Mauritius"
|
||||
"Mauritius Standard Time","RE","Indian/Reunion"
|
||||
"Mauritius Standard Time","SC","Indian/Mahe"
|
||||
"Middle East Standard Time","001","Asia/Beirut"
|
||||
"Middle East Standard Time","LB","Asia/Beirut"
|
||||
"Montevideo Standard Time","001","America/Montevideo"
|
||||
"Montevideo Standard Time","UY","America/Montevideo"
|
||||
"Morocco Standard Time","001","Africa/Casablanca"
|
||||
"Morocco Standard Time","EH","Africa/El_Aaiun"
|
||||
"Morocco Standard Time","MA","Africa/Casablanca"
|
||||
"Mountain Standard Time","001","America/Denver"
|
||||
"Mountain Standard Time","CA","America/Edmonton America/Cambridge_Bay America/Inuvik America/Yellowknife"
|
||||
"Mountain Standard Time","MX","America/Ojinaga"
|
||||
"Mountain Standard Time","US","America/Denver America/Boise"
|
||||
"Mountain Standard Time","ZZ","MST7MDT"
|
||||
"Mountain Standard Time (Mexico)","001","America/Chihuahua"
|
||||
"Mountain Standard Time (Mexico)","MX","America/Chihuahua America/Mazatlan"
|
||||
"Myanmar Standard Time","001","Asia/Rangoon"
|
||||
"Myanmar Standard Time","CC","Indian/Cocos"
|
||||
"Myanmar Standard Time","MM","Asia/Rangoon"
|
||||
"N. Central Asia Standard Time","001","Asia/Novosibirsk"
|
||||
"N. Central Asia Standard Time","RU","Asia/Novosibirsk Asia/Omsk"
|
||||
"Namibia Standard Time","001","Africa/Windhoek"
|
||||
"Namibia Standard Time","NA","Africa/Windhoek"
|
||||
"Nepal Standard Time","001","Asia/Katmandu"
|
||||
"Nepal Standard Time","NP","Asia/Katmandu"
|
||||
"New Zealand Standard Time","001","Pacific/Auckland"
|
||||
"New Zealand Standard Time","AQ","Antarctica/McMurdo"
|
||||
"New Zealand Standard Time","NZ","Pacific/Auckland"
|
||||
"Newfoundland Standard Time","001","America/St_Johns"
|
||||
"Newfoundland Standard Time","CA","America/St_Johns"
|
||||
"North Asia East Standard Time","001","Asia/Irkutsk"
|
||||
"North Asia East Standard Time","RU","Asia/Irkutsk Asia/Chita"
|
||||
"North Asia Standard Time","001","Asia/Krasnoyarsk"
|
||||
"North Asia Standard Time","RU","Asia/Krasnoyarsk Asia/Novokuznetsk"
|
||||
"Pacific SA Standard Time","001","America/Santiago"
|
||||
"Pacific SA Standard Time","AQ","Antarctica/Palmer"
|
||||
"Pacific SA Standard Time","CL","America/Santiago"
|
||||
"Pacific Standard Time","001","America/Los_Angeles"
|
||||
"Pacific Standard Time","CA","America/Vancouver America/Dawson America/Whitehorse"
|
||||
"Pacific Standard Time","MX","America/Tijuana"
|
||||
"Pacific Standard Time","US","America/Los_Angeles"
|
||||
"Pacific Standard Time","ZZ","PST8PDT"
|
||||
"Pacific Standard Time (Mexico)","001","America/Santa_Isabel"
|
||||
"Pacific Standard Time (Mexico)","MX","America/Santa_Isabel"
|
||||
"Pakistan Standard Time","001","Asia/Karachi"
|
||||
"Pakistan Standard Time","PK","Asia/Karachi"
|
||||
"Paraguay Standard Time","001","America/Asuncion"
|
||||
"Paraguay Standard Time","PY","America/Asuncion"
|
||||
"Romance Standard Time","001","Europe/Paris"
|
||||
"Romance Standard Time","BE","Europe/Brussels"
|
||||
"Romance Standard Time","DK","Europe/Copenhagen"
|
||||
"Romance Standard Time","ES","Europe/Madrid Africa/Ceuta"
|
||||
"Romance Standard Time","FR","Europe/Paris"
|
||||
"Russia Time Zone 10","001","Asia/Srednekolymsk"
|
||||
"Russia Time Zone 10","RU","Asia/Srednekolymsk"
|
||||
"Russia Time Zone 11","001","Asia/Kamchatka"
|
||||
"Russia Time Zone 11","RU","Asia/Kamchatka Asia/Anadyr"
|
||||
"Russia Time Zone 3","001","Europe/Samara"
|
||||
"Russia Time Zone 3","RU","Europe/Samara"
|
||||
"Russian Standard Time","001","Europe/Moscow"
|
||||
"Russian Standard Time","RU","Europe/Moscow Europe/Simferopol Europe/Volgograd"
|
||||
"SA Eastern Standard Time","001","America/Cayenne"
|
||||
"SA Eastern Standard Time","AQ","Antarctica/Rothera"
|
||||
"SA Eastern Standard Time","BR","America/Fortaleza America/Araguaina America/Belem America/Maceio America/Recife America/Santarem"
|
||||
"SA Eastern Standard Time","FK","Atlantic/Stanley"
|
||||
"SA Eastern Standard Time","GF","America/Cayenne"
|
||||
"SA Eastern Standard Time","SR","America/Paramaribo"
|
||||
"SA Eastern Standard Time","ZZ","Etc/GMT+3"
|
||||
"SA Pacific Standard Time","001","America/Bogota"
|
||||
"SA Pacific Standard Time","BR","America/Rio_Branco America/Eirunepe"
|
||||
"SA Pacific Standard Time","CA","America/Coral_Harbour"
|
||||
"SA Pacific Standard Time","CO","America/Bogota"
|
||||
"SA Pacific Standard Time","EC","America/Guayaquil"
|
||||
"SA Pacific Standard Time","JM","America/Jamaica"
|
||||
"SA Pacific Standard Time","KY","America/Cayman"
|
||||
"SA Pacific Standard Time","PA","America/Panama"
|
||||
"SA Pacific Standard Time","PE","America/Lima"
|
||||
"SA Pacific Standard Time","ZZ","Etc/GMT+5"
|
||||
"SA Western Standard Time","001","America/La_Paz"
|
||||
"SA Western Standard Time","AG","America/Antigua"
|
||||
"SA Western Standard Time","AI","America/Anguilla"
|
||||
"SA Western Standard Time","AW","America/Aruba"
|
||||
"SA Western Standard Time","BB","America/Barbados"
|
||||
"SA Western Standard Time","BL","America/St_Barthelemy"
|
||||
"SA Western Standard Time","BO","America/La_Paz"
|
||||
"SA Western Standard Time","BQ","America/Kralendijk"
|
||||
"SA Western Standard Time","BR","America/Manaus America/Boa_Vista America/Porto_Velho"
|
||||
"SA Western Standard Time","CA","America/Blanc-Sablon"
|
||||
"SA Western Standard Time","CW","America/Curacao"
|
||||
"SA Western Standard Time","DM","America/Dominica"
|
||||
"SA Western Standard Time","DO","America/Santo_Domingo"
|
||||
"SA Western Standard Time","GD","America/Grenada"
|
||||
"SA Western Standard Time","GP","America/Guadeloupe"
|
||||
"SA Western Standard Time","GY","America/Guyana"
|
||||
"SA Western Standard Time","KN","America/St_Kitts"
|
||||
"SA Western Standard Time","LC","America/St_Lucia"
|
||||
"SA Western Standard Time","MF","America/Marigot"
|
||||
"SA Western Standard Time","MQ","America/Martinique"
|
||||
"SA Western Standard Time","MS","America/Montserrat"
|
||||
"SA Western Standard Time","PR","America/Puerto_Rico"
|
||||
"SA Western Standard Time","SX","America/Lower_Princes"
|
||||
"SA Western Standard Time","TC","America/Grand_Turk"
|
||||
"SA Western Standard Time","TT","America/Port_of_Spain"
|
||||
"SA Western Standard Time","VC","America/St_Vincent"
|
||||
"SA Western Standard Time","VG","America/Tortola"
|
||||
"SA Western Standard Time","VI","America/St_Thomas"
|
||||
"SA Western Standard Time","ZZ","Etc/GMT+4"
|
||||
"SE Asia Standard Time","001","Asia/Bangkok"
|
||||
"SE Asia Standard Time","AQ","Antarctica/Davis"
|
||||
"SE Asia Standard Time","CX","Indian/Christmas"
|
||||
"SE Asia Standard Time","ID","Asia/Jakarta Asia/Pontianak"
|
||||
"SE Asia Standard Time","KH","Asia/Phnom_Penh"
|
||||
"SE Asia Standard Time","LA","Asia/Vientiane"
|
||||
"SE Asia Standard Time","MN","Asia/Hovd"
|
||||
"SE Asia Standard Time","TH","Asia/Bangkok"
|
||||
"SE Asia Standard Time","VN","Asia/Saigon"
|
||||
"SE Asia Standard Time","ZZ","Etc/GMT-7"
|
||||
"Samoa Standard Time","001","Pacific/Apia"
|
||||
"Samoa Standard Time","WS","Pacific/Apia"
|
||||
"Singapore Standard Time","001","Asia/Singapore"
|
||||
"Singapore Standard Time","BN","Asia/Brunei"
|
||||
"Singapore Standard Time","ID","Asia/Makassar"
|
||||
"Singapore Standard Time","MY","Asia/Kuala_Lumpur Asia/Kuching"
|
||||
"Singapore Standard Time","PH","Asia/Manila"
|
||||
"Singapore Standard Time","SG","Asia/Singapore"
|
||||
"Singapore Standard Time","ZZ","Etc/GMT-8"
|
||||
"South Africa Standard Time","001","Africa/Johannesburg"
|
||||
"South Africa Standard Time","BI","Africa/Bujumbura"
|
||||
"South Africa Standard Time","BW","Africa/Gaborone"
|
||||
"South Africa Standard Time","CD","Africa/Lubumbashi"
|
||||
"South Africa Standard Time","LS","Africa/Maseru"
|
||||
"South Africa Standard Time","MW","Africa/Blantyre"
|
||||
"South Africa Standard Time","MZ","Africa/Maputo"
|
||||
"South Africa Standard Time","RW","Africa/Kigali"
|
||||
"South Africa Standard Time","SZ","Africa/Mbabane"
|
||||
"South Africa Standard Time","ZA","Africa/Johannesburg"
|
||||
"South Africa Standard Time","ZM","Africa/Lusaka"
|
||||
"South Africa Standard Time","ZW","Africa/Harare"
|
||||
"South Africa Standard Time","ZZ","Etc/GMT-2"
|
||||
"Sri Lanka Standard Time","001","Asia/Colombo"
|
||||
"Sri Lanka Standard Time","LK","Asia/Colombo"
|
||||
"Syria Standard Time","001","Asia/Damascus"
|
||||
"Syria Standard Time","SY","Asia/Damascus"
|
||||
"Taipei Standard Time","001","Asia/Taipei"
|
||||
"Taipei Standard Time","TW","Asia/Taipei"
|
||||
"Tasmania Standard Time","001","Australia/Hobart"
|
||||
"Tasmania Standard Time","AU","Australia/Hobart Australia/Currie"
|
||||
"Tokyo Standard Time","001","Asia/Tokyo"
|
||||
"Tokyo Standard Time","ID","Asia/Jayapura"
|
||||
"Tokyo Standard Time","JP","Asia/Tokyo"
|
||||
"Tokyo Standard Time","PW","Pacific/Palau"
|
||||
"Tokyo Standard Time","TL","Asia/Dili"
|
||||
"Tokyo Standard Time","ZZ","Etc/GMT-9"
|
||||
"Tonga Standard Time","001","Pacific/Tongatapu"
|
||||
"Tonga Standard Time","KI","Pacific/Enderbury"
|
||||
"Tonga Standard Time","TK","Pacific/Fakaofo"
|
||||
"Tonga Standard Time","TO","Pacific/Tongatapu"
|
||||
"Tonga Standard Time","ZZ","Etc/GMT-13"
|
||||
"Turkey Standard Time","001","Europe/Istanbul"
|
||||
"Turkey Standard Time","TR","Europe/Istanbul"
|
||||
"US Eastern Standard Time","001","America/Indianapolis"
|
||||
"US Eastern Standard Time","US","America/Indianapolis America/Indiana/Marengo America/Indiana/Vevay"
|
||||
"US Mountain Standard Time","001","America/Phoenix"
|
||||
"US Mountain Standard Time","CA","America/Dawson_Creek America/Creston"
|
||||
"US Mountain Standard Time","MX","America/Hermosillo"
|
||||
"US Mountain Standard Time","US","America/Phoenix"
|
||||
"US Mountain Standard Time","ZZ","Etc/GMT+7"
|
||||
"UTC","001","Etc/GMT"
|
||||
"UTC","GL","America/Danmarkshavn"
|
||||
"UTC","ZZ","Etc/GMT"
|
||||
"UTC+12","001","Etc/GMT-12"
|
||||
"UTC+12","KI","Pacific/Tarawa"
|
||||
"UTC+12","MH","Pacific/Majuro Pacific/Kwajalein"
|
||||
"UTC+12","NR","Pacific/Nauru"
|
||||
"UTC+12","TV","Pacific/Funafuti"
|
||||
"UTC+12","UM","Pacific/Wake"
|
||||
"UTC+12","WF","Pacific/Wallis"
|
||||
"UTC+12","ZZ","Etc/GMT-12"
|
||||
"UTC-02","001","Etc/GMT+2"
|
||||
"UTC-02","BR","America/Noronha"
|
||||
"UTC-02","GS","Atlantic/South_Georgia"
|
||||
"UTC-02","ZZ","Etc/GMT+2"
|
||||
"UTC-11","001","Etc/GMT+11"
|
||||
"UTC-11","AS","Pacific/Pago_Pago"
|
||||
"UTC-11","NU","Pacific/Niue"
|
||||
"UTC-11","UM","Pacific/Midway"
|
||||
"UTC-11","ZZ","Etc/GMT+11"
|
||||
"Ulaanbaatar Standard Time","001","Asia/Ulaanbaatar"
|
||||
"Ulaanbaatar Standard Time","MN","Asia/Ulaanbaatar Asia/Choibalsan"
|
||||
"Venezuela Standard Time","001","America/Caracas"
|
||||
"Venezuela Standard Time","VE","America/Caracas"
|
||||
"Vladivostok Standard Time","001","Asia/Vladivostok"
|
||||
"Vladivostok Standard Time","RU","Asia/Vladivostok Asia/Sakhalin Asia/Ust-Nera"
|
||||
"W. Australia Standard Time","001","Australia/Perth"
|
||||
"W. Australia Standard Time","AQ","Antarctica/Casey"
|
||||
"W. Australia Standard Time","AU","Australia/Perth"
|
||||
"W. Central Africa Standard Time","001","Africa/Lagos"
|
||||
"W. Central Africa Standard Time","AO","Africa/Luanda"
|
||||
"W. Central Africa Standard Time","BJ","Africa/Porto-Novo"
|
||||
"W. Central Africa Standard Time","CD","Africa/Kinshasa"
|
||||
"W. Central Africa Standard Time","CF","Africa/Bangui"
|
||||
"W. Central Africa Standard Time","CG","Africa/Brazzaville"
|
||||
"W. Central Africa Standard Time","CM","Africa/Douala"
|
||||
"W. Central Africa Standard Time","DZ","Africa/Algiers"
|
||||
"W. Central Africa Standard Time","GA","Africa/Libreville"
|
||||
"W. Central Africa Standard Time","GQ","Africa/Malabo"
|
||||
"W. Central Africa Standard Time","NE","Africa/Niamey"
|
||||
"W. Central Africa Standard Time","NG","Africa/Lagos"
|
||||
"W. Central Africa Standard Time","TD","Africa/Ndjamena"
|
||||
"W. Central Africa Standard Time","TN","Africa/Tunis"
|
||||
"W. Central Africa Standard Time","ZZ","Etc/GMT-1"
|
||||
"W. Europe Standard Time","001","Europe/Berlin"
|
||||
"W. Europe Standard Time","AD","Europe/Andorra"
|
||||
"W. Europe Standard Time","AT","Europe/Vienna"
|
||||
"W. Europe Standard Time","CH","Europe/Zurich"
|
||||
"W. Europe Standard Time","DE","Europe/Berlin Europe/Busingen"
|
||||
"W. Europe Standard Time","GI","Europe/Gibraltar"
|
||||
"W. Europe Standard Time","IT","Europe/Rome"
|
||||
"W. Europe Standard Time","LI","Europe/Vaduz"
|
||||
"W. Europe Standard Time","LU","Europe/Luxembourg"
|
||||
"W. Europe Standard Time","MC","Europe/Monaco"
|
||||
"W. Europe Standard Time","MT","Europe/Malta"
|
||||
"W. Europe Standard Time","NL","Europe/Amsterdam"
|
||||
"W. Europe Standard Time","NO","Europe/Oslo"
|
||||
"W. Europe Standard Time","SE","Europe/Stockholm"
|
||||
"W. Europe Standard Time","SJ","Arctic/Longyearbyen"
|
||||
"W. Europe Standard Time","SM","Europe/San_Marino"
|
||||
"W. Europe Standard Time","VA","Europe/Vatican"
|
||||
"West Asia Standard Time","001","Asia/Tashkent"
|
||||
"West Asia Standard Time","AQ","Antarctica/Mawson"
|
||||
"West Asia Standard Time","KZ","Asia/Oral Asia/Aqtau Asia/Aqtobe"
|
||||
"West Asia Standard Time","MV","Indian/Maldives"
|
||||
"West Asia Standard Time","TF","Indian/Kerguelen"
|
||||
"West Asia Standard Time","TJ","Asia/Dushanbe"
|
||||
"West Asia Standard Time","TM","Asia/Ashgabat"
|
||||
"West Asia Standard Time","UZ","Asia/Tashkent Asia/Samarkand"
|
||||
"West Asia Standard Time","ZZ","Etc/GMT-5"
|
||||
"West Pacific Standard Time","001","Pacific/Port_Moresby"
|
||||
"West Pacific Standard Time","AQ","Antarctica/DumontDUrville"
|
||||
"West Pacific Standard Time","FM","Pacific/Truk"
|
||||
"West Pacific Standard Time","GU","Pacific/Guam"
|
||||
"West Pacific Standard Time","MP","Pacific/Saipan"
|
||||
"West Pacific Standard Time","PG","Pacific/Port_Moresby"
|
||||
"West Pacific Standard Time","ZZ","Etc/GMT-10"
|
||||
"Yakutsk Standard Time","001","Asia/Yakutsk"
|
||||
"Yakutsk Standard Time","RU","Asia/Yakutsk Asia/Khandyga"
|
Can't render this file because it has a wrong number of fields in line 2.
|
34
ci/install_cmake.sh
Executable file
34
ci/install_cmake.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
IFS=. read cm_maj cm_min cm_rel <<<"$1"
|
||||
: ${cm_rel:-0}
|
||||
CMAKE_ROOT=${2:-"${HOME}/cmake"}
|
||||
|
||||
function cmake_version ()
|
||||
{
|
||||
if [[ -d ${CMAKE_ROOT} ]] ; then
|
||||
local perms=$(test $(uname) = "Linux" && echo "/111" || echo "+111")
|
||||
local installed=$(find ${CMAKE_ROOT} -perm ${perms} -type f -name cmake)
|
||||
if [[ "${installed}" != "" ]] ; then
|
||||
echo "$(${installed} --version | head -1)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
installed=$(cmake_version)
|
||||
if [[ "${installed}" != "" && ${installed} =~ ${cm_maj}.${cm_min}.${cm_rel} ]] ; then
|
||||
echo "cmake already installed: ${installed}"
|
||||
exit
|
||||
fi
|
||||
|
||||
pkgname="cmake-${cm_maj}.${cm_min}.${cm_rel}-$(uname)-x86_64.tar.gz"
|
||||
tmppkg="/tmp/cmake.tar.gz"
|
||||
wget --quiet https://cmake.org/files/v${cm_maj}.${cm_min}/${pkgname} -O ${tmppkg}
|
||||
mkdir -p ${CMAKE_ROOT}
|
||||
cd ${CMAKE_ROOT}
|
||||
tar --strip-components 1 -xf ${tmppkg}
|
||||
rm -f ${tmppkg}
|
||||
echo "installed: $(cmake_version)"
|
||||
|
||||
|
11
cmake/dateConfig.cmake
Normal file
11
cmake/dateConfig.cmake
Normal file
@ -0,0 +1,11 @@
|
||||
include( CMakeFindDependencyMacro )
|
||||
include( "${CMAKE_CURRENT_LIST_DIR}/dateTargets.cmake" )
|
||||
if( NOT MSVC AND TARGET date::date-tz )
|
||||
find_dependency( Threads REQUIRED)
|
||||
get_target_property( _tzill date::date-tz INTERFACE_LINK_LIBRARIES )
|
||||
if( _tzill AND "${_tzill}" MATCHES "libcurl" )
|
||||
find_dependency( CURL )
|
||||
endif( )
|
||||
endif( )
|
||||
|
||||
|
16
compile_fail.sh
Executable file
16
compile_fail.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
export TEST_BIN_NAME=$1
|
||||
#echo "Building ${TEST_BIN_NAME}"
|
||||
shift 1
|
||||
export BUILD_COMMAND=$@
|
||||
#echo "Build command: ${BUILD_COMMAND}"
|
||||
eval ${BUILD_COMMAND} >/dev/null 2>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -ne "#!/bin/bash\nexit 1;" > ${TEST_BIN_NAME}
|
||||
else
|
||||
echo -ne "#!/bin/bash\nexit 0;" > ${TEST_BIN_NAME}
|
||||
fi
|
||||
chmod u+x ${TEST_BIN_NAME}
|
||||
exit 0;
|
||||
|
34
include/date/chrono_io.h
Normal file
34
include/date/chrono_io.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef CHRONO_IO_H
|
||||
#define CHRONO_IO_H
|
||||
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2016, 2017 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// Our apologies. When the previous paragraph was written, lowercase had not yet
|
||||
// been invented (that would involve another several millennia of evolution).
|
||||
// We did not mean to shout.
|
||||
|
||||
// This functionality has moved to "date.h"
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#endif // CHRONO_IO_H
|
8008
include/date/date.h
Normal file
8008
include/date/date.h
Normal file
File diff suppressed because it is too large
Load Diff
50
include/date/ios.h
Normal file
50
include/date/ios.h
Normal file
@ -0,0 +1,50 @@
|
||||
//
|
||||
// ios.h
|
||||
// DateTimeLib
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2016 Alexander Kormanovsky
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#ifndef ios_hpp
|
||||
#define ios_hpp
|
||||
|
||||
#if __APPLE__
|
||||
# include <TargetConditionals.h>
|
||||
# if TARGET_OS_IPHONE
|
||||
# include <string>
|
||||
|
||||
namespace date
|
||||
{
|
||||
namespace iOSUtils
|
||||
{
|
||||
|
||||
std::string get_tzdata_path();
|
||||
std::string get_current_timezone();
|
||||
|
||||
} // namespace iOSUtils
|
||||
} // namespace date
|
||||
|
||||
# endif // TARGET_OS_IPHONE
|
||||
#else // !__APPLE__
|
||||
# define TARGET_OS_IPHONE 0
|
||||
#endif // !__APPLE__
|
||||
#endif // ios_hpp
|
3031
include/date/islamic.h
Normal file
3031
include/date/islamic.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,19 +2,19 @@
|
||||
#define ISO_WEEK_H
|
||||
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016, 2017 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -25,6 +25,8 @@
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <climits>
|
||||
|
||||
namespace iso_week
|
||||
{
|
||||
|
||||
@ -38,7 +40,8 @@ using years = date::years;
|
||||
|
||||
// time_point
|
||||
|
||||
using day_point = date::day_point;
|
||||
using sys_days = date::sys_days;
|
||||
using local_days = date::local_days;
|
||||
|
||||
// types
|
||||
|
||||
@ -95,7 +98,8 @@ public:
|
||||
explicit CONSTCD11 weekday(unsigned wd) NOEXCEPT;
|
||||
CONSTCD11 weekday(date::weekday wd) NOEXCEPT;
|
||||
explicit weekday(int) = delete;
|
||||
CONSTCD11 weekday(const day_point& dp) NOEXCEPT;
|
||||
CONSTCD11 weekday(const sys_days& dp) NOEXCEPT;
|
||||
CONSTCD11 explicit weekday(const local_days& dp) NOEXCEPT;
|
||||
|
||||
weekday& operator++() NOEXCEPT;
|
||||
weekday operator++(int) NOEXCEPT;
|
||||
@ -123,7 +127,9 @@ CONSTCD14 weekday operator+(const days& x, const weekday& y) NOEXCEPT;
|
||||
CONSTCD14 weekday operator-(const weekday& x, const days& y) NOEXCEPT;
|
||||
CONSTCD14 days operator-(const weekday& x, const weekday& y) NOEXCEPT;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const weekday& wd);
|
||||
template<class CharT, class Traits>
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const weekday& wd);
|
||||
|
||||
// year
|
||||
|
||||
@ -161,7 +167,9 @@ CONSTCD11 year operator+(const years& x, const year& y) NOEXCEPT;
|
||||
CONSTCD11 year operator-(const year& x, const years& y) NOEXCEPT;
|
||||
CONSTCD11 years operator-(const year& x, const year& y) NOEXCEPT;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const year& y);
|
||||
template<class CharT, class Traits>
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const year& y);
|
||||
|
||||
// weeknum
|
||||
|
||||
@ -196,7 +204,9 @@ CONSTCD11 weeknum operator+(const weeks& x, const weeknum& y) NOEXCEPT;
|
||||
CONSTCD11 weeknum operator-(const weeknum& x, const weeks& y) NOEXCEPT;
|
||||
CONSTCD11 weeks operator-(const weeknum& x, const weeknum& y) NOEXCEPT;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const weeknum& wn);
|
||||
template<class CharT, class Traits>
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const weeknum& wn);
|
||||
|
||||
// year_weeknum
|
||||
|
||||
@ -228,7 +238,9 @@ CONSTCD11 year_weeknum operator+(const year_weeknum& ym, const years& dy) NOEXCE
|
||||
CONSTCD11 year_weeknum operator+(const years& dy, const year_weeknum& ym) NOEXCEPT;
|
||||
CONSTCD11 year_weeknum operator-(const year_weeknum& ym, const years& dy) NOEXCEPT;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const year_weeknum& ym);
|
||||
template<class CharT, class Traits>
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const year_weeknum& ym);
|
||||
|
||||
// year_lastweek
|
||||
|
||||
@ -259,7 +271,9 @@ CONSTCD11 year_lastweek operator+(const year_lastweek& ym, const years& dy) NOEX
|
||||
CONSTCD11 year_lastweek operator+(const years& dy, const year_lastweek& ym) NOEXCEPT;
|
||||
CONSTCD11 year_lastweek operator-(const year_lastweek& ym, const years& dy) NOEXCEPT;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const year_lastweek& ym);
|
||||
template<class CharT, class Traits>
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const year_lastweek& ym);
|
||||
|
||||
// weeknum_weekday
|
||||
|
||||
@ -285,7 +299,9 @@ CONSTCD11 bool operator> (const weeknum_weekday& x, const weeknum_weekday& y) NO
|
||||
CONSTCD11 bool operator<=(const weeknum_weekday& x, const weeknum_weekday& y) NOEXCEPT;
|
||||
CONSTCD11 bool operator>=(const weeknum_weekday& x, const weeknum_weekday& y) NOEXCEPT;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const weeknum_weekday& md);
|
||||
template<class CharT, class Traits>
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const weeknum_weekday& md);
|
||||
|
||||
// lastweek_weekday
|
||||
|
||||
@ -308,7 +324,9 @@ CONSTCD11 bool operator> (const lastweek_weekday& x, const lastweek_weekday& y)
|
||||
CONSTCD11 bool operator<=(const lastweek_weekday& x, const lastweek_weekday& y) NOEXCEPT;
|
||||
CONSTCD11 bool operator>=(const lastweek_weekday& x, const lastweek_weekday& y) NOEXCEPT;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const lastweek_weekday& md);
|
||||
template<class CharT, class Traits>
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const lastweek_weekday& md);
|
||||
|
||||
// year_lastweek_weekday
|
||||
|
||||
@ -325,10 +343,11 @@ public:
|
||||
year_lastweek_weekday& operator-=(const years& y) NOEXCEPT;
|
||||
|
||||
CONSTCD11 iso_week::year year() const NOEXCEPT;
|
||||
CONSTCD11 iso_week::weeknum weeknum() const NOEXCEPT;
|
||||
CONSTCD14 iso_week::weeknum weeknum() const NOEXCEPT;
|
||||
CONSTCD11 iso_week::weekday weekday() const NOEXCEPT;
|
||||
|
||||
CONSTCD14 operator day_point() const NOEXCEPT;
|
||||
CONSTCD14 operator sys_days() const NOEXCEPT;
|
||||
CONSTCD14 explicit operator local_days() const NOEXCEPT;
|
||||
CONSTCD11 bool ok() const NOEXCEPT;
|
||||
};
|
||||
|
||||
@ -343,7 +362,9 @@ CONSTCD11 year_lastweek_weekday operator+(const year_lastweek_weekday& ywnwd, co
|
||||
CONSTCD11 year_lastweek_weekday operator+(const years& y, const year_lastweek_weekday& ywnwd) NOEXCEPT;
|
||||
CONSTCD11 year_lastweek_weekday operator-(const year_lastweek_weekday& ywnwd, const years& y) NOEXCEPT;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const year_lastweek_weekday& ywnwd);
|
||||
template<class CharT, class Traits>
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const year_lastweek_weekday& ywnwd);
|
||||
|
||||
// class year_weeknum_weekday
|
||||
|
||||
@ -357,7 +378,8 @@ public:
|
||||
CONSTCD11 year_weeknum_weekday(const iso_week::year& y, const iso_week::weeknum& wn,
|
||||
const iso_week::weekday& wd) NOEXCEPT;
|
||||
CONSTCD14 year_weeknum_weekday(const year_lastweek_weekday& ylwwd) NOEXCEPT;
|
||||
CONSTCD14 year_weeknum_weekday(const day_point& dp) NOEXCEPT;
|
||||
CONSTCD14 year_weeknum_weekday(const sys_days& dp) NOEXCEPT;
|
||||
CONSTCD14 explicit year_weeknum_weekday(const local_days& dp) NOEXCEPT;
|
||||
|
||||
year_weeknum_weekday& operator+=(const years& y) NOEXCEPT;
|
||||
year_weeknum_weekday& operator-=(const years& y) NOEXCEPT;
|
||||
@ -366,11 +388,12 @@ public:
|
||||
CONSTCD11 iso_week::weeknum weeknum() const NOEXCEPT;
|
||||
CONSTCD11 iso_week::weekday weekday() const NOEXCEPT;
|
||||
|
||||
CONSTCD14 operator day_point() const NOEXCEPT;
|
||||
CONSTCD14 operator sys_days() const NOEXCEPT;
|
||||
CONSTCD14 explicit operator local_days() const NOEXCEPT;
|
||||
CONSTCD14 bool ok() const NOEXCEPT;
|
||||
|
||||
private:
|
||||
static CONSTCD14 year_weeknum_weekday from_day_point(const day_point& dp) NOEXCEPT;
|
||||
static CONSTCD14 year_weeknum_weekday from_days(days dp) NOEXCEPT;
|
||||
};
|
||||
|
||||
CONSTCD11 bool operator==(const year_weeknum_weekday& x, const year_weeknum_weekday& y) NOEXCEPT;
|
||||
@ -384,7 +407,9 @@ CONSTCD11 year_weeknum_weekday operator+(const year_weeknum_weekday& ywnwd, cons
|
||||
CONSTCD11 year_weeknum_weekday operator+(const years& y, const year_weeknum_weekday& ywnwd) NOEXCEPT;
|
||||
CONSTCD11 year_weeknum_weekday operator-(const year_weeknum_weekday& ywnwd, const years& y) NOEXCEPT;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const year_weeknum_weekday& ywnwd);
|
||||
template<class CharT, class Traits>
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const year_weeknum_weekday& ywnwd);
|
||||
|
||||
//----------------+
|
||||
// Implementation |
|
||||
@ -426,12 +451,18 @@ weekday::weekday(unsigned wd) NOEXCEPT
|
||||
CONSTCD11
|
||||
inline
|
||||
weekday::weekday(date::weekday wd) NOEXCEPT
|
||||
: wd_(to_iso_encoding(unsigned{wd}))
|
||||
: wd_(wd.iso_encoding())
|
||||
{}
|
||||
|
||||
CONSTCD11
|
||||
inline
|
||||
weekday::weekday(const day_point& dp) NOEXCEPT
|
||||
weekday::weekday(const sys_days& dp) NOEXCEPT
|
||||
: wd_(weekday_from_days(dp.time_since_epoch().count()))
|
||||
{}
|
||||
|
||||
CONSTCD11
|
||||
inline
|
||||
weekday::weekday(const local_days& dp) NOEXCEPT
|
||||
: wd_(weekday_from_days(dp.time_since_epoch().count()))
|
||||
{}
|
||||
|
||||
@ -523,9 +554,10 @@ operator-(const weekday& x, const days& y) NOEXCEPT
|
||||
return x + -y;
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const weekday& wd)
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const weekday& wd)
|
||||
{
|
||||
switch (static_cast<unsigned>(wd))
|
||||
{
|
||||
@ -575,7 +607,10 @@ inline
|
||||
year
|
||||
year::min() NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
using std::chrono::duration_cast;
|
||||
static_assert(sizeof(seconds)*CHAR_BIT >= 41, "seconds may overflow");
|
||||
static_assert(sizeof(hours)*CHAR_BIT >= 30, "hours may overflow");
|
||||
return sizeof(minutes)*CHAR_BIT < 34 ?
|
||||
@ -588,7 +623,10 @@ inline
|
||||
year
|
||||
year::max() NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
using std::chrono::duration_cast;
|
||||
static_assert(sizeof(seconds)*CHAR_BIT >= 41, "seconds may overflow");
|
||||
static_assert(sizeof(hours)*CHAR_BIT >= 30, "hours may overflow");
|
||||
return sizeof(minutes)*CHAR_BIT < 34 ?
|
||||
@ -676,11 +714,12 @@ operator-(const year& x, const years& y) NOEXCEPT
|
||||
return year{static_cast<int>(x) - y.count()};
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const year& y)
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const year& y)
|
||||
{
|
||||
date::detail::save_stream _(os);
|
||||
date::detail::save_ostream<CharT, Traits> _(os);
|
||||
os.fill('0');
|
||||
os.flags(std::ios::dec | std::ios::internal);
|
||||
os.width(4 + (y < year{0}));
|
||||
@ -837,11 +876,12 @@ operator-(const weeknum& x, const weeks& y) NOEXCEPT
|
||||
return x + -y;
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const weeknum& wn)
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const weeknum& wn)
|
||||
{
|
||||
date::detail::save_stream _(os);
|
||||
date::detail::save_ostream<CharT, Traits> _(os);
|
||||
os << 'W';
|
||||
os.fill('0');
|
||||
os.flags(std::ios::dec | std::ios::right);
|
||||
@ -863,7 +903,7 @@ CONSTCD11 inline year year_weeknum::year() const NOEXCEPT {return y_;}
|
||||
CONSTCD11 inline weeknum year_weeknum::weeknum() const NOEXCEPT {return wn_;}
|
||||
CONSTCD11 inline bool year_weeknum::ok() const NOEXCEPT
|
||||
{
|
||||
return y_.ok() && 1u <= unsigned{wn_} && wn_ <= (y_/last).weeknum();
|
||||
return y_.ok() && 1u <= static_cast<unsigned>(wn_) && wn_ <= (y_/last).weeknum();
|
||||
}
|
||||
|
||||
inline
|
||||
@ -956,9 +996,10 @@ operator-(const year_weeknum& ym, const years& dy) NOEXCEPT
|
||||
return ym + -dy;
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const year_weeknum& ywn)
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const year_weeknum& ywn)
|
||||
{
|
||||
return os << ywn.year() << '-' << ywn.weeknum();
|
||||
}
|
||||
@ -979,10 +1020,10 @@ inline
|
||||
weeknum
|
||||
year_lastweek::weeknum() const NOEXCEPT
|
||||
{
|
||||
const auto y = date::year{int{y_}};
|
||||
const auto s0 = day_point{(y-years{1})/12/date::thu[date::last]};
|
||||
const auto s1 = day_point{y/12/date::thu[date::last]};
|
||||
return iso_week::weeknum(date::trunc<weeks>(s1-s0).count());
|
||||
const auto y = date::year{static_cast<int>(y_)};
|
||||
const auto s0 = sys_days((y-years{1})/12/date::thu[date::last]);
|
||||
const auto s1 = sys_days(y/12/date::thu[date::last]);
|
||||
return iso_week::weeknum(static_cast<unsigned>(date::trunc<weeks>(s1-s0).count()));
|
||||
}
|
||||
|
||||
CONSTCD11 inline bool year_lastweek::ok() const NOEXCEPT {return y_.ok();}
|
||||
@ -1075,9 +1116,10 @@ operator-(const year_lastweek& ym, const years& dy) NOEXCEPT
|
||||
return ym + -dy;
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const year_lastweek& ywn)
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const year_lastweek& ywn)
|
||||
{
|
||||
return os << ywn.year() << "-W last";
|
||||
}
|
||||
@ -1126,7 +1168,7 @@ operator<(const weeknum_weekday& x, const weeknum_weekday& y) NOEXCEPT
|
||||
{
|
||||
return x.weeknum() < y.weeknum() ? true
|
||||
: (x.weeknum() > y.weeknum() ? false
|
||||
: (unsigned{x.weekday()} < unsigned{y.weekday()}));
|
||||
: (static_cast<unsigned>(x.weekday()) < static_cast<unsigned>(y.weekday())));
|
||||
}
|
||||
|
||||
CONSTCD11
|
||||
@ -1153,9 +1195,10 @@ operator>=(const weeknum_weekday& x, const weeknum_weekday& y) NOEXCEPT
|
||||
return !(x < y);
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const weeknum_weekday& md)
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const weeknum_weekday& md)
|
||||
{
|
||||
return os << md.weeknum() << '-' << md.weekday();
|
||||
}
|
||||
@ -1199,7 +1242,7 @@ inline
|
||||
bool
|
||||
operator<(const lastweek_weekday& x, const lastweek_weekday& y) NOEXCEPT
|
||||
{
|
||||
return unsigned{x.weekday()} < unsigned{y.weekday()};
|
||||
return static_cast<unsigned>(x.weekday()) < static_cast<unsigned>(y.weekday());
|
||||
}
|
||||
|
||||
CONSTCD11
|
||||
@ -1226,9 +1269,10 @@ operator>=(const lastweek_weekday& x, const lastweek_weekday& y) NOEXCEPT
|
||||
return !(x < y);
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const lastweek_weekday& md)
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const lastweek_weekday& md)
|
||||
{
|
||||
return os << "W last-" << md.weekday();
|
||||
}
|
||||
@ -1261,7 +1305,7 @@ year_lastweek_weekday::operator-=(const years& y) NOEXCEPT
|
||||
|
||||
CONSTCD11 inline year year_lastweek_weekday::year() const NOEXCEPT {return y_;}
|
||||
|
||||
CONSTCD11
|
||||
CONSTCD14
|
||||
inline
|
||||
weeknum
|
||||
year_lastweek_weekday::weeknum() const NOEXCEPT
|
||||
@ -1273,10 +1317,18 @@ CONSTCD11 inline weekday year_lastweek_weekday::weekday() const NOEXCEPT {return
|
||||
|
||||
CONSTCD14
|
||||
inline
|
||||
year_lastweek_weekday::operator day_point() const NOEXCEPT
|
||||
year_lastweek_weekday::operator sys_days() const NOEXCEPT
|
||||
{
|
||||
return day_point{date::year{int{y_}}/date::dec/date::thu[date::last]} + (mon - thu)
|
||||
- (mon - wd_);
|
||||
return sys_days(date::year{static_cast<int>(y_)}/date::dec/date::thu[date::last])
|
||||
+ (sun - thu) - (sun - wd_);
|
||||
}
|
||||
|
||||
CONSTCD14
|
||||
inline
|
||||
year_lastweek_weekday::operator local_days() const NOEXCEPT
|
||||
{
|
||||
return local_days(date::year{static_cast<int>(y_)}/date::dec/date::thu[date::last])
|
||||
+ (sun - thu) - (sun - wd_);
|
||||
}
|
||||
|
||||
CONSTCD11
|
||||
@ -1310,7 +1362,7 @@ operator<(const year_lastweek_weekday& x, const year_lastweek_weekday& y) NOEXCE
|
||||
{
|
||||
return x.year() < y.year() ? true
|
||||
: (x.year() > y.year() ? false
|
||||
: (unsigned{x.weekday()} < unsigned{y.weekday()}));
|
||||
: (static_cast<unsigned>(x.weekday()) < static_cast<unsigned>(y.weekday())));
|
||||
}
|
||||
|
||||
CONSTCD11
|
||||
@ -1361,9 +1413,10 @@ operator-(const year_lastweek_weekday& ywnwd, const years& y) NOEXCEPT
|
||||
return ywnwd + -y;
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const year_lastweek_weekday& ywnwd)
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const year_lastweek_weekday& ywnwd)
|
||||
{
|
||||
return os << ywnwd.year() << "-W last-" << ywnwd.weekday();
|
||||
}
|
||||
@ -1390,8 +1443,14 @@ year_weeknum_weekday::year_weeknum_weekday(const year_lastweek_weekday& ylwwd) N
|
||||
|
||||
CONSTCD14
|
||||
inline
|
||||
year_weeknum_weekday::year_weeknum_weekday(const day_point& dp) NOEXCEPT
|
||||
: year_weeknum_weekday(from_day_point(dp))
|
||||
year_weeknum_weekday::year_weeknum_weekday(const sys_days& dp) NOEXCEPT
|
||||
: year_weeknum_weekday(from_days(dp.time_since_epoch()))
|
||||
{}
|
||||
|
||||
CONSTCD14
|
||||
inline
|
||||
year_weeknum_weekday::year_weeknum_weekday(const local_days& dp) NOEXCEPT
|
||||
: year_weeknum_weekday(from_days(dp.time_since_epoch()))
|
||||
{}
|
||||
|
||||
inline
|
||||
@ -1416,10 +1475,18 @@ CONSTCD11 inline weekday year_weeknum_weekday::weekday() const NOEXCEPT {return
|
||||
|
||||
CONSTCD14
|
||||
inline
|
||||
year_weeknum_weekday::operator day_point() const NOEXCEPT
|
||||
year_weeknum_weekday::operator sys_days() const NOEXCEPT
|
||||
{
|
||||
return day_point{date::year{int{y_}-1}/date::dec/date::thu[date::last]}
|
||||
+ (date::mon - date::thu) + weeks{unsigned{wn_}-1} + (wd_ - mon);
|
||||
return sys_days(date::year{static_cast<int>(y_)-1}/date::dec/date::thu[date::last])
|
||||
+ (date::mon - date::thu) + weeks{static_cast<unsigned>(wn_)-1} + (wd_ - mon);
|
||||
}
|
||||
|
||||
CONSTCD14
|
||||
inline
|
||||
year_weeknum_weekday::operator local_days() const NOEXCEPT
|
||||
{
|
||||
return local_days(date::year{static_cast<int>(y_)-1}/date::dec/date::thu[date::last])
|
||||
+ (date::mon - date::thu) + weeks{static_cast<unsigned>(wn_)-1} + (wd_ - mon);
|
||||
}
|
||||
|
||||
CONSTCD14
|
||||
@ -1433,18 +1500,20 @@ year_weeknum_weekday::ok() const NOEXCEPT
|
||||
CONSTCD14
|
||||
inline
|
||||
year_weeknum_weekday
|
||||
year_weeknum_weekday::from_day_point(const day_point& dp) NOEXCEPT
|
||||
year_weeknum_weekday::from_days(days d) NOEXCEPT
|
||||
{
|
||||
const auto dp = sys_days{d};
|
||||
const auto wd = iso_week::weekday{dp};
|
||||
auto y = date::year_month_day{dp + days{3}}.year();
|
||||
auto start = day_point{(y - date::years{1})/date::dec/date::thu[date::last]} + (mon-thu);
|
||||
auto start = sys_days((y - date::years{1})/date::dec/date::thu[date::last]) + (mon-thu);
|
||||
if (dp < start)
|
||||
{
|
||||
--y;
|
||||
start = day_point{(y - date::years{1})/date::dec/date::thu[date::last]} + (mon-thu);
|
||||
start = sys_days((y - date::years{1})/date::dec/date::thu[date::last]) + (mon-thu);
|
||||
}
|
||||
const auto wn = iso_week::weeknum(date::trunc<weeks>(dp - start).count() + 1);
|
||||
return {iso_week::year(int{y}), wn, wd};
|
||||
const auto wn = iso_week::weeknum(
|
||||
static_cast<unsigned>(date::trunc<weeks>(dp - start).count() + 1));
|
||||
return {iso_week::year(static_cast<int>(y)), wn, wd};
|
||||
}
|
||||
|
||||
CONSTCD11
|
||||
@ -1472,7 +1541,7 @@ operator<(const year_weeknum_weekday& x, const year_weeknum_weekday& y) NOEXCEPT
|
||||
: (x.year() > y.year() ? false
|
||||
: (x.weeknum() < y.weeknum() ? true
|
||||
: (x.weeknum() > y.weeknum() ? false
|
||||
: (unsigned{x.weekday()} < unsigned{y.weekday()}))));
|
||||
: (static_cast<unsigned>(x.weekday()) < static_cast<unsigned>(y.weekday())))));
|
||||
}
|
||||
|
||||
CONSTCD11
|
||||
@ -1523,9 +1592,10 @@ operator-(const year_weeknum_weekday& ywnwd, const years& y) NOEXCEPT
|
||||
return ywnwd + -y;
|
||||
}
|
||||
|
||||
template<class CharT, class Traits>
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const year_weeknum_weekday& ywnwd)
|
||||
std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os, const year_weeknum_weekday& ywnwd)
|
||||
{
|
||||
return os << ywnwd.year() << '-' << ywnwd.weeknum() << '-' << ywnwd.weekday();
|
||||
}
|
||||
@ -1545,7 +1615,7 @@ inline
|
||||
year_weeknum
|
||||
operator/(const year& y, int wn) NOEXCEPT
|
||||
{
|
||||
return y/weeknum(wn);
|
||||
return y/weeknum(static_cast<unsigned>(wn));
|
||||
}
|
||||
|
||||
CONSTCD11
|
File diff suppressed because it is too large
Load Diff
788
include/date/ptz.h
Normal file
788
include/date/ptz.h
Normal file
@ -0,0 +1,788 @@
|
||||
#ifndef PTZ_H
|
||||
#define PTZ_H
|
||||
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// This header allows Posix-style time zones as specified for TZ here:
|
||||
// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
|
||||
//
|
||||
// Posix::time_zone can be constructed with a posix-style string and then used in
|
||||
// a zoned_time like so:
|
||||
//
|
||||
// zoned_time<system_clock::duration, Posix::time_zone> zt{"EST5EDT,M3.2.0,M11.1.0",
|
||||
// system_clock::now()};
|
||||
// or:
|
||||
//
|
||||
// Posix::time_zone tz{"EST5EDT,M3.2.0,M11.1.0"};
|
||||
// zoned_time<system_clock::duration, Posix::time_zone> zt{tz, system_clock::now()};
|
||||
//
|
||||
// If the rule set is missing (everything starting with ','), then the rule is that the
|
||||
// alternate offset is never enabled.
|
||||
//
|
||||
// Note, Posix-style time zones are not recommended for all of the reasons described here:
|
||||
// https://stackoverflow.com/tags/timezone/info
|
||||
//
|
||||
// They are provided here as a non-trivial custom time zone example, and if you really
|
||||
// have to have Posix time zones, you're welcome to use this one.
|
||||
|
||||
#include "date/tz.h"
|
||||
#include <cctype>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace Posix
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if HAS_STRING_VIEW
|
||||
|
||||
using string_t = std::string_view;
|
||||
|
||||
#else // !HAS_STRING_VIEW
|
||||
|
||||
using string_t = std::string;
|
||||
|
||||
#endif // !HAS_STRING_VIEW
|
||||
|
||||
class rule;
|
||||
|
||||
void throw_invalid(const string_t& s, unsigned i, const string_t& message);
|
||||
unsigned read_date(const string_t& s, unsigned i, rule& r);
|
||||
unsigned read_name(const string_t& s, unsigned i, std::string& name);
|
||||
unsigned read_signed_time(const string_t& s, unsigned i, std::chrono::seconds& t);
|
||||
unsigned read_unsigned_time(const string_t& s, unsigned i, std::chrono::seconds& t);
|
||||
unsigned read_unsigned(const string_t& s, unsigned i, unsigned limit, unsigned& u,
|
||||
const string_t& message = string_t{});
|
||||
|
||||
class rule
|
||||
{
|
||||
enum {off, J, M, N};
|
||||
|
||||
date::month m_;
|
||||
date::weekday wd_;
|
||||
unsigned short n_ : 14;
|
||||
unsigned short mode_ : 2;
|
||||
std::chrono::duration<std::int32_t> time_ = std::chrono::hours{2};
|
||||
|
||||
public:
|
||||
rule() : mode_(off) {}
|
||||
|
||||
bool ok() const {return mode_ != off;}
|
||||
date::local_seconds operator()(date::year y) const;
|
||||
std::string to_string() const;
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const rule& r);
|
||||
friend unsigned read_date(const string_t& s, unsigned i, rule& r);
|
||||
friend bool operator==(const rule& x, const rule& y);
|
||||
};
|
||||
|
||||
inline
|
||||
bool
|
||||
operator==(const rule& x, const rule& y)
|
||||
{
|
||||
if (x.mode_ != y.mode_)
|
||||
return false;
|
||||
switch (x.mode_)
|
||||
{
|
||||
case rule::J:
|
||||
case rule::N:
|
||||
return x.n_ == y.n_;
|
||||
case rule::M:
|
||||
return x.m_ == y.m_ && x.n_ == y.n_ && x.wd_ == y.wd_;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
operator!=(const rule& x, const rule& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
inline
|
||||
date::local_seconds
|
||||
rule::operator()(date::year y) const
|
||||
{
|
||||
using date::local_days;
|
||||
using date::January;
|
||||
using date::days;
|
||||
using date::last;
|
||||
using sec = std::chrono::seconds;
|
||||
date::local_seconds t;
|
||||
switch (mode_)
|
||||
{
|
||||
case J:
|
||||
t = local_days{y/January/0} + days{n_ + (y.is_leap() && n_ > 59)} + sec{time_};
|
||||
break;
|
||||
case M:
|
||||
t = (n_ == 5 ? local_days{y/m_/wd_[last]} : local_days{y/m_/wd_[n_]}) + sec{time_};
|
||||
break;
|
||||
case N:
|
||||
t = local_days{y/January/1} + days{n_} + sec{time_};
|
||||
break;
|
||||
default:
|
||||
assert(!"rule called with bad mode");
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
inline
|
||||
std::string
|
||||
rule::to_string() const
|
||||
{
|
||||
using namespace std::chrono;
|
||||
auto print_offset = [](seconds off)
|
||||
{
|
||||
std::string nm;
|
||||
if (off != hours{2})
|
||||
{
|
||||
date::hh_mm_ss<seconds> offset{off};
|
||||
nm = '/';
|
||||
nm += std::to_string(offset.hours().count());
|
||||
if (offset.minutes() != minutes{0} || offset.seconds() != seconds{0})
|
||||
{
|
||||
nm += ':';
|
||||
if (offset.minutes() < minutes{10})
|
||||
nm += '0';
|
||||
nm += std::to_string(offset.minutes().count());
|
||||
if (offset.seconds() != seconds{0})
|
||||
{
|
||||
nm += ':';
|
||||
if (offset.seconds() < seconds{10})
|
||||
nm += '0';
|
||||
nm += std::to_string(offset.seconds().count());
|
||||
}
|
||||
}
|
||||
}
|
||||
return nm;
|
||||
};
|
||||
|
||||
std::string nm;
|
||||
switch (mode_)
|
||||
{
|
||||
case rule::J:
|
||||
nm = 'J';
|
||||
nm += std::to_string(n_);
|
||||
break;
|
||||
case rule::M:
|
||||
nm = 'M';
|
||||
nm += std::to_string(static_cast<unsigned>(m_));
|
||||
nm += '.';
|
||||
nm += std::to_string(n_);
|
||||
nm += '.';
|
||||
nm += std::to_string(wd_.c_encoding());
|
||||
break;
|
||||
case rule::N:
|
||||
nm = std::to_string(n_);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
nm += print_offset(time_);
|
||||
return nm;
|
||||
}
|
||||
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const rule& r)
|
||||
{
|
||||
switch (r.mode_)
|
||||
{
|
||||
case rule::J:
|
||||
os << 'J' << r.n_ << date::format(" %T", r.time_);
|
||||
break;
|
||||
case rule::M:
|
||||
if (r.n_ == 5)
|
||||
os << r.m_/r.wd_[date::last];
|
||||
else
|
||||
os << r.m_/r.wd_[r.n_];
|
||||
os << date::format(" %T", r.time_);
|
||||
break;
|
||||
case rule::N:
|
||||
os << r.n_ << date::format(" %T", r.time_);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
class time_zone
|
||||
{
|
||||
std::string std_abbrev_;
|
||||
std::string dst_abbrev_ = {};
|
||||
std::chrono::seconds offset_;
|
||||
std::chrono::seconds save_ = std::chrono::hours{1};
|
||||
detail::rule start_rule_;
|
||||
detail::rule end_rule_;
|
||||
|
||||
public:
|
||||
explicit time_zone(const detail::string_t& name);
|
||||
|
||||
template <class Duration>
|
||||
date::sys_info get_info(date::sys_time<Duration> st) const;
|
||||
template <class Duration>
|
||||
date::local_info get_info(date::local_time<Duration> tp) const;
|
||||
|
||||
template <class Duration>
|
||||
date::sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
to_sys(date::local_time<Duration> tp) const;
|
||||
|
||||
template <class Duration>
|
||||
date::sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
to_sys(date::local_time<Duration> tp, date::choose z) const;
|
||||
|
||||
template <class Duration>
|
||||
date::local_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
to_local(date::sys_time<Duration> tp) const;
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const time_zone& z);
|
||||
|
||||
const time_zone* operator->() const {return this;}
|
||||
|
||||
std::string name() const;
|
||||
|
||||
friend bool operator==(const time_zone& x, const time_zone& y);
|
||||
};
|
||||
|
||||
inline
|
||||
time_zone::time_zone(const detail::string_t& s)
|
||||
{
|
||||
using detail::read_name;
|
||||
using detail::read_signed_time;
|
||||
using detail::throw_invalid;
|
||||
auto i = read_name(s, 0, std_abbrev_);
|
||||
i = read_signed_time(s, i, offset_);
|
||||
offset_ = -offset_;
|
||||
if (i != s.size())
|
||||
{
|
||||
i = read_name(s, i, dst_abbrev_);
|
||||
if (i != s.size())
|
||||
{
|
||||
if (s[i] != ',')
|
||||
{
|
||||
i = read_signed_time(s, i, save_);
|
||||
save_ = -save_ - offset_;
|
||||
}
|
||||
if (i != s.size())
|
||||
{
|
||||
if (s[i] != ',')
|
||||
throw_invalid(s, i, "Expecting end of string or ',' to start rule");
|
||||
++i;
|
||||
i = read_date(s, i, start_rule_);
|
||||
if (i == s.size() || s[i] != ',')
|
||||
throw_invalid(s, i, "Expecting ',' and then the ending rule");
|
||||
++i;
|
||||
i = read_date(s, i, end_rule_);
|
||||
if (i != s.size())
|
||||
throw_invalid(s, i, "Found unexpected trailing characters");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class Duration>
|
||||
date::sys_info
|
||||
time_zone::get_info(date::sys_time<Duration> st) const
|
||||
{
|
||||
using date::sys_info;
|
||||
using date::year_month_day;
|
||||
using date::sys_seconds;
|
||||
using date::sys_days;
|
||||
using date::floor;
|
||||
using date::ceil;
|
||||
using date::days;
|
||||
using date::years;
|
||||
using date::year;
|
||||
using date::January;
|
||||
using date::December;
|
||||
using date::last;
|
||||
using std::chrono::minutes;
|
||||
sys_info r{};
|
||||
r.offset = offset_;
|
||||
if (start_rule_.ok())
|
||||
{
|
||||
auto y = year_month_day{floor<days>(st)}.year();
|
||||
auto start = sys_seconds{(start_rule_(y) - offset_).time_since_epoch()};
|
||||
auto end = sys_seconds{(end_rule_(y) - (offset_ + save_)).time_since_epoch()};
|
||||
if (start <= st && st < end)
|
||||
{
|
||||
r.begin = start;
|
||||
r.end = end;
|
||||
r.offset += save_;
|
||||
r.save = ceil<minutes>(save_);
|
||||
r.abbrev = dst_abbrev_;
|
||||
}
|
||||
else if (st < start)
|
||||
{
|
||||
r.begin = sys_seconds{(end_rule_(y-years{1}) -
|
||||
(offset_ + save_)).time_since_epoch()};
|
||||
r.end = start;
|
||||
r.abbrev = std_abbrev_;
|
||||
}
|
||||
else // st >= end
|
||||
{
|
||||
r.begin = end;
|
||||
r.end = sys_seconds{(start_rule_(y+years{1}) - offset_).time_since_epoch()};
|
||||
r.abbrev = std_abbrev_;
|
||||
}
|
||||
}
|
||||
else // constant offset
|
||||
{
|
||||
r.begin = sys_days{year::min()/January/1};
|
||||
r.end = sys_days{year::max()/December/last};
|
||||
r.abbrev = std_abbrev_;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
template <class Duration>
|
||||
date::local_info
|
||||
time_zone::get_info(date::local_time<Duration> tp) const
|
||||
{
|
||||
using date::local_info;
|
||||
using date::year_month_day;
|
||||
using date::days;
|
||||
using date::sys_days;
|
||||
using date::sys_seconds;
|
||||
using date::years;
|
||||
using date::year;
|
||||
using date::ceil;
|
||||
using date::January;
|
||||
using date::December;
|
||||
using date::last;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
local_info r{};
|
||||
using date::floor;
|
||||
if (start_rule_.ok())
|
||||
{
|
||||
auto y = year_month_day{floor<days>(tp)}.year();
|
||||
auto start = sys_seconds{(start_rule_(y) - offset_).time_since_epoch()};
|
||||
auto end = sys_seconds{(end_rule_(y) - (offset_ + save_)).time_since_epoch()};
|
||||
auto utcs = sys_seconds{floor<seconds>(tp - offset_).time_since_epoch()};
|
||||
auto utcd = sys_seconds{floor<seconds>(tp - (offset_ + save_)).time_since_epoch()};
|
||||
if ((utcs < start) != (utcd < start))
|
||||
{
|
||||
r.first.begin = sys_seconds{(end_rule_(y-years{1}) -
|
||||
(offset_ + save_)).time_since_epoch()};
|
||||
r.first.end = start;
|
||||
r.first.offset = offset_;
|
||||
r.first.abbrev = std_abbrev_;
|
||||
r.second.begin = start;
|
||||
r.second.end = end;
|
||||
r.second.abbrev = dst_abbrev_;
|
||||
r.second.offset = offset_ + save_;
|
||||
r.second.save = ceil<minutes>(save_);
|
||||
r.result = save_ > seconds{0} ? local_info::nonexistent
|
||||
: local_info::ambiguous;
|
||||
}
|
||||
else if ((utcs < end) != (utcd < end))
|
||||
{
|
||||
r.first.begin = start;
|
||||
r.first.end = end;
|
||||
r.first.offset = offset_ + save_;
|
||||
r.first.save = ceil<minutes>(save_);
|
||||
r.first.abbrev = dst_abbrev_;
|
||||
r.second.begin = end;
|
||||
r.second.end = sys_seconds{(start_rule_(y+years{1}) -
|
||||
offset_).time_since_epoch()};
|
||||
r.second.abbrev = std_abbrev_;
|
||||
r.second.offset = offset_;
|
||||
r.result = save_ > seconds{0} ? local_info::ambiguous
|
||||
: local_info::nonexistent;
|
||||
}
|
||||
else if (utcs < start)
|
||||
{
|
||||
r.first.begin = sys_seconds{(end_rule_(y-years{1}) -
|
||||
(offset_ + save_)).time_since_epoch()};
|
||||
r.first.end = start;
|
||||
r.first.offset = offset_;
|
||||
r.first.abbrev = std_abbrev_;
|
||||
}
|
||||
else if (utcs < end)
|
||||
{
|
||||
r.first.begin = start;
|
||||
r.first.end = end;
|
||||
r.first.offset = offset_ + save_;
|
||||
r.first.save = ceil<minutes>(save_);
|
||||
r.first.abbrev = dst_abbrev_;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.first.begin = end;
|
||||
r.first.end = sys_seconds{(start_rule_(y+years{1}) -
|
||||
offset_).time_since_epoch()};
|
||||
r.first.abbrev = std_abbrev_;
|
||||
r.first.offset = offset_;
|
||||
}
|
||||
}
|
||||
else // constant offset
|
||||
{
|
||||
r.first.begin = sys_days{year::min()/January/1};
|
||||
r.first.end = sys_days{year::max()/December/last};
|
||||
r.first.abbrev = std_abbrev_;
|
||||
r.first.offset = offset_;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
template <class Duration>
|
||||
date::sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
time_zone::to_sys(date::local_time<Duration> tp) const
|
||||
{
|
||||
using date::local_info;
|
||||
using date::sys_time;
|
||||
using date::ambiguous_local_time;
|
||||
auto i = get_info(tp);
|
||||
if (i.result == local_info::nonexistent)
|
||||
throw nonexistent_local_time(tp, i);
|
||||
else if (i.result == local_info::ambiguous)
|
||||
throw ambiguous_local_time(tp, i);
|
||||
return sys_time<Duration>{tp.time_since_epoch()} - i.first.offset;
|
||||
}
|
||||
|
||||
template <class Duration>
|
||||
date::sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
time_zone::to_sys(date::local_time<Duration> tp, date::choose z) const
|
||||
{
|
||||
using date::local_info;
|
||||
using date::sys_time;
|
||||
using date::choose;
|
||||
auto i = get_info(tp);
|
||||
if (i.result == local_info::nonexistent)
|
||||
{
|
||||
return i.first.end;
|
||||
}
|
||||
else if (i.result == local_info::ambiguous)
|
||||
{
|
||||
if (z == choose::latest)
|
||||
return sys_time<Duration>{tp.time_since_epoch()} - i.second.offset;
|
||||
}
|
||||
return sys_time<Duration>{tp.time_since_epoch()} - i.first.offset;
|
||||
}
|
||||
|
||||
template <class Duration>
|
||||
date::local_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
time_zone::to_local(date::sys_time<Duration> tp) const
|
||||
{
|
||||
using date::local_time;
|
||||
using std::chrono::seconds;
|
||||
using LT = local_time<typename std::common_type<Duration, seconds>::type>;
|
||||
auto i = get_info(tp);
|
||||
return LT{(tp + i.offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const time_zone& z)
|
||||
{
|
||||
using date::operator<<;
|
||||
os << '{';
|
||||
os << z.std_abbrev_ << ", " << z.dst_abbrev_ << date::format(", %T, ", z.offset_)
|
||||
<< date::format("%T, [", z.save_) << z.start_rule_ << ", " << z.end_rule_ << ")}";
|
||||
return os;
|
||||
}
|
||||
|
||||
inline
|
||||
std::string
|
||||
time_zone::name() const
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
auto nm = std_abbrev_;
|
||||
auto print_offset = [](seconds off)
|
||||
{
|
||||
std::string nm;
|
||||
hh_mm_ss<seconds> offset{-off};
|
||||
if (offset.is_negative())
|
||||
nm += '-';
|
||||
nm += std::to_string(offset.hours().count());
|
||||
if (offset.minutes() != minutes{0} || offset.seconds() != seconds{0})
|
||||
{
|
||||
nm += ':';
|
||||
if (offset.minutes() < minutes{10})
|
||||
nm += '0';
|
||||
nm += std::to_string(offset.minutes().count());
|
||||
if (offset.seconds() != seconds{0})
|
||||
{
|
||||
nm += ':';
|
||||
if (offset.seconds() < seconds{10})
|
||||
nm += '0';
|
||||
nm += std::to_string(offset.seconds().count());
|
||||
}
|
||||
}
|
||||
return nm;
|
||||
};
|
||||
nm += print_offset(offset_);
|
||||
if (!dst_abbrev_.empty())
|
||||
{
|
||||
nm += dst_abbrev_;
|
||||
if (save_ != hours{1})
|
||||
nm += print_offset(offset_+save_);
|
||||
if (start_rule_.ok())
|
||||
{
|
||||
nm += ',';
|
||||
nm += start_rule_.to_string();
|
||||
nm += ',';
|
||||
nm += end_rule_.to_string();
|
||||
}
|
||||
}
|
||||
return nm;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
operator==(const time_zone& x, const time_zone& y)
|
||||
{
|
||||
return x.std_abbrev_ == y.std_abbrev_ &&
|
||||
x.dst_abbrev_ == y. dst_abbrev_ &&
|
||||
x.offset_ == y.offset_ &&
|
||||
x.save_ == y.save_ &&
|
||||
x.start_rule_ == y.start_rule_ &&
|
||||
x.end_rule_ == y.end_rule_;
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
operator!=(const time_zone& x, const time_zone& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline
|
||||
void
|
||||
throw_invalid(const string_t& s, unsigned i, const string_t& message)
|
||||
{
|
||||
throw std::runtime_error(std::string("Invalid time_zone initializer.\n") +
|
||||
std::string(message) + ":\n" +
|
||||
std::string(s) + '\n' +
|
||||
"\x1b[1;32m" +
|
||||
std::string(i, '~') + '^' +
|
||||
std::string(i < s.size() ? s.size()-i-1 : 0, '~') +
|
||||
"\x1b[0m");
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned
|
||||
read_date(const string_t& s, unsigned i, rule& r)
|
||||
{
|
||||
using date::month;
|
||||
using date::weekday;
|
||||
if (i == s.size())
|
||||
throw_invalid(s, i, "Expected rule but found end of string");
|
||||
if (s[i] == 'J')
|
||||
{
|
||||
++i;
|
||||
unsigned n;
|
||||
i = read_unsigned(s, i, 3, n, "Expected to find the Julian day [1, 365]");
|
||||
r.mode_ = rule::J;
|
||||
r.n_ = n;
|
||||
}
|
||||
else if (s[i] == 'M')
|
||||
{
|
||||
++i;
|
||||
unsigned m;
|
||||
i = read_unsigned(s, i, 2, m, "Expected to find month [1, 12]");
|
||||
if (i == s.size() || s[i] != '.')
|
||||
throw_invalid(s, i, "Expected '.' after month");
|
||||
++i;
|
||||
unsigned n;
|
||||
i = read_unsigned(s, i, 1, n, "Expected to find week number [1, 5]");
|
||||
if (i == s.size() || s[i] != '.')
|
||||
throw_invalid(s, i, "Expected '.' after weekday index");
|
||||
++i;
|
||||
unsigned wd;
|
||||
i = read_unsigned(s, i, 1, wd, "Expected to find day of week [0, 6]");
|
||||
r.mode_ = rule::M;
|
||||
r.m_ = month{m};
|
||||
r.wd_ = weekday{wd};
|
||||
r.n_ = n;
|
||||
}
|
||||
else if (std::isdigit(s[i]))
|
||||
{
|
||||
unsigned n;
|
||||
i = read_unsigned(s, i, 3, n);
|
||||
r.mode_ = rule::N;
|
||||
r.n_ = n;
|
||||
}
|
||||
else
|
||||
throw_invalid(s, i, "Expected 'J', 'M', or a digit to start rule");
|
||||
if (i != s.size() && s[i] == '/')
|
||||
{
|
||||
++i;
|
||||
std::chrono::seconds t;
|
||||
i = read_unsigned_time(s, i, t);
|
||||
r.time_ = t;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned
|
||||
read_name(const string_t& s, unsigned i, std::string& name)
|
||||
{
|
||||
if (i == s.size())
|
||||
throw_invalid(s, i, "Expected a name but found end of string");
|
||||
if (s[i] == '<')
|
||||
{
|
||||
++i;
|
||||
while (true)
|
||||
{
|
||||
if (i == s.size())
|
||||
throw_invalid(s, i,
|
||||
"Expected to find closing '>', but found end of string");
|
||||
if (s[i] == '>')
|
||||
break;
|
||||
name.push_back(s[i]);
|
||||
++i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (i != s.size() && std::isalpha(s[i]))
|
||||
{
|
||||
name.push_back(s[i]);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (name.size() < 3)
|
||||
throw_invalid(s, i, "Found name to be shorter than 3 characters");
|
||||
return i;
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned
|
||||
read_signed_time(const string_t& s, unsigned i,
|
||||
std::chrono::seconds& t)
|
||||
{
|
||||
if (i == s.size())
|
||||
throw_invalid(s, i, "Expected to read signed time, but found end of string");
|
||||
bool negative = false;
|
||||
if (s[i] == '-')
|
||||
{
|
||||
negative = true;
|
||||
++i;
|
||||
}
|
||||
else if (s[i] == '+')
|
||||
++i;
|
||||
i = read_unsigned_time(s, i, t);
|
||||
if (negative)
|
||||
t = -t;
|
||||
return i;
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned
|
||||
read_unsigned_time(const string_t& s, unsigned i, std::chrono::seconds& t)
|
||||
{
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
if (i == s.size())
|
||||
throw_invalid(s, i, "Expected to read unsigned time, but found end of string");
|
||||
unsigned x;
|
||||
i = read_unsigned(s, i, 2, x, "Expected to find hours [0, 24]");
|
||||
t = hours{x};
|
||||
if (i != s.size() && s[i] == ':')
|
||||
{
|
||||
++i;
|
||||
i = read_unsigned(s, i, 2, x, "Expected to find minutes [0, 59]");
|
||||
t += minutes{x};
|
||||
if (i != s.size() && s[i] == ':')
|
||||
{
|
||||
++i;
|
||||
i = read_unsigned(s, i, 2, x, "Expected to find seconds [0, 59]");
|
||||
t += seconds{x};
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned
|
||||
read_unsigned(const string_t& s, unsigned i, unsigned limit, unsigned& u,
|
||||
const string_t& message)
|
||||
{
|
||||
if (i == s.size() || !std::isdigit(s[i]))
|
||||
throw_invalid(s, i, message);
|
||||
u = static_cast<unsigned>(s[i] - '0');
|
||||
unsigned count = 1;
|
||||
for (++i; count < limit && i != s.size() && std::isdigit(s[i]); ++i, ++count)
|
||||
u = u * 10 + static_cast<unsigned>(s[i] - '0');
|
||||
return i;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace Posix
|
||||
|
||||
namespace date
|
||||
{
|
||||
|
||||
template <>
|
||||
struct zoned_traits<Posix::time_zone>
|
||||
{
|
||||
|
||||
#if HAS_STRING_VIEW
|
||||
|
||||
static
|
||||
Posix::time_zone
|
||||
locate_zone(std::string_view name)
|
||||
{
|
||||
return Posix::time_zone{name};
|
||||
}
|
||||
|
||||
#else // !HAS_STRING_VIEW
|
||||
|
||||
static
|
||||
Posix::time_zone
|
||||
locate_zone(const std::string& name)
|
||||
{
|
||||
return Posix::time_zone{name};
|
||||
}
|
||||
|
||||
static
|
||||
Posix::time_zone
|
||||
locate_zone(const char* name)
|
||||
{
|
||||
return Posix::time_zone{name};
|
||||
}
|
||||
|
||||
#endif // !HAS_STRING_VIEW
|
||||
|
||||
};
|
||||
|
||||
} // namespace date
|
||||
|
||||
#endif // PTZ_H
|
3151
include/date/solar_hijri.h
Normal file
3151
include/date/solar_hijri.h
Normal file
File diff suppressed because it is too large
Load Diff
2792
include/date/tz.h
Normal file
2792
include/date/tz.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,19 +2,19 @@
|
||||
#define TZ_PRIVATE_H
|
||||
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -22,12 +22,34 @@
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// Our apologies. When the previous paragraph was written, lowercase had not yet
|
||||
// been invented (that would involve another several millennia of evolution).
|
||||
// We did not mean to shout.
|
||||
|
||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
||||
#include "tz.h"
|
||||
#else
|
||||
#include "date.h"
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
namespace date
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if !USE_OS_TZDB
|
||||
|
||||
enum class tz {utc, local, standard};
|
||||
|
||||
//forward declare to avoid warnings in gcc 6.2
|
||||
class MonthDayTime;
|
||||
std::istream& operator>>(std::istream& is, MonthDayTime& x);
|
||||
std::ostream& operator<<(std::ostream& os, const MonthDayTime& x);
|
||||
|
||||
|
||||
class MonthDayTime
|
||||
{
|
||||
private:
|
||||
@ -61,9 +83,9 @@ private:
|
||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
||||
U() : month_day_{date::jan/1} {}
|
||||
#else
|
||||
U() :
|
||||
month_day_(date::jan/1),
|
||||
month_weekday_last_(date::month(0U), date::weekday_last(date::weekday(0U)))
|
||||
U() :
|
||||
month_day_(date::jan/1),
|
||||
month_weekday_last_(date::month(0U), date::weekday_last(date::weekday(0U)))
|
||||
{}
|
||||
|
||||
#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
||||
@ -80,7 +102,7 @@ private:
|
||||
|
||||
public:
|
||||
MonthDayTime() = default;
|
||||
MonthDayTime(second_point tp, tz timezone);
|
||||
MonthDayTime(local_seconds tp, tz timezone);
|
||||
MonthDayTime(const date::month_day& md, tz timezone);
|
||||
|
||||
date::day day() const;
|
||||
@ -89,11 +111,11 @@ public:
|
||||
|
||||
void canonicalize(date::year y);
|
||||
|
||||
second_point
|
||||
sys_seconds
|
||||
to_sys(date::year y, std::chrono::seconds offset, std::chrono::seconds save) const;
|
||||
date::day_point to_day_point(date::year y) const;
|
||||
sys_days to_sys_days(date::year y) const;
|
||||
|
||||
second_point to_time_point(date::year y) const;
|
||||
sys_seconds to_time_point(date::year y) const;
|
||||
int compare(date::year y, const MonthDayTime& x, date::year yx,
|
||||
std::chrono::seconds offset, std::chrono::minutes prev_save) const;
|
||||
|
||||
@ -104,11 +126,25 @@ public:
|
||||
// A Rule specifies one or more set of datetimes without using an offset.
|
||||
// Multiple dates are specified with multiple years. The years in effect
|
||||
// go from starting_year_ to ending_year_, inclusive. starting_year_ <=
|
||||
// ending_year_. save_ is ineffect for times from the specified time
|
||||
// ending_year_. save_ is in effect for times from the specified time
|
||||
// onward, including the specified time. When the specified time is
|
||||
// local, it uses the save_ from the chronologically previous Rule, or if
|
||||
// there is none, 0.
|
||||
|
||||
//forward declare to avoid warnings in gcc 6.2
|
||||
class Rule;
|
||||
bool operator==(const Rule& x, const Rule& y);
|
||||
bool operator<(const Rule& x, const Rule& y);
|
||||
bool operator==(const Rule& x, const date::year& y);
|
||||
bool operator<(const Rule& x, const date::year& y);
|
||||
bool operator==(const date::year& x, const Rule& y);
|
||||
bool operator<(const date::year& x, const Rule& y);
|
||||
bool operator==(const Rule& x, const std::string& y);
|
||||
bool operator<(const Rule& x, const std::string& y);
|
||||
bool operator==(const std::string& x, const Rule& y);
|
||||
bool operator<(const std::string& x, const Rule& y);
|
||||
std::ostream& operator<<(std::ostream& os, const Rule& r);
|
||||
|
||||
class Rule
|
||||
{
|
||||
private:
|
||||
@ -181,7 +217,7 @@ inline bool operator> (const std::string& x, const Rule& y) {return y < x;}
|
||||
inline bool operator<=(const std::string& x, const Rule& y) {return !(y < x);}
|
||||
inline bool operator>=(const std::string& x, const Rule& y) {return !(x < y);}
|
||||
|
||||
struct Zone::zonelet
|
||||
struct zonelet
|
||||
{
|
||||
enum tag {has_rule, has_save, is_empty};
|
||||
|
||||
@ -203,14 +239,14 @@ struct Zone::zonelet
|
||||
U& operator=(const U&) = delete;
|
||||
} u;
|
||||
|
||||
std::string format_;
|
||||
date::year until_year_{0};
|
||||
MonthDayTime until_date_;
|
||||
second_point until_utc_;
|
||||
second_point until_std_;
|
||||
second_point until_loc_;
|
||||
std::chrono::minutes initial_save_{};
|
||||
std::string initial_abbrev_;
|
||||
std::string format_;
|
||||
date::year until_year_{0};
|
||||
MonthDayTime until_date_;
|
||||
sys_seconds until_utc_;
|
||||
local_seconds until_std_;
|
||||
local_seconds until_loc_;
|
||||
std::chrono::minutes initial_save_{0};
|
||||
std::string initial_abbrev_;
|
||||
std::pair<const Rule*, date::year> first_rule_{nullptr, date::year::min()};
|
||||
std::pair<const Rule*, date::year> last_rule_{nullptr, date::year::max()};
|
||||
|
||||
@ -220,6 +256,61 @@ struct Zone::zonelet
|
||||
zonelet& operator=(const zonelet&) = delete;
|
||||
};
|
||||
|
||||
#else // USE_OS_TZDB
|
||||
|
||||
struct ttinfo
|
||||
{
|
||||
std::int32_t tt_gmtoff;
|
||||
unsigned char tt_isdst;
|
||||
unsigned char tt_abbrind;
|
||||
unsigned char pad[2];
|
||||
};
|
||||
|
||||
static_assert(sizeof(ttinfo) == 8, "");
|
||||
|
||||
struct expanded_ttinfo
|
||||
{
|
||||
std::chrono::seconds offset;
|
||||
std::string abbrev;
|
||||
bool is_dst;
|
||||
};
|
||||
|
||||
struct transition
|
||||
{
|
||||
sys_seconds timepoint;
|
||||
const expanded_ttinfo* info;
|
||||
|
||||
transition(sys_seconds tp, const expanded_ttinfo* i = nullptr)
|
||||
: timepoint(tp)
|
||||
, info(i)
|
||||
{}
|
||||
|
||||
friend
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const transition& t)
|
||||
{
|
||||
using date::operator<<;
|
||||
os << t.timepoint << "Z ";
|
||||
if (t.info->offset >= std::chrono::seconds{0})
|
||||
os << '+';
|
||||
os << make_time(t.info->offset);
|
||||
if (t.info->is_dst > 0)
|
||||
os << " daylight ";
|
||||
else
|
||||
os << " standard ";
|
||||
os << t.info->abbrev;
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // USE_OS_TZDB
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace date
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||
#include "tz.h"
|
||||
#endif
|
||||
|
||||
#endif // TZ_PRIVATE_H
|
11
library.json
Normal file
11
library.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "date",
|
||||
"version": "1.0.0",
|
||||
"build": {
|
||||
"includeDir": "include",
|
||||
"srcFilter":
|
||||
[
|
||||
"+<->"
|
||||
]
|
||||
}
|
||||
}
|
337
src/ios.mm
Normal file
337
src/ios.mm
Normal file
@ -0,0 +1,337 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2016 Alexander Kormanovsky
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
|
||||
#include "date/ios.h"
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <zlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifndef TAR_DEBUG
|
||||
# define TAR_DEBUG 0
|
||||
#endif
|
||||
|
||||
#define INTERNAL_DIR "Library"
|
||||
#define TZDATA_DIR "tzdata"
|
||||
#define TARGZ_EXTENSION "tar.gz"
|
||||
|
||||
#define TAR_BLOCK_SIZE 512
|
||||
#define TAR_TYPE_POSITION 156
|
||||
#define TAR_NAME_POSITION 0
|
||||
#define TAR_NAME_SIZE 100
|
||||
#define TAR_SIZE_POSITION 124
|
||||
#define TAR_SIZE_SIZE 12
|
||||
|
||||
namespace date
|
||||
{
|
||||
namespace iOSUtils
|
||||
{
|
||||
|
||||
struct TarInfo
|
||||
{
|
||||
char objType;
|
||||
std::string objName;
|
||||
size_t realContentSize; // writable size without padding zeroes
|
||||
size_t blocksContentSize; // adjusted size to 512 bytes blocks
|
||||
bool success;
|
||||
};
|
||||
|
||||
std::string convertCFStringRefPathToCStringPath(CFStringRef ref);
|
||||
bool extractTzdata(CFURLRef homeUrl, CFURLRef archiveUrl, std::string destPath);
|
||||
TarInfo getTarObjectInfo(std::ifstream &readStream);
|
||||
std::string getTarObject(std::ifstream &readStream, int64_t size);
|
||||
bool writeFile(const std::string &tzdataPath, const std::string &fileName,
|
||||
const std::string &data, size_t realContentSize);
|
||||
|
||||
std::string
|
||||
get_current_timezone()
|
||||
{
|
||||
CFTimeZoneRef tzRef = CFTimeZoneCopySystem();
|
||||
CFStringRef tzNameRef = CFTimeZoneGetName(tzRef);
|
||||
CFIndex bufferSize = CFStringGetLength(tzNameRef) + 1;
|
||||
char buffer[bufferSize];
|
||||
|
||||
if (CFStringGetCString(tzNameRef, buffer, bufferSize, kCFStringEncodingUTF8))
|
||||
{
|
||||
CFRelease(tzRef);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
CFRelease(tzRef);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string
|
||||
get_tzdata_path()
|
||||
{
|
||||
CFURLRef homeUrlRef = CFCopyHomeDirectoryURL();
|
||||
CFStringRef homePath = CFURLCopyPath(homeUrlRef);
|
||||
std::string path(std::string(convertCFStringRefPathToCStringPath(homePath)) +
|
||||
INTERNAL_DIR + "/" + TZDATA_DIR);
|
||||
std::string result_path(std::string(convertCFStringRefPathToCStringPath(homePath)) +
|
||||
INTERNAL_DIR);
|
||||
|
||||
if (access(path.c_str(), F_OK) == 0)
|
||||
{
|
||||
#if TAR_DEBUG
|
||||
printf("tzdata dir exists\n");
|
||||
#endif
|
||||
CFRelease(homeUrlRef);
|
||||
CFRelease(homePath);
|
||||
|
||||
return result_path;
|
||||
}
|
||||
|
||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||
CFArrayRef paths = CFBundleCopyResourceURLsOfType(mainBundle, CFSTR(TARGZ_EXTENSION),
|
||||
NULL);
|
||||
|
||||
if (CFArrayGetCount(paths) != 0)
|
||||
{
|
||||
// get archive path, assume there is no other tar.gz in bundle
|
||||
CFURLRef archiveUrl = static_cast<CFURLRef>(CFArrayGetValueAtIndex(paths, 0));
|
||||
CFStringRef archiveName = CFURLCopyPath(archiveUrl);
|
||||
archiveUrl = CFBundleCopyResourceURL(mainBundle, archiveName, NULL, NULL);
|
||||
|
||||
extractTzdata(homeUrlRef, archiveUrl, path);
|
||||
|
||||
CFRelease(archiveUrl);
|
||||
CFRelease(archiveName);
|
||||
}
|
||||
|
||||
CFRelease(homeUrlRef);
|
||||
CFRelease(homePath);
|
||||
CFRelease(paths);
|
||||
|
||||
return result_path;
|
||||
}
|
||||
|
||||
std::string
|
||||
convertCFStringRefPathToCStringPath(CFStringRef ref)
|
||||
{
|
||||
CFIndex bufferSize = CFStringGetMaximumSizeOfFileSystemRepresentation(ref);
|
||||
char *buffer = new char[bufferSize];
|
||||
CFStringGetFileSystemRepresentation(ref, buffer, bufferSize);
|
||||
auto result = std::string(buffer);
|
||||
delete[] buffer;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
extractTzdata(CFURLRef homeUrl, CFURLRef archiveUrl, std::string destPath)
|
||||
{
|
||||
std::string TAR_TMP_PATH = "/tmp.tar";
|
||||
|
||||
CFStringRef homeStringRef = CFURLCopyPath(homeUrl);
|
||||
auto homePath = convertCFStringRefPathToCStringPath(homeStringRef);
|
||||
CFRelease(homeStringRef);
|
||||
|
||||
CFStringRef archiveStringRef = CFURLCopyPath(archiveUrl);
|
||||
auto archivePath = convertCFStringRefPathToCStringPath(archiveStringRef);
|
||||
CFRelease(archiveStringRef);
|
||||
|
||||
// create Library path
|
||||
auto libraryPath = homePath + INTERNAL_DIR;
|
||||
|
||||
// create tzdata path
|
||||
auto tzdataPath = libraryPath + "/" + TZDATA_DIR;
|
||||
|
||||
// -- replace %20 with " "
|
||||
const std::string search = "%20";
|
||||
const std::string replacement = " ";
|
||||
size_t pos = 0;
|
||||
|
||||
while ((pos = archivePath.find(search, pos)) != std::string::npos) {
|
||||
archivePath.replace(pos, search.length(), replacement);
|
||||
pos += replacement.length();
|
||||
}
|
||||
|
||||
gzFile tarFile = gzopen(archivePath.c_str(), "rb");
|
||||
|
||||
// create tar unpacking path
|
||||
auto tarPath = libraryPath + TAR_TMP_PATH;
|
||||
|
||||
// create tzdata directory
|
||||
mkdir(destPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
|
||||
// ======= extract tar ========
|
||||
|
||||
std::ofstream os(tarPath.c_str(), std::ofstream::out | std::ofstream::app);
|
||||
unsigned int bufferLength = 1024 * 256; // 256Kb
|
||||
unsigned char *buffer = (unsigned char *)malloc(bufferLength);
|
||||
bool success = true;
|
||||
|
||||
while (true)
|
||||
{
|
||||
int readBytes = gzread(tarFile, buffer, bufferLength);
|
||||
|
||||
if (readBytes > 0)
|
||||
{
|
||||
os.write((char *) &buffer[0], readBytes);
|
||||
}
|
||||
else
|
||||
if (readBytes == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
if (readBytes == -1)
|
||||
{
|
||||
printf("decompression failed\n");
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("unexpected zlib state\n");
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
os.close();
|
||||
free(buffer);
|
||||
gzclose(tarFile);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
remove(tarPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// ======== extract files =========
|
||||
|
||||
uint64_t location = 0; // Position in the file
|
||||
|
||||
// get file size
|
||||
struct stat stat_buf;
|
||||
int res = stat(tarPath.c_str(), &stat_buf);
|
||||
if (res != 0)
|
||||
{
|
||||
printf("error file size\n");
|
||||
remove(tarPath.c_str());
|
||||
return false;
|
||||
}
|
||||
int64_t tarSize = stat_buf.st_size;
|
||||
|
||||
// create read stream
|
||||
std::ifstream is(tarPath.c_str(), std::ifstream::in | std::ifstream::binary);
|
||||
|
||||
// process files
|
||||
while (location < tarSize)
|
||||
{
|
||||
TarInfo info = getTarObjectInfo(is);
|
||||
|
||||
if (!info.success || info.realContentSize == 0)
|
||||
{
|
||||
break; // something wrong or all files are read
|
||||
}
|
||||
|
||||
switch (info.objType)
|
||||
{
|
||||
case '0': // file
|
||||
case '\0': //
|
||||
{
|
||||
std::string obj = getTarObject(is, info.blocksContentSize);
|
||||
#if TAR_DEBUG
|
||||
size += info.realContentSize;
|
||||
printf("#%i %s file size %lld written total %ld from %lld\n", ++count,
|
||||
info.objName.c_str(), info.realContentSize, size, tarSize);
|
||||
#endif
|
||||
writeFile(tzdataPath, info.objName, obj, info.realContentSize);
|
||||
location += info.blocksContentSize;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remove(tarPath.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TarInfo
|
||||
getTarObjectInfo(std::ifstream &readStream)
|
||||
{
|
||||
int64_t length = TAR_BLOCK_SIZE;
|
||||
char buffer[length];
|
||||
char type;
|
||||
char name[TAR_NAME_SIZE + 1];
|
||||
char sizeBuf[TAR_SIZE_SIZE + 1];
|
||||
|
||||
readStream.read(buffer, length);
|
||||
|
||||
memcpy(&type, &buffer[TAR_TYPE_POSITION], 1);
|
||||
|
||||
memset(&name, '\0', TAR_NAME_SIZE + 1);
|
||||
memcpy(&name, &buffer[TAR_NAME_POSITION], TAR_NAME_SIZE);
|
||||
|
||||
memset(&sizeBuf, '\0', TAR_SIZE_SIZE + 1);
|
||||
memcpy(&sizeBuf, &buffer[TAR_SIZE_POSITION], TAR_SIZE_SIZE);
|
||||
size_t realSize = strtol(sizeBuf, NULL, 8);
|
||||
size_t blocksSize = realSize + (TAR_BLOCK_SIZE - (realSize % TAR_BLOCK_SIZE));
|
||||
|
||||
return {type, std::string(name), realSize, blocksSize, true};
|
||||
}
|
||||
|
||||
std::string
|
||||
getTarObject(std::ifstream &readStream, int64_t size)
|
||||
{
|
||||
char buffer[size];
|
||||
readStream.read(buffer, size);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
bool
|
||||
writeFile(const std::string &tzdataPath, const std::string &fileName, const std::string &data,
|
||||
size_t realContentSize)
|
||||
{
|
||||
std::ofstream os(tzdataPath + "/" + fileName, std::ofstream::out | std::ofstream::binary);
|
||||
|
||||
if (!os) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// trim empty space
|
||||
char trimmedData[realContentSize + 1];
|
||||
memset(&trimmedData, '\0', realContentSize);
|
||||
memcpy(&trimmedData, data.c_str(), realContentSize);
|
||||
|
||||
// write
|
||||
os.write(trimmedData, realContentSize);
|
||||
os.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace iOSUtils
|
||||
} // namespace date
|
||||
|
||||
#endif // TARGET_OS_IPHONE
|
3939
src/tz.cpp
Normal file
3939
src/tz.cpp
Normal file
File diff suppressed because it is too large
Load Diff
75
test/clock_cast_test/constexpr.pass.cpp
Normal file
75
test/clock_cast_test/constexpr.pass.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2019 nanoric
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "tz.h"
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
struct const_clock {
|
||||
using duration =
|
||||
typename std::common_type<std::chrono::system_clock::duration,
|
||||
date::days>::type;
|
||||
using rep = duration::rep;
|
||||
using period = duration::period;
|
||||
using time_point = std::chrono::time_point<const_clock, duration>;
|
||||
|
||||
static constexpr date::sys_days epoch { date::days { 1000 } };
|
||||
|
||||
template <typename Duration>
|
||||
static std::chrono::time_point<std::chrono::system_clock,
|
||||
typename std::common_type<Duration, date::days>::type>
|
||||
CONSTCD11 to_sys(std::chrono::time_point<const_clock, Duration> const& tp)
|
||||
{
|
||||
return epoch + tp.time_since_epoch();
|
||||
}
|
||||
|
||||
template <typename Duration>
|
||||
static std::chrono::time_point<const_clock,
|
||||
typename std::common_type<Duration, date::days>::type>
|
||||
CONSTCD11 from_sys(
|
||||
std::chrono::time_point<std::chrono::system_clock, Duration> const&
|
||||
tp)
|
||||
{
|
||||
using res = std::chrono::time_point<const_clock,
|
||||
typename std::common_type<Duration, date::days>::type>;
|
||||
return res(tp - epoch);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
using const_days = time_point<const_clock, days>;
|
||||
|
||||
CONSTCD14 sys_days sys { days { 1024 } };
|
||||
static_assert(sys.time_since_epoch().count() == 1024, "");
|
||||
|
||||
CONSTCD14 const_days c {clock_cast<const_clock>(sys)};
|
||||
CONSTCD14 sys_days sys2 {clock_cast<system_clock>(c)};
|
||||
CONSTCD14 sys_days sys3 { clock_cast<system_clock>(const_days(days(48))) };
|
||||
#if __cplusplus >= 201402L
|
||||
static_assert(c.time_since_epoch().count() == 24, "");
|
||||
static_assert(sys2.time_since_epoch().count() == 1024, "");
|
||||
static_assert(sys3.time_since_epoch().count() == 1048, "");
|
||||
#endif
|
||||
}
|
213
test/clock_cast_test/custom_clock.pass.cpp
Normal file
213
test/clock_cast_test/custom_clock.pass.cpp
Normal file
@ -0,0 +1,213 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017, 2018 Tomasz Kamiński
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "tz.h"
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
//used to count number of conversion
|
||||
int conversions = 0;
|
||||
|
||||
//to/from impl
|
||||
struct mil_clock
|
||||
{
|
||||
using duration = typename std::common_type<std::chrono::system_clock::duration, date::days>::type;
|
||||
using rep = duration::rep;
|
||||
using period = duration::period;
|
||||
using time_point = std::chrono::time_point<mil_clock, duration>;
|
||||
|
||||
static constexpr date::sys_days epoch{date::days{1000}};
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<std::chrono::system_clock, typename std::common_type<Duration, date::days>::type>
|
||||
to_sys(std::chrono::time_point<mil_clock, Duration> const& tp)
|
||||
{
|
||||
++conversions;
|
||||
return epoch + tp.time_since_epoch();
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<mil_clock, typename std::common_type<Duration, date::days>::type>
|
||||
from_sys(std::chrono::time_point<std::chrono::system_clock, Duration> const& tp)
|
||||
{
|
||||
++conversions;
|
||||
using res = std::chrono::time_point<mil_clock, typename std::common_type<Duration, date::days>::type>;
|
||||
return res(tp - epoch);
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<date::local_t, typename std::common_type<Duration, date::days>::type>
|
||||
to_local(std::chrono::time_point<mil_clock, Duration> const& tp)
|
||||
{
|
||||
return date::clock_cast<date::local_t>(to_sys(tp));
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<mil_clock, typename std::common_type<Duration, date::days>::type>
|
||||
from_local(std::chrono::time_point<date::local_t, Duration> const& tp)
|
||||
{
|
||||
return from_sys(date::clock_cast<std::chrono::system_clock>(tp));
|
||||
}
|
||||
|
||||
|
||||
static time_point now()
|
||||
{
|
||||
return from_sys(std::chrono::system_clock::now());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
date::sys_days const mil_clock::epoch;
|
||||
|
||||
// traits example
|
||||
struct s2s_clock
|
||||
{
|
||||
using duration = std::chrono::system_clock::duration;
|
||||
using rep = duration::rep;
|
||||
using period = duration::period;
|
||||
using time_point = std::chrono::time_point<s2s_clock, duration>;
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<std::chrono::system_clock, Duration>
|
||||
to_sys(std::chrono::time_point<s2s_clock, Duration> const& tp)
|
||||
{
|
||||
++conversions;
|
||||
return std::chrono::time_point<std::chrono::system_clock, Duration>(tp.time_since_epoch());
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<s2s_clock, Duration>
|
||||
from_sys(std::chrono::time_point<std::chrono::system_clock, Duration> const& tp)
|
||||
{
|
||||
++conversions;
|
||||
return std::chrono::time_point<s2s_clock, Duration>(tp.time_since_epoch());
|
||||
}
|
||||
|
||||
static time_point now()
|
||||
{
|
||||
return from_sys(std::chrono::system_clock::now());
|
||||
}
|
||||
};
|
||||
|
||||
namespace date
|
||||
{
|
||||
template<>
|
||||
struct clock_time_conversion<mil_clock, s2s_clock>
|
||||
{
|
||||
template<typename Duration>
|
||||
std::chrono::time_point<mil_clock, typename std::common_type<Duration, date::days>::type>
|
||||
operator()(std::chrono::time_point<s2s_clock, Duration> const& tp)
|
||||
{
|
||||
++conversions;
|
||||
using res = std::chrono::time_point<mil_clock, typename std::common_type<Duration, date::days>::type>;
|
||||
return res(tp.time_since_epoch() - mil_clock::epoch.time_since_epoch());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using sys_clock = std::chrono::system_clock;
|
||||
|
||||
// self
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto mt = mil_clock::from_sys(st);
|
||||
|
||||
assert(clock_cast<mil_clock>(mt) == mt);
|
||||
}
|
||||
|
||||
// mil <-> local
|
||||
{
|
||||
local_days lt(1997_y/dec/12);
|
||||
auto mt = mil_clock::from_local(lt);
|
||||
|
||||
assert(clock_cast<mil_clock>(lt) == mt);
|
||||
assert(clock_cast<local_t>(mt) == lt);
|
||||
}
|
||||
|
||||
// mil <-> sys
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto mt = mil_clock::from_sys(st);
|
||||
|
||||
assert(clock_cast<mil_clock>(st) == mt);
|
||||
assert(clock_cast<sys_clock>(mt) == st);
|
||||
}
|
||||
|
||||
// mil <-> utc
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto mt = mil_clock::from_sys(st);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
|
||||
assert(clock_cast<mil_clock>(ut) == mt);
|
||||
assert(clock_cast<utc_clock>(mt) == ut);
|
||||
}
|
||||
|
||||
// mil <-> tai
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto mt = mil_clock::from_sys(st);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto tt = tai_clock::from_utc(ut);
|
||||
|
||||
assert(clock_cast<tai_clock>(mt) == tt);
|
||||
assert(clock_cast<mil_clock>(tt) == mt);
|
||||
}
|
||||
|
||||
// mil <-> gps
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto mt = mil_clock::from_sys(st);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto gt = gps_clock::from_utc(ut);
|
||||
|
||||
assert(clock_cast<gps_clock>(mt) == gt);
|
||||
assert(clock_cast<mil_clock>(gt) == mt);
|
||||
}
|
||||
|
||||
// s2s -> mil
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto mt = mil_clock::from_sys(st);
|
||||
auto s2t = s2s_clock::from_sys(st);
|
||||
|
||||
//direct trait conversion
|
||||
conversions = 0;
|
||||
assert(clock_cast<mil_clock>(s2t) == mt);
|
||||
assert(conversions == 1);
|
||||
|
||||
//uses sys_clock
|
||||
conversions = 0;
|
||||
assert(clock_cast<s2s_clock>(mt) == s2t);
|
||||
assert(conversions == 2);
|
||||
}
|
||||
}
|
90
test/clock_cast_test/deprecated.pass.cpp
Normal file
90
test/clock_cast_test/deprecated.pass.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Tomasz Kamiński
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "tz.h"
|
||||
#include <cassert>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
|
||||
// sys <-> utc
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
|
||||
assert(to_utc_time(st) == ut);
|
||||
assert(to_sys_time(ut) == st);
|
||||
}
|
||||
|
||||
// tai <-> utc
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto tt = tai_clock::from_utc(ut);
|
||||
|
||||
assert(to_tai_time(ut) == tt);
|
||||
assert(to_utc_time(tt) == ut);
|
||||
}
|
||||
|
||||
// tai <-> sys
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto tt = tai_clock::from_utc(ut);
|
||||
|
||||
assert(to_tai_time(st) == tt);
|
||||
assert(to_sys_time(tt) == st);
|
||||
}
|
||||
|
||||
// gps <-> utc
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto gt = gps_clock::from_utc(ut);
|
||||
|
||||
assert(to_gps_time(ut) == gt);
|
||||
assert(to_utc_time(gt) == ut);
|
||||
}
|
||||
|
||||
// gps <-> sys
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto gt = gps_clock::from_utc(ut);
|
||||
|
||||
assert(to_gps_time(st) == gt);
|
||||
assert(to_sys_time(gt) == st);
|
||||
}
|
||||
|
||||
// tai <-> gps
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto tt = tai_clock::from_utc(ut);
|
||||
auto gt = gps_clock::from_utc(ut);
|
||||
|
||||
assert(to_gps_time(tt) == gt);
|
||||
assert(to_tai_time(gt) == tt);
|
||||
}
|
||||
}
|
132
test/clock_cast_test/local_t.pass.cpp
Normal file
132
test/clock_cast_test/local_t.pass.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Tomasz Kamiński
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <chrono>
|
||||
#include "date/tz.h"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
|
||||
// self
|
||||
{
|
||||
auto ls = local_days{1970_y/January/1_d};
|
||||
assert(clock_cast<local_t>(ls) == ls);
|
||||
}
|
||||
|
||||
/// sys epoch
|
||||
{
|
||||
auto ls = local_days{1970_y/January/1_d};
|
||||
auto st = clock_cast<system_clock>(ls);
|
||||
assert(clock_cast<local_t>(st) == ls);
|
||||
assert(st.time_since_epoch() == seconds(0));
|
||||
}
|
||||
|
||||
/// sys 2000 case
|
||||
{
|
||||
auto ls = local_days{2000_y/January/1_d};
|
||||
auto st = clock_cast<system_clock>(ls);
|
||||
assert(clock_cast<local_t>(st) == ls);
|
||||
assert(st.time_since_epoch() == seconds(946684800));
|
||||
}
|
||||
|
||||
/// utc epoch
|
||||
{
|
||||
auto lu = local_days{1970_y/January/1_d};
|
||||
auto ut = clock_cast<utc_clock>(lu);
|
||||
assert(clock_cast<local_t>(ut) == lu);
|
||||
assert(ut.time_since_epoch() == seconds(0));
|
||||
}
|
||||
|
||||
// utc leap second
|
||||
{
|
||||
auto lu = local_days{2015_y/July/1_d} - milliseconds(1);
|
||||
auto ut = clock_cast<utc_clock>(lu) + milliseconds(50); //into leap second
|
||||
|
||||
assert(clock_cast<local_t>(ut) == lu);
|
||||
}
|
||||
|
||||
/// utc paper example
|
||||
{
|
||||
auto lu = local_days{2000_y/January/1_d};
|
||||
auto ut = clock_cast<utc_clock>(lu);
|
||||
assert(clock_cast<local_t>(ut) == lu);
|
||||
assert(ut.time_since_epoch() == seconds(946684822));
|
||||
}
|
||||
|
||||
/// tai epoch
|
||||
{
|
||||
auto lt = local_days{1958_y/January/1_d};
|
||||
auto tt = clock_cast<tai_clock>(lt);
|
||||
assert(clock_cast<local_t>(tt) == lt);
|
||||
assert(tt.time_since_epoch() == seconds(0));
|
||||
|
||||
auto lu = local_days{1958_y/January/1_d} - seconds(10);
|
||||
auto ut = clock_cast<utc_clock>(lu);
|
||||
assert(clock_cast<tai_clock>(ut) == tt);
|
||||
}
|
||||
|
||||
// tai paper example
|
||||
{
|
||||
auto lt = local_days{2000_y/January/1_d} + seconds(32);
|
||||
auto tt = clock_cast<tai_clock>(lt);
|
||||
assert(clock_cast<local_t>(tt) == lt);
|
||||
|
||||
auto lu = local_days{2000_y/January/1_d};
|
||||
auto ut = clock_cast<utc_clock>(lu);
|
||||
assert(clock_cast<tai_clock>(ut) == tt);
|
||||
}
|
||||
|
||||
/// gps epoch
|
||||
{
|
||||
auto lg = local_days{1980_y/January/Sunday[1]};
|
||||
auto gt = clock_cast<gps_clock>(lg);
|
||||
assert(clock_cast<local_t>(gt) == lg);
|
||||
assert(gt.time_since_epoch() == seconds(0));
|
||||
|
||||
auto lu = local_days{1980_y/January/Sunday[1]};
|
||||
auto ut = clock_cast<utc_clock>(lu);
|
||||
assert(clock_cast<gps_clock>(ut) == gt);
|
||||
|
||||
auto lt = local_days{1980_y/January/Sunday[1]} + seconds(19);
|
||||
auto tt = clock_cast<tai_clock>(lt);
|
||||
assert(clock_cast<gps_clock>(tt) == gt);
|
||||
}
|
||||
|
||||
// gps 2000 example
|
||||
{
|
||||
auto lg = local_days{2000_y/January/1_d};
|
||||
auto gt = clock_cast<gps_clock>(lg);
|
||||
assert(clock_cast<local_t>(gt) == lg);
|
||||
|
||||
auto lu = local_days{2000_y/January/1_d} - seconds(13);
|
||||
auto ut = clock_cast<utc_clock>(lu);
|
||||
assert(clock_cast<gps_clock>(ut) == gt);
|
||||
|
||||
auto lt = local_days{2000_y/January/1_d} + seconds(19);
|
||||
auto tt = clock_cast<tai_clock>(lt);
|
||||
assert(clock_cast<gps_clock>(tt) == gt);
|
||||
}
|
||||
|
||||
}
|
251
test/clock_cast_test/noncastable.pass.cpp
Normal file
251
test/clock_cast_test/noncastable.pass.cpp
Normal file
@ -0,0 +1,251 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017, 2018 Tomasz Kamiński
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "tz.h"
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
template<typename SourceClock, typename DestClock, typename = void>
|
||||
struct is_clock_castable
|
||||
: std::false_type
|
||||
{};
|
||||
|
||||
template<typename SourceClock, typename DestClock>
|
||||
struct is_clock_castable<SourceClock, DestClock, decltype(date::clock_cast<DestClock>(typename SourceClock::time_point()), void())>
|
||||
: std::true_type
|
||||
{};
|
||||
|
||||
|
||||
//Clock based on steady clock, not related to wall time (sys_clock/utc_clock)
|
||||
struct steady_based_clock
|
||||
{
|
||||
using duration = std::chrono::steady_clock::duration;
|
||||
using rep = duration::rep;
|
||||
using period = duration::period;
|
||||
using time_point = std::chrono::time_point<steady_based_clock, duration>;
|
||||
|
||||
static time_point now()
|
||||
{
|
||||
return time_point(std::chrono::steady_clock::now().time_since_epoch());
|
||||
}
|
||||
};
|
||||
|
||||
//Traits that allow conversion between steady_clock and steady_based clock
|
||||
//Does not use wall-time clocks as rally (sys/utc)
|
||||
namespace date
|
||||
{
|
||||
template<>
|
||||
struct clock_time_conversion<std::chrono::steady_clock, steady_based_clock>
|
||||
{
|
||||
template<typename Duration>
|
||||
std::chrono::time_point<std::chrono::steady_clock, Duration>
|
||||
operator()(std::chrono::time_point<steady_based_clock, Duration> const& tp) const
|
||||
{
|
||||
using res = std::chrono::time_point<std::chrono::steady_clock, Duration>;
|
||||
return res(tp.time_since_epoch());
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct clock_time_conversion<steady_based_clock, std::chrono::steady_clock>
|
||||
{
|
||||
template<typename Duration>
|
||||
std::chrono::time_point<steady_based_clock, Duration>
|
||||
operator()(std::chrono::time_point<std::chrono::steady_clock, Duration> const& tp) const
|
||||
{
|
||||
using res = std::chrono::time_point<steady_based_clock, Duration>;
|
||||
return res(tp.time_since_epoch());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//Ambigous clocks both providing to/from_sys and to/from_utc
|
||||
//They are mock_ups just returning zero time_point
|
||||
struct amb1_clock
|
||||
{
|
||||
using duration = std::chrono::seconds;
|
||||
using rep = duration::rep;
|
||||
using period = duration::period;
|
||||
using time_point = std::chrono::time_point<amb1_clock>;
|
||||
|
||||
static time_point now()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<std::chrono::system_clock, Duration>
|
||||
to_sys(std::chrono::time_point<amb1_clock, Duration> const&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<amb1_clock, Duration>
|
||||
from_sys(std::chrono::time_point<std::chrono::system_clock, Duration> const&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<date::utc_clock, Duration>
|
||||
to_utc(std::chrono::time_point<amb1_clock, Duration> const&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<amb1_clock, Duration>
|
||||
from_utc(std::chrono::time_point<date::utc_clock, Duration> const&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
struct amb2_clock
|
||||
{
|
||||
using duration = std::chrono::seconds;
|
||||
using rep = duration::rep;
|
||||
using period = duration::period;
|
||||
using time_point = std::chrono::time_point<amb2_clock>;
|
||||
|
||||
static time_point now()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<std::chrono::system_clock, Duration>
|
||||
to_sys(std::chrono::time_point<amb2_clock, Duration> const&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<amb2_clock, Duration>
|
||||
from_sys(std::chrono::time_point<std::chrono::system_clock, Duration> const&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<date::utc_clock, Duration>
|
||||
to_utc(std::chrono::time_point<amb2_clock, Duration> const&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
std::chrono::time_point<amb2_clock, Duration>
|
||||
from_utc(std::chrono::time_point<date::utc_clock, Duration> const&)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
namespace date
|
||||
{
|
||||
//Disambiguates that sys_clock is preffered
|
||||
template<>
|
||||
struct clock_time_conversion<amb1_clock, amb2_clock>
|
||||
{
|
||||
template<typename Duration>
|
||||
std::chrono::time_point<amb1_clock, Duration>
|
||||
operator()(std::chrono::time_point<amb2_clock, Duration> const& tp) const
|
||||
{
|
||||
return amb1_clock::from_sys(amb2_clock::to_sys(tp));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
using sys_clock = std::chrono::system_clock;
|
||||
|
||||
//steady_clock (must be different that sys_clock)
|
||||
static_assert(is_clock_castable<steady_clock, steady_clock>::value, "steady_clock -> steady_clock");
|
||||
static_assert(!is_clock_castable<steady_clock, local_t>::value, "steady_clock -> local_t");
|
||||
static_assert(!is_clock_castable<local_t, steady_clock>::value, "local_t -> steady_clock");
|
||||
static_assert(!is_clock_castable<steady_clock, sys_clock>::value, "steady_clock -> sys_clock");
|
||||
static_assert(!is_clock_castable<sys_clock, steady_clock>::value, "sys_clock -> steady_clock");
|
||||
static_assert(!is_clock_castable<steady_clock, utc_clock>::value, "steady_clock -> utc_clock");
|
||||
static_assert(!is_clock_castable<utc_clock, steady_clock>::value, "utc_clock -> steady_clock");
|
||||
static_assert(!is_clock_castable<steady_clock, tai_clock>::value, "steady_clock -> tai_clock");
|
||||
static_assert(!is_clock_castable<tai_clock, steady_clock>::value, "tai_clock -> steady_clock");
|
||||
|
||||
//steady_based_clock (unrelated to sys_clock and utc_clocks)
|
||||
static_assert(is_clock_castable<steady_based_clock, steady_based_clock>::value, "steady_based_clock -> steady_based_clock");
|
||||
static_assert(!is_clock_castable<steady_based_clock, local_t>::value, "steady_based_clock -> local_t");
|
||||
static_assert(!is_clock_castable<local_t, steady_based_clock>::value, "local_t -> steady_based_clock");
|
||||
static_assert(!is_clock_castable<steady_based_clock, sys_clock>::value, "steady_based_clock -> sys_clock");
|
||||
static_assert(!is_clock_castable<sys_clock, steady_based_clock>::value, "sys_clock -> steady_based_clock");
|
||||
static_assert(!is_clock_castable<steady_based_clock, utc_clock>::value, "steady_based_clock -> utc_clock");
|
||||
static_assert(!is_clock_castable<utc_clock, steady_based_clock>::value, "utc_clock -> steady_based_clock");
|
||||
static_assert(!is_clock_castable<steady_based_clock, tai_clock>::value, "steady_based_clock -> tai_clock");
|
||||
static_assert(!is_clock_castable<tai_clock, steady_based_clock>::value, "tai_clock -> steady_based_clock");
|
||||
|
||||
//steady_based <-> steady_clock
|
||||
{
|
||||
auto s1 = steady_clock::time_point(steady_clock::duration(200));
|
||||
auto s2 = steady_based_clock::time_point(steady_based_clock::duration(200));
|
||||
|
||||
assert(clock_cast<steady_based_clock>(s1) == s2);
|
||||
assert(clock_cast<steady_clock>(s2) == s1);
|
||||
}
|
||||
|
||||
//ambX <-> sys/utc works as one rally can be used in each case, or one lead to quicker conversione
|
||||
static_assert(is_clock_castable<amb1_clock, amb1_clock>::value, "amb1_clock -> amb1_clock");
|
||||
static_assert(is_clock_castable<amb1_clock, sys_clock>::value, "amb1_clock -> sys_clock");
|
||||
static_assert(is_clock_castable<sys_clock, amb1_clock>::value, "sys_clock -> amb1_clock");
|
||||
static_assert(is_clock_castable<amb1_clock, utc_clock>::value, "amb1_clock -> utc_clock");
|
||||
static_assert(is_clock_castable<utc_clock, amb1_clock>::value, "utc_clock -> amb1_clock");
|
||||
static_assert(is_clock_castable<amb1_clock, tai_clock>::value, "amb1_clock -> tai_clock");
|
||||
static_assert(is_clock_castable<tai_clock, amb1_clock>::value, "tai_clock -> amb1_clock");
|
||||
static_assert(is_clock_castable<amb1_clock, tai_clock>::value, "amb1_clock -> tai_clock");
|
||||
static_assert(is_clock_castable<gps_clock, amb1_clock>::value, "gps_clock -> amb1_clock");
|
||||
static_assert(is_clock_castable<amb2_clock, amb2_clock>::value, "amb2_clock -> amb2_clock");
|
||||
static_assert(is_clock_castable<amb2_clock, sys_clock>::value, "amb2_clock -> sys_clock");
|
||||
static_assert(is_clock_castable<sys_clock, amb2_clock>::value, "sys_clock -> amb2_clock");
|
||||
static_assert(is_clock_castable<amb2_clock, utc_clock>::value, "amb2_clock -> utc_clock");
|
||||
static_assert(is_clock_castable<utc_clock, amb2_clock>::value, "utc_clock -> amb2_clock");
|
||||
static_assert(is_clock_castable<amb2_clock, tai_clock>::value, "amb2_clock -> tai_clock");
|
||||
static_assert(is_clock_castable<tai_clock, amb2_clock>::value, "tai_clock -> amb2_clock");
|
||||
static_assert(is_clock_castable<amb2_clock, tai_clock>::value, "amb2_clock -> tai_clock");
|
||||
static_assert(is_clock_castable<gps_clock, amb2_clock>::value, "gps_clock -> amb2_clock");
|
||||
|
||||
//amb1 -> amb2: ambigous because can either go trough sys_clock or utc_clock
|
||||
static_assert(!is_clock_castable<amb1_clock, amb2_clock>::value, "amb1_clock -> amb2_clock");
|
||||
|
||||
//amb2 -> amb1: disambiguated via trait specialization
|
||||
static_assert(is_clock_castable<amb2_clock, amb1_clock>::value, "amb2_clock -> amb1_clock");
|
||||
}
|
102
test/clock_cast_test/normal_clocks.pass.cpp
Normal file
102
test/clock_cast_test/normal_clocks.pass.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Tomasz Kamiński
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "tz.h"
|
||||
#include <cassert>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using sys_clock = std::chrono::system_clock;
|
||||
|
||||
// self
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto tt = tai_clock::from_utc(ut);
|
||||
|
||||
assert(clock_cast<sys_clock>(st) == st);
|
||||
assert(clock_cast<utc_clock>(ut) == ut);
|
||||
assert(clock_cast<tai_clock>(tt) == tt);
|
||||
}
|
||||
|
||||
// sys <-> utc
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
|
||||
assert(clock_cast<utc_clock>(st) == ut);
|
||||
assert(clock_cast<sys_clock>(ut) == st);
|
||||
}
|
||||
|
||||
// tai <-> utc
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto tt = tai_clock::from_utc(ut);
|
||||
|
||||
assert(clock_cast<tai_clock>(ut) == tt);
|
||||
assert(clock_cast<utc_clock>(tt) == ut);
|
||||
}
|
||||
|
||||
// tai <-> sys
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto tt = tai_clock::from_utc(ut);
|
||||
|
||||
assert(clock_cast<tai_clock>(st) == tt);
|
||||
assert(clock_cast<sys_clock>(tt) == st);
|
||||
}
|
||||
|
||||
// gps <-> utc
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto gt = gps_clock::from_utc(ut);
|
||||
|
||||
assert(clock_cast<gps_clock>(ut) == gt);
|
||||
assert(clock_cast<utc_clock>(gt) == ut);
|
||||
}
|
||||
|
||||
// gps <-> sys
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto gt = gps_clock::from_utc(ut);
|
||||
|
||||
assert(clock_cast<gps_clock>(st) == gt);
|
||||
assert(clock_cast<sys_clock>(gt) == st);
|
||||
}
|
||||
|
||||
// tai <-> gps
|
||||
{
|
||||
sys_days st(1997_y/dec/12);
|
||||
auto ut = utc_clock::from_sys(st);
|
||||
auto tt = tai_clock::from_utc(ut);
|
||||
auto gt = gps_clock::from_utc(ut);
|
||||
|
||||
assert(clock_cast<gps_clock>(tt) == gt);
|
||||
assert(clock_cast<tai_clock>(gt) == tt);
|
||||
}
|
||||
}
|
49
test/clock_cast_test/to_sys_return_int.fail.cpp
Normal file
49
test/clock_cast_test/to_sys_return_int.fail.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Tomasz Kamiński
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "tz.h"
|
||||
|
||||
struct bad_clock
|
||||
{
|
||||
using duration = std::chrono::system_clock::duration;
|
||||
using rep = duration::rep;
|
||||
using period = duration::period;
|
||||
using time_point = std::chrono::time_point<bad_clock, duration>;
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
int
|
||||
to_sys(std::chrono::time_point<bad_clock, Duration> const& tp)
|
||||
{
|
||||
return tp.time_since_epoch().count();
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using sys_clock = std::chrono::system_clock;
|
||||
|
||||
auto bt = bad_clock::time_point();
|
||||
clock_cast<sys_clock>(bt);
|
||||
}
|
51
test/clock_cast_test/to_sys_return_reference.fail.cpp
Normal file
51
test/clock_cast_test/to_sys_return_reference.fail.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Tomasz Kamiński
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "tz.h"
|
||||
|
||||
struct bad_clock
|
||||
{
|
||||
using duration = std::chrono::system_clock::duration;
|
||||
using rep = duration::rep;
|
||||
using period = duration::period;
|
||||
using time_point = std::chrono::time_point<bad_clock, duration>;
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
date::sys_time<Duration> const&
|
||||
to_sys(std::chrono::time_point<bad_clock, Duration> const& tp)
|
||||
{
|
||||
static date::sys_time<Duration> val;
|
||||
val = date::sys_time<Duration>(tp.time_since_epoch());
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using sys_clock = std::chrono::system_clock;
|
||||
|
||||
auto bt = bad_clock::time_point();
|
||||
clock_cast<sys_clock>(bt);
|
||||
}
|
49
test/clock_cast_test/to_sys_return_utc_time.fail.cpp
Normal file
49
test/clock_cast_test/to_sys_return_utc_time.fail.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017, 2018 Tomasz Kamiński
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "tz.h"
|
||||
|
||||
struct bad_clock
|
||||
{
|
||||
using duration = std::chrono::system_clock::duration;
|
||||
using rep = duration::rep;
|
||||
using period = duration::period;
|
||||
using time_point = std::chrono::time_point<bad_clock, duration>;
|
||||
|
||||
template<typename Duration>
|
||||
static
|
||||
date::utc_time<Duration>
|
||||
to_sys(std::chrono::time_point<bad_clock, Duration> const& tp)
|
||||
{
|
||||
return date::utc_time<Duration>(tp.time_since_epoch());
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using sys_clock = std::chrono::system_clock;
|
||||
|
||||
auto bt = bad_clock::time_point();
|
||||
clock_cast<sys_clock>(bt);
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -25,31 +25,31 @@
|
||||
// unsigned char d_;
|
||||
// public:
|
||||
// explicit constexpr day(unsigned d) noexcept;
|
||||
//
|
||||
//
|
||||
// day& operator++() noexcept;
|
||||
// day operator++(int) noexcept;
|
||||
// day& operator--() noexcept;
|
||||
// day operator--(int) noexcept;
|
||||
//
|
||||
//
|
||||
// day& operator+=(const days& d) noexcept;
|
||||
// day& operator-=(const days& d) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr explicit operator unsigned() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// constexpr bool operator==(const day& x, const day& y) noexcept;
|
||||
// constexpr bool operator!=(const day& x, const day& y) noexcept;
|
||||
// constexpr bool operator< (const day& x, const day& y) noexcept;
|
||||
// constexpr bool operator> (const day& x, const day& y) noexcept;
|
||||
// constexpr bool operator<=(const day& x, const day& y) noexcept;
|
||||
// constexpr bool operator>=(const day& x, const day& y) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr day operator+(const day& x, const days& y) noexcept;
|
||||
// constexpr day operator+(const days& x, const day& y) noexcept;
|
||||
// constexpr day operator-(const day& x, const days& y) noexcept;
|
||||
// constexpr days operator-(const day& x, const day& y) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr day operator "" _d(unsigned long long d) noexcept;
|
||||
// std::ostream& operator<<(std::ostream& os, const day& d);
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
#include <type_traits>
|
||||
|
||||
static_assert( std::is_trivially_destructible<date::day>{}, "");
|
||||
static_assert(!std::is_default_constructible<date::day>{}, "");
|
||||
static_assert( std::is_default_constructible<date::day>{}, "");
|
||||
static_assert( std::is_trivially_copy_constructible<date::day>{}, "");
|
||||
static_assert( std::is_trivially_copy_assignable<date::day>{}, "");
|
||||
static_assert( std::is_trivially_move_constructible<date::day>{}, "");
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
141
test/date_test/detail/decimal_format_seconds.pass.cpp
Normal file
141
test/date_test/detail/decimal_format_seconds.pass.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// template <class Duration>
|
||||
// class decimal_format_seconds
|
||||
// {
|
||||
// using CT = typename std::common_type<Duration, std::chrono::seconds>::type;
|
||||
// using rep = typename CT::rep;
|
||||
// public:
|
||||
// static unsigned constexpr width = detail::width<CT::period::den>::value < 19 ?
|
||||
// detail::width<CT::period::den>::value : 6u;
|
||||
// using precision = std::chrono::duration<rep,
|
||||
// std::ratio<1, static_pow10<width>::value>>;
|
||||
// private:
|
||||
// std::chrono::seconds s_;
|
||||
// precision sub_s_;
|
||||
//
|
||||
// public:
|
||||
// constexpr explicit decimal_format_seconds(const Duration& d) noexcept;
|
||||
//
|
||||
// constexpr std::chrono::seconds& seconds() noexcept;
|
||||
// constexpr std::chrono::seconds seconds() const noexcept;
|
||||
// constexpr precision subseconds() const noexcept;
|
||||
// constexpr precision to_duration() const noexcept;
|
||||
//
|
||||
// template <class CharT, class Traits>
|
||||
// friend
|
||||
// std::basic_ostream<CharT, Traits>&
|
||||
// operator<<(std::basic_ostream<CharT, Traits>& os, const decimal_format_seconds& x);
|
||||
// };
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
using fortnights = std::chrono::duration<date::weeks::rep,
|
||||
date::detail::ratio_multiply<std::ratio<2>,
|
||||
date::weeks::period>>;
|
||||
|
||||
using microfortnights = std::chrono::duration<std::int64_t,
|
||||
date::detail::ratio_multiply<fortnights::period,
|
||||
std::micro>>;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date::detail;
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
|
||||
{
|
||||
using D = decimal_format_seconds<minutes>;
|
||||
static_assert(is_same<D::precision, seconds>{}, "");
|
||||
static_assert(D::width == 0, "");
|
||||
D dfs{minutes{3}};
|
||||
assert(dfs.seconds() == seconds{180});
|
||||
assert(dfs.to_duration() == seconds{180});
|
||||
ostringstream out;
|
||||
out << dfs;
|
||||
assert(out.str() == "180");
|
||||
}
|
||||
{
|
||||
using D = decimal_format_seconds<seconds>;
|
||||
static_assert(is_same<D::precision, seconds>{}, "");
|
||||
static_assert(D::width == 0, "");
|
||||
D dfs{seconds{3}};
|
||||
assert(dfs.seconds() == seconds{3});
|
||||
assert(dfs.to_duration() == seconds{3});
|
||||
ostringstream out;
|
||||
out << dfs;
|
||||
assert(out.str() == "03");
|
||||
}
|
||||
{
|
||||
using D = decimal_format_seconds<milliseconds>;
|
||||
static_assert(D::width == 3, "");
|
||||
D dfs{seconds{3}};
|
||||
assert(dfs.seconds() == seconds{3});
|
||||
assert(dfs.to_duration() == seconds{3});
|
||||
assert(dfs.subseconds() == milliseconds{0});
|
||||
ostringstream out;
|
||||
out << dfs;
|
||||
assert(out.str() == "03.000");
|
||||
}
|
||||
{
|
||||
using D = decimal_format_seconds<milliseconds>;
|
||||
static_assert(D::width == 3, "");
|
||||
D dfs{milliseconds{3}};
|
||||
assert(dfs.seconds() == seconds{0});
|
||||
assert(dfs.to_duration() == milliseconds{3});
|
||||
assert(dfs.subseconds() == milliseconds{3});
|
||||
ostringstream out;
|
||||
out << dfs;
|
||||
assert(out.str() == "00.003");
|
||||
}
|
||||
{
|
||||
using D = decimal_format_seconds<microfortnights>;
|
||||
static_assert(D::width == 4, "");
|
||||
D dfs{microfortnights{3}};
|
||||
using S = D::precision;
|
||||
assert(dfs.seconds() == seconds{3});
|
||||
assert(dfs.to_duration() == S{36288});
|
||||
assert(dfs.subseconds() == S{6288});
|
||||
ostringstream out;
|
||||
out << dfs;
|
||||
assert(out.str() == "03.6288");
|
||||
}
|
||||
{
|
||||
using CT = common_type<seconds, microfortnights>::type;
|
||||
using D = decimal_format_seconds<CT>;
|
||||
static_assert(D::width == 4, "");
|
||||
D dfs{microfortnights{3}};
|
||||
using S = D::precision;
|
||||
assert(dfs.seconds() == seconds{3});
|
||||
assert(dfs.to_duration() == S{36288});
|
||||
assert(dfs.subseconds() == S{6288});
|
||||
ostringstream out;
|
||||
out << dfs;
|
||||
assert(out.str() == "03.6288");
|
||||
}
|
||||
}
|
50
test/date_test/detail/static_pow10.pass.cpp
Normal file
50
test/date_test/detail/static_pow10.pass.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// template <unsigned exp>
|
||||
// struct static_pow10
|
||||
// {
|
||||
// static constepxr std::uint64_t value = ...;
|
||||
// };
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date::detail;
|
||||
static_assert(static_pow10<0>::value == 1, "");
|
||||
static_assert(static_pow10<1>::value == 10, "");
|
||||
static_assert(static_pow10<2>::value == 100, "");
|
||||
static_assert(static_pow10<3>::value == 1000, "");
|
||||
static_assert(static_pow10<4>::value == 10000, "");
|
||||
static_assert(static_pow10<5>::value == 100000, "");
|
||||
static_assert(static_pow10<6>::value == 1000000, "");
|
||||
static_assert(static_pow10<7>::value == 10000000, "");
|
||||
static_assert(static_pow10<8>::value == 100000000, "");
|
||||
static_assert(static_pow10<9>::value == 1000000000, "");
|
||||
static_assert(static_pow10<10>::value == 10000000000, "");
|
||||
}
|
64
test/date_test/detail/width.pass.cpp
Normal file
64
test/date_test/detail/width.pass.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2017 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// width<n>::value is the number of fractional decimal digits in 1/n
|
||||
// width<0>::value and width<1>::value are defined to be 0
|
||||
// If 1/n takes more than 18 fractional decimal digits,
|
||||
// the result is truncated to 19.
|
||||
// Example: width<2>::value == 1
|
||||
// Example: width<3>::value == 19
|
||||
// Example: width<4>::value == 2
|
||||
// Example: width<10>::value == 1
|
||||
// Example: width<1000>::value == 3
|
||||
// template <std::uint64_t n>
|
||||
//
|
||||
// struct width
|
||||
// {
|
||||
// static constexpr unsigned value = ...;
|
||||
// };
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date::detail;
|
||||
static_assert(width<0, 1>::value == 0, "");
|
||||
static_assert(width<1, 1>::value == 0, "");
|
||||
static_assert(width<1, 2>::value == 1, "");
|
||||
static_assert(width<1, 3>::value == 19, "");
|
||||
static_assert(width<1, 4>::value == 2, "");
|
||||
static_assert(width<1, 5>::value == 1, "");
|
||||
static_assert(width<1, 6>::value == 19, "");
|
||||
static_assert(width<1, 7>::value == 19, "");
|
||||
static_assert(width<1, 8>::value == 3, "");
|
||||
static_assert(width<1, 9>::value == 19, "");
|
||||
static_assert(width<1, 10>::value == 1, "");
|
||||
static_assert(width<1, 100>::value == 2, "");
|
||||
static_assert(width<1, 1000>::value == 3, "");
|
||||
static_assert(width<1, 10000>::value == 4, "");
|
||||
static_assert(width<756, 625>::value == 4, "");
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,22 +21,22 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// durations
|
||||
//
|
||||
//
|
||||
// using days = std::chrono::duration
|
||||
// <int, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>;
|
||||
//
|
||||
//
|
||||
// using weeks = std::chrono::duration
|
||||
// <int, std::ratio_multiply<std::ratio<7>, days::period>>;
|
||||
//
|
||||
//
|
||||
// using years = std::chrono::duration
|
||||
// <int, std::ratio_multiply<std::ratio<146097, 400>, days::period>>;
|
||||
//
|
||||
//
|
||||
// using months = std::chrono::duration
|
||||
// <int, std::ratio_divide<years::period, std::ratio<12>>>;
|
||||
//
|
||||
//
|
||||
// time_point
|
||||
//
|
||||
// using day_point = std::chrono::time_point<std::chrono::system_clock, days>;
|
||||
//
|
||||
// using sys_days = std::chrono::time_point<std::chrono::system_clock, days>;
|
||||
|
||||
#include "date.h"
|
||||
|
||||
@ -54,7 +54,7 @@ static_assert(date::years{400} == date::days{146097}, "");
|
||||
static_assert(date::days{365} < date::years{1} && date::years{1} < date::days{366}, "");
|
||||
static_assert(date::weeks{52} < date::years{1} && date::years{1} < date::weeks{53}, "");
|
||||
|
||||
static_assert(std::is_same<date::day_point::duration, date::days>{}, "");
|
||||
static_assert(std::is_same<date::sys_days::duration, date::days>{}, "");
|
||||
|
||||
int
|
||||
main()
|
||||
|
328
test/date_test/durations_output.pass.cpp
Normal file
328
test/date_test/durations_output.pass.cpp
Normal file
@ -0,0 +1,328 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Tomasz Kamiński
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
void test_SI()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using namespace date;
|
||||
|
||||
std::ostringstream os;
|
||||
|
||||
// atto
|
||||
{
|
||||
duration<int, std::atto> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13as");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// femto
|
||||
{
|
||||
duration<int, std::femto> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13fs");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// pico
|
||||
{
|
||||
duration<int, std::pico> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13ps");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// nano
|
||||
{
|
||||
duration<int, std::nano> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13ns");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// mikro
|
||||
{
|
||||
duration<int, std::micro> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13\xC2\xB5s");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// milli
|
||||
{
|
||||
duration<int, std::milli> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13ms");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// centi
|
||||
{
|
||||
duration<int, std::centi> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13cs");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// deci
|
||||
{
|
||||
duration<int, std::deci> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13ds");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// seconds
|
||||
{
|
||||
duration<int> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13s");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// deca
|
||||
{
|
||||
duration<int, std::deca> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13das");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// hecto
|
||||
{
|
||||
duration<int, std::hecto> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13hs");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// kilo
|
||||
{
|
||||
duration<int, std::kilo> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13ks");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// mega
|
||||
{
|
||||
duration<int, std::mega> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13Ms");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// giga
|
||||
{
|
||||
duration<int, std::giga> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13Gs");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// tera
|
||||
{
|
||||
duration<int, std::tera> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13Ts");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// peta
|
||||
{
|
||||
duration<int, std::peta> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13Ps");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// femto
|
||||
{
|
||||
duration<int, std::exa> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13Es");
|
||||
os.str("");
|
||||
}
|
||||
}
|
||||
|
||||
void test_calendar()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using namespace date;
|
||||
|
||||
std::ostringstream os;
|
||||
|
||||
// minutes
|
||||
{
|
||||
minutes d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13min");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// hours
|
||||
{
|
||||
hours d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13h");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// days
|
||||
{
|
||||
days d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13d");
|
||||
os.str("");
|
||||
}
|
||||
}
|
||||
|
||||
void test_integral_scale()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using namespace date;
|
||||
|
||||
std::ostringstream os;
|
||||
|
||||
// ratio 123 / 1
|
||||
{
|
||||
duration<int, std::ratio<123, 1>> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13[123]s");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// ratio 100 / 4 = ratio 25 / 1
|
||||
{
|
||||
duration<int, std::ratio<25, 1>> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13[25]s");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// weeks = ratio 7 * 24 * 60 * 60 / 1 = ratio 604800 / 1
|
||||
{
|
||||
weeks d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13[604800]s");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// years = 146097/400 days = ratio 146097/400 * 24 * 60 * 60 = ratio 31556952 / 1
|
||||
{
|
||||
years d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13[31556952]s");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// months = 1/12 years = ratio 1/12 * 31556952 = ratio 2629746 / 1
|
||||
{
|
||||
months d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13[2629746]s");
|
||||
os.str("");
|
||||
}
|
||||
}
|
||||
|
||||
void test_ratio_scale()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using namespace date;
|
||||
|
||||
std::ostringstream os;
|
||||
|
||||
// ratio 1 / 2
|
||||
{
|
||||
duration<int, std::ratio<1, 2>> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13[1/2]s");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// ratio 100 / 3
|
||||
{
|
||||
duration<int, std::ratio<100, 3>> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13[100/3]s");
|
||||
os.str("");
|
||||
}
|
||||
|
||||
// ratio 100 / 6 = ratio 50 / 3
|
||||
{
|
||||
duration<int, std::ratio<100, 6>> d(13);
|
||||
os << d;
|
||||
assert(os.str() == "13[50/3]s");
|
||||
os.str("");
|
||||
}
|
||||
}
|
||||
|
||||
void test_constexpr()
|
||||
{
|
||||
using date::detail::get_units;
|
||||
|
||||
CONSTCD11 auto as = get_units<char>(std::atto{});
|
||||
CONSTCD11 auto fs = get_units<char>(std::femto{});
|
||||
CONSTCD11 auto ps = get_units<char>(std::pico{});
|
||||
CONSTCD11 auto ns = get_units<char>(std::nano{});
|
||||
CONSTCD11 auto us = get_units<char>(std::micro{});
|
||||
CONSTCD11 auto usw = get_units<wchar_t>(std::micro{});
|
||||
CONSTCD11 auto ms = get_units<char>(std::milli{});
|
||||
CONSTCD11 auto cs = get_units<char>(std::centi{});
|
||||
CONSTCD11 auto ds = get_units<char>(std::deci{});
|
||||
CONSTCD11 auto s = get_units<char>(std::ratio<1>{});
|
||||
CONSTCD11 auto das = get_units<char>(std::deca{});
|
||||
CONSTCD11 auto hs = get_units<char>(std::hecto{});
|
||||
CONSTCD11 auto ks = get_units<char>(std::kilo{});
|
||||
CONSTCD11 auto Ms = get_units<char>(std::mega{});
|
||||
CONSTCD11 auto Gs = get_units<char>(std::giga{});
|
||||
CONSTCD11 auto Ts = get_units<char>(std::tera{});
|
||||
CONSTCD11 auto Ps = get_units<char>(std::peta{});
|
||||
CONSTCD11 auto Es = get_units<char>(std::exa{});
|
||||
(void)as, (void)fs, (void)ps, (void)ns, (void)usw, (void)us,
|
||||
(void)ms, (void)cs, (void)ds, (void)s, (void)das, (void)hs,
|
||||
(void)ks, (void)Ms, (void)Gs, (void)Ts, (void)Ps, (void)Es;
|
||||
|
||||
CONSTCD11 auto min = get_units<char>(std::ratio<60>{});
|
||||
CONSTCD11 auto h = get_units<char>(std::ratio<3600>{});
|
||||
CONSTCD11 auto d = get_units<char>(std::ratio<86400>{});
|
||||
(void)min, (void)h, (void)d;
|
||||
|
||||
CONSTCD14 auto integer = get_units<char>(std::ratio<123>{});
|
||||
CONSTCD14 auto ratio = get_units<char>(std::ratio<123, 3>{});
|
||||
(void)integer, (void)ratio;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test_SI();
|
||||
test_calendar();
|
||||
test_integral_scale();
|
||||
test_ratio_scale();
|
||||
}
|
117
test/date_test/format/century.pass.cpp
Normal file
117
test/date_test/format/century.pass.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
std::ostringstream os;
|
||||
os << format("%C", sys_days{jun/1/20001});
|
||||
assert(os.str() == "200");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/20000});
|
||||
assert(os.str() == "200");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/19999});
|
||||
assert(os.str() == "199");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/2001});
|
||||
assert(os.str() == "20");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/2000});
|
||||
assert(os.str() == "20");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/1999});
|
||||
assert(os.str() == "19");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/101});
|
||||
assert(os.str() == "01");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/100});
|
||||
assert(os.str() == "01");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/99});
|
||||
assert(os.str() == "00");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/1});
|
||||
assert(os.str() == "00");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/0});
|
||||
assert(os.str() == "00");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/-1});
|
||||
assert(os.str() == "-01");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/-99});
|
||||
assert(os.str() == "-01");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/-100});
|
||||
assert(os.str() == "-01");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/-101});
|
||||
assert(os.str() == "-02");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/-1999});
|
||||
assert(os.str() == "-20");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/-2000});
|
||||
assert(os.str() == "-20");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/-2001});
|
||||
assert(os.str() == "-21");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/-19999});
|
||||
assert(os.str() == "-200");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/-20000});
|
||||
assert(os.str() == "-200");
|
||||
|
||||
os.str("");
|
||||
os << format("%C", sys_days{jun/1/-20001});
|
||||
assert(os.str() == "-201");
|
||||
}
|
52
test/date_test/format/misc.pass.cpp
Normal file
52
test/date_test/format/misc.pass.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "date.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test(const std::string& in_fmt, const std::string& input,
|
||||
const std::string& out_fmt, const std::string& output)
|
||||
{
|
||||
using namespace date;
|
||||
std::istringstream in{input};
|
||||
T t;
|
||||
in >> parse(in_fmt, t);
|
||||
assert(!in.fail());
|
||||
auto s = format(out_fmt, t);
|
||||
assert(s == output);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
test<year>("%Y", "2017", "%Y", "2017");
|
||||
test<month>("%m", "3", "%m", "03");
|
||||
test<day>("%d", "25", "%d", "25");
|
||||
test<year_month>("%Y-%m", "2017-03", "%Y-%m", "2017-03");
|
||||
test<year_month>("%y%m", "1703", "%Y-%m", "2017-03");
|
||||
test<month_day>("%m/%d", "3/25", "%m/%d", "03/25");
|
||||
test<weekday>("%w", "3", "%w", "3");
|
||||
}
|
78
test/date_test/format/range.pass.cpp
Normal file
78
test/date_test/format/range.pass.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
using fortnights = std::chrono::duration<date::weeks::rep,
|
||||
date::detail::ratio_multiply<std::ratio<2>,
|
||||
date::weeks::period>>;
|
||||
|
||||
using microfortnights = std::chrono::duration<std::int64_t,
|
||||
date::detail::ratio_multiply<fortnights::period,
|
||||
std::micro>>;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
std::ostringstream os;
|
||||
os << format("%F %T", sys_days{jan/1/year::min()});
|
||||
assert(os.str() == "-32767-01-01 00:00:00");
|
||||
os.str("");
|
||||
os << format("%F %T", sys_days{dec/last/year::max()});
|
||||
assert(os.str() == "32767-12-31 00:00:00");
|
||||
os.str("");
|
||||
os << format("%F %T", sys_days{dec/last/year::max()} + hours{23} + minutes{59} +
|
||||
seconds{59} + microseconds{999999});
|
||||
assert(os.str() == "32767-12-31 23:59:59.999999");
|
||||
os.str("");
|
||||
|
||||
os << format("%Y-%m-%d %H:%M:%S", sys_days{jan/1/year::min()});
|
||||
assert(os.str() == "-32767-01-01 00:00:00");
|
||||
os.str("");
|
||||
os << format("%Y-%m-%d %H:%M:%S", sys_days{dec/last/year::max()});
|
||||
assert(os.str() == "32767-12-31 00:00:00");
|
||||
os.str("");
|
||||
os << format("%Y-%m-%d %H:%M:%S", sys_days{dec/last/year::max()} + hours{23} +
|
||||
minutes{59} + seconds{59} + microseconds{999999});
|
||||
assert(os.str() == "32767-12-31 23:59:59.999999");
|
||||
os.str("");
|
||||
|
||||
os << format("%F %T", sys_days{jan/1/year::min()} + microfortnights{1});
|
||||
assert(os.str() == "-32767-01-01 00:00:01.2096");
|
||||
os.str("");
|
||||
os << format("%F %T", sys_days{dec/last/year::max()} + microfortnights{1});
|
||||
assert(os.str() == "32767-12-31 00:00:01.2096");
|
||||
os.str("");
|
||||
|
||||
os << format("%F", jan/1/year::min());
|
||||
assert(os.str() == "-32767-01-01");
|
||||
os.str("");
|
||||
os << format("%F", dec/last/year::max());
|
||||
assert(os.str() == "32767-12-31");
|
||||
os.str("");
|
||||
}
|
121
test/date_test/format/two_dight_year.pass.cpp
Normal file
121
test/date_test/format/two_dight_year.pass.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
std::ostringstream os;
|
||||
os << format("%y", sys_days{jun/1/20001});
|
||||
assert(os.str() == "01");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/20000});
|
||||
assert(os.str() == "00");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/19999});
|
||||
assert(os.str() == "99");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/2001});
|
||||
assert(os.str() == "01");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/2000});
|
||||
assert(os.str() == "00");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/1999});
|
||||
assert(os.str() == "99");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/101});
|
||||
assert(os.str() == "01");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/100});
|
||||
assert(os.str() == "00");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/99});
|
||||
assert(os.str() == "99");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/1});
|
||||
assert(os.str() == "01");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/0});
|
||||
assert(os.str() == "00");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/-1});
|
||||
assert(os.str() == "01");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/-99});
|
||||
assert(os.str() == "99");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/-100});
|
||||
assert(os.str() == "00");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/-101});
|
||||
assert(os.str() == "01");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/-1999});
|
||||
assert(os.str() == "99");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/-2000});
|
||||
assert(os.str() == "00");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/-2001});
|
||||
assert(os.str() == "01");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/-19999});
|
||||
assert(os.str() == "99");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/-20000});
|
||||
assert(os.str() == "00");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/-20001});
|
||||
assert(os.str() == "01");
|
||||
|
||||
os.str("");
|
||||
os << format("%y", sys_days{jun/1/year::min()});
|
||||
assert(os.str() == "67");
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -27,27 +27,6 @@
|
||||
// time_of_day<std::chrono::duration<Rep, Period>>
|
||||
// make_time(std::chrono::duration<Rep, Period> d) noexcept;
|
||||
|
||||
// constexpr
|
||||
// time_of_day<std::chrono::hours>
|
||||
// make_time(std::chrono::hours h, unsigned md) noexcept;
|
||||
|
||||
// constexpr
|
||||
// time_of_day<std::chrono::minutes>
|
||||
// make_time(std::chrono::hours h, std::chrono::minutes m, unsigned md) noexcept;
|
||||
|
||||
// constexpr
|
||||
// time_of_day<std::chrono::seconds>
|
||||
// make_time(std::chrono::hours h, std::chrono::minutes m, std::chrono::seconds s,
|
||||
// unsigned md) noexcept;
|
||||
|
||||
// template <class Rep, class Period,
|
||||
// class = typename std::enable_if<std::ratio_less<Period,
|
||||
// std::ratio<1>>::value>::type>
|
||||
// constexpr
|
||||
// time_of_day<std::chrono::duration<Rep, Period>>
|
||||
// make_time(std::chrono::hours h, std::chrono::minutes m, std::chrono::seconds s,
|
||||
// std::chrono::duration<Rep, Period> sub_s, unsigned md) noexcept;
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <cassert>
|
||||
@ -68,7 +47,6 @@ main()
|
||||
assert(tod.minutes() == minutes{7});
|
||||
assert(tod.seconds() == seconds{9});
|
||||
assert(tod.subseconds() == nanoseconds{22});
|
||||
assert(tod.mode() == 0);
|
||||
}
|
||||
{
|
||||
static_assert(is_same<decltype(make_time(microseconds{18429000022})),
|
||||
@ -78,7 +56,6 @@ main()
|
||||
assert(tod.minutes() == minutes{7});
|
||||
assert(tod.seconds() == seconds{9});
|
||||
assert(tod.subseconds() == microseconds{22});
|
||||
assert(tod.mode() == 0);
|
||||
}
|
||||
{
|
||||
static_assert(is_same<decltype(make_time(seconds{18429})),
|
||||
@ -87,7 +64,6 @@ main()
|
||||
assert(tod.hours() == hours{5});
|
||||
assert(tod.minutes() == minutes{7});
|
||||
assert(tod.seconds() == seconds{9});
|
||||
assert(tod.mode() == 0);
|
||||
}
|
||||
{
|
||||
static_assert(is_same<decltype(make_time(minutes{307})),
|
||||
@ -95,70 +71,11 @@ main()
|
||||
auto tod = make_time(minutes{307});
|
||||
assert(tod.hours() == hours{5});
|
||||
assert(tod.minutes() == minutes{7});
|
||||
assert(tod.mode() == 0);
|
||||
}
|
||||
{
|
||||
static_assert(is_same<decltype(make_time(hours{5})),
|
||||
time_of_day<hours>>{}, "");
|
||||
auto tod = make_time(hours{5});
|
||||
assert(tod.hours() == hours{5});
|
||||
assert(tod.mode() == 0);
|
||||
}
|
||||
{
|
||||
static_assert(is_same<decltype(make_time(hours{5}, minutes{7}, seconds{9},
|
||||
nanoseconds{22}, pm)),
|
||||
time_of_day<nanoseconds>>{}, "");
|
||||
auto tod = make_time(hours{5}, minutes{7}, seconds{9}, nanoseconds{22}, pm);
|
||||
assert(tod.hours() == hours{5});
|
||||
assert(tod.minutes() == minutes{7});
|
||||
assert(tod.seconds() == seconds{9});
|
||||
assert(tod.subseconds() == nanoseconds{22});
|
||||
assert(tod.mode() == pm);
|
||||
}
|
||||
{
|
||||
static_assert(is_same<decltype(make_time(hours{5}, minutes{7}, seconds{9},
|
||||
microseconds{22}, 0)),
|
||||
time_of_day<microseconds>>{}, "");
|
||||
auto tod = make_time(hours{5}, minutes{7}, seconds{9}, microseconds{22}, 0);
|
||||
assert(tod.hours() == hours{5});
|
||||
assert(tod.minutes() == minutes{7});
|
||||
assert(tod.seconds() == seconds{9});
|
||||
assert(tod.subseconds() == microseconds{22});
|
||||
assert(tod.mode() == 0);
|
||||
}
|
||||
{
|
||||
static_assert(is_same<decltype(make_time(hours{5}, minutes{7}, seconds{9},
|
||||
milliseconds{22}, am)),
|
||||
time_of_day<milliseconds>>{}, "");
|
||||
auto tod = make_time(hours{5}, minutes{7}, seconds{9}, milliseconds{22}, am);
|
||||
assert(tod.hours() == hours{5});
|
||||
assert(tod.minutes() == minutes{7});
|
||||
assert(tod.seconds() == seconds{9});
|
||||
assert(tod.subseconds() == milliseconds{22});
|
||||
assert(tod.mode() == am);
|
||||
}
|
||||
{
|
||||
static_assert(is_same<decltype(make_time(hours{5}, minutes{7}, seconds{9}, am)),
|
||||
time_of_day<seconds>>{}, "");
|
||||
auto tod = make_time(hours{5}, minutes{7}, seconds{9}, am);
|
||||
assert(tod.hours() == hours{5});
|
||||
assert(tod.minutes() == minutes{7});
|
||||
assert(tod.seconds() == seconds{9});
|
||||
assert(tod.mode() == am);
|
||||
}
|
||||
{
|
||||
static_assert(is_same<decltype(make_time(hours{5}, minutes{7}, pm)),
|
||||
time_of_day<minutes>>{}, "");
|
||||
auto tod = make_time(hours{5}, minutes{7}, pm);
|
||||
assert(tod.hours() == hours{5});
|
||||
assert(tod.minutes() == minutes{7});
|
||||
assert(tod.mode() == pm);
|
||||
}
|
||||
{
|
||||
static_assert(is_same<decltype(make_time(hours{5}, 0)),
|
||||
time_of_day<hours>>{}, "");
|
||||
auto tod = make_time(hours{5}, 0);
|
||||
assert(tod.hours() == hours{5});
|
||||
assert(tod.mode() == 0);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -25,31 +25,31 @@
|
||||
// unsigned char m_;
|
||||
// public:
|
||||
// explicit constexpr month(unsigned m) noexcept;
|
||||
//
|
||||
//
|
||||
// month& operator++() noexcept;
|
||||
// month operator++(int) noexcept;
|
||||
// month& operator--() noexcept;
|
||||
// month operator--(int) noexcept;
|
||||
//
|
||||
//
|
||||
// month& operator+=(const months& m) noexcept;
|
||||
// month& operator-=(const months& m) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr explicit operator unsigned() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// constexpr bool operator==(const month& x, const month& y) noexcept;
|
||||
// constexpr bool operator!=(const month& x, const month& y) noexcept;
|
||||
// constexpr bool operator< (const month& x, const month& y) noexcept;
|
||||
// constexpr bool operator> (const month& x, const month& y) noexcept;
|
||||
// constexpr bool operator<=(const month& x, const month& y) noexcept;
|
||||
// constexpr bool operator>=(const month& x, const month& y) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr month operator+(const month& x, const months& y) noexcept;
|
||||
// constexpr month operator+(const months& x, const month& y) noexcept;
|
||||
// constexpr month operator-(const month& x, const months& y) noexcept;
|
||||
// constexpr months operator-(const month& x, const month& y) noexcept;
|
||||
//
|
||||
//
|
||||
// std::ostream& operator<<(std::ostream& os, const month& m);
|
||||
|
||||
// constexpr month jan{1};
|
||||
@ -72,7 +72,7 @@
|
||||
#include <type_traits>
|
||||
|
||||
static_assert( std::is_trivially_destructible<date::month>{}, "");
|
||||
static_assert(!std::is_default_constructible<date::month>{}, "");
|
||||
static_assert( std::is_default_constructible<date::month>{}, "");
|
||||
static_assert( std::is_trivially_copy_constructible<date::month>{}, "");
|
||||
static_assert( std::is_trivially_copy_assignable<date::month>{}, "");
|
||||
static_assert( std::is_trivially_move_constructible<date::month>{}, "");
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -24,10 +24,10 @@
|
||||
// {
|
||||
// public:
|
||||
// constexpr month_day(const date::month& m, const date::day& d) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr date::month month() const noexcept;
|
||||
// constexpr date::day day() const noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
#include <type_traits>
|
||||
|
||||
static_assert( std::is_trivially_destructible<date::month_day>{}, "");
|
||||
static_assert(!std::is_default_constructible<date::month_day>{}, "");
|
||||
static_assert( std::is_default_constructible<date::month_day>{}, "");
|
||||
static_assert( std::is_trivially_copy_constructible<date::month_day>{}, "");
|
||||
static_assert( std::is_trivially_copy_assignable<date::month_day>{}, "");
|
||||
static_assert( std::is_trivially_move_constructible<date::month_day>{}, "");
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -24,7 +24,7 @@
|
||||
// {
|
||||
// public:
|
||||
// constexpr explicit month_day_last(const date::month& m) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr date::month month() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -25,10 +25,10 @@
|
||||
// public:
|
||||
// constexpr month_weekday(const date::month& m,
|
||||
// const date::weekday_indexed& wdi) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr date::month month() const noexcept;
|
||||
// constexpr date::weekday_indexed weekday_indexed() const noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -25,10 +25,10 @@
|
||||
// public:
|
||||
// constexpr month_weekday_last(const date::month& m,
|
||||
// const date::weekday_last& wdl) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr date::month month() const noexcept;
|
||||
// constexpr date::weekday_last weekday_last() const noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
487
test/date_test/multi_year_duration_addition.pass.cpp
Normal file
487
test/date_test/multi_year_duration_addition.pass.cpp
Normal file
@ -0,0 +1,487 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2018 Tomasz Kamiński
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "date.h"
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
#define CPP11_ASSERT(...) static_assert(__VA_ARGS__, "")
|
||||
|
||||
#if __cplusplus >= 201402
|
||||
// C++14
|
||||
# define CPP14_ASSERT(...) static_assert(__VA_ARGS__, "")
|
||||
#else
|
||||
// C++11
|
||||
# define CPP14_ASSERT(...) assert(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define NOEXCEPT_ASSERT(...) static_assert(noexcept(__VA_ARGS__), "")
|
||||
|
||||
//Invocation involves a conversion between duration that is currently
|
||||
//not marked as noexcept.
|
||||
#define NOEXCEPT_CONVERSION(...)
|
||||
|
||||
template<typename T>
|
||||
constexpr T copy(T const& t) noexcept { return t; }
|
||||
|
||||
struct ConvertibleToYears
|
||||
{
|
||||
CONSTCD11 operator date::years() const NOEXCEPT
|
||||
{ return date::years{1}; };
|
||||
};
|
||||
|
||||
struct ConvertibleToMonths
|
||||
{
|
||||
CONSTCD11 operator date::months() const NOEXCEPT
|
||||
{ return date::months{1}; };
|
||||
};
|
||||
|
||||
struct ConvertibleToYearsAndMonths
|
||||
{
|
||||
CONSTCD11 operator date::years() const NOEXCEPT
|
||||
{ return date::years{1}; };
|
||||
|
||||
CONSTCD11 operator date::months() const NOEXCEPT
|
||||
{ return date::months{1}; };
|
||||
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
|
||||
using decades = duration<int, date::detail::ratio_multiply<std::ratio<10>, years::period>>;
|
||||
using decamonths = duration<int, date::detail::ratio_multiply<std::ratio<10>, months::period>>;
|
||||
|
||||
constexpr months one_month{1};
|
||||
constexpr years one_year{1};
|
||||
constexpr decades one_decade{1};
|
||||
constexpr decamonths one_decamonth{1};
|
||||
|
||||
constexpr ConvertibleToMonths custom_month;
|
||||
constexpr ConvertibleToYears custom_year;
|
||||
constexpr ConvertibleToYearsAndMonths prefer_year;
|
||||
|
||||
|
||||
{
|
||||
constexpr year_month ym = 2001_y/feb;
|
||||
CPP14_ASSERT(ym + one_month == 2001_y/mar);
|
||||
NOEXCEPT_ASSERT(ym + one_month);
|
||||
CPP14_ASSERT(one_month + ym == 2001_y/mar);
|
||||
NOEXCEPT_ASSERT(one_month + ym);
|
||||
CPP14_ASSERT(ym - one_month == 2001_y/jan);
|
||||
NOEXCEPT_ASSERT(ym - one_month);
|
||||
CPP14_ASSERT((copy(ym) += one_month) == 2001_y/mar);
|
||||
NOEXCEPT_ASSERT(copy(ym) += one_month);
|
||||
CPP14_ASSERT((copy(ym) -= one_month) == 2001_y/jan);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= one_month);
|
||||
|
||||
CPP11_ASSERT(ym + one_year == 2002_y/feb);
|
||||
NOEXCEPT_ASSERT(ym + one_year);
|
||||
CPP11_ASSERT(one_year + ym == 2002_y/feb);
|
||||
NOEXCEPT_ASSERT(one_year + ym);
|
||||
CPP11_ASSERT(ym - one_year == 2000_y/feb);
|
||||
NOEXCEPT_ASSERT(ym - one_year);
|
||||
CPP14_ASSERT((copy(ym) += one_year) == 2002_y/feb);
|
||||
NOEXCEPT_ASSERT(copy(ym) += one_year);
|
||||
CPP14_ASSERT((copy(ym) -= one_year) == 2000_y/feb);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= one_year);
|
||||
|
||||
CPP11_ASSERT(ym + one_decade == 2011_y/feb);
|
||||
NOEXCEPT_CONVERSION(ym + one_decade);
|
||||
CPP11_ASSERT(one_decade + ym == 2011_y/feb);
|
||||
NOEXCEPT_CONVERSION(one_decade + ym);
|
||||
CPP11_ASSERT(ym - one_decade == 1991_y/feb);
|
||||
NOEXCEPT_CONVERSION(ym - one_decade);
|
||||
CPP14_ASSERT((copy(ym) += one_decade) == 2011_y/feb);
|
||||
NOEXCEPT_CONVERSION(copy(ym) += one_decade);
|
||||
CPP14_ASSERT((copy(ym) -= one_decade) == 1991_y/feb);
|
||||
NOEXCEPT_CONVERSION(copy(ym) -= one_decade);
|
||||
|
||||
CPP14_ASSERT(ym + one_decamonth == 2001_y/dec);
|
||||
NOEXCEPT_CONVERSION(ym + one_decamonth);
|
||||
CPP14_ASSERT(one_decamonth + ym == 2001_y/dec);
|
||||
NOEXCEPT_CONVERSION(one_decamonth + ym);
|
||||
CPP14_ASSERT(ym - one_decamonth == 2000_y/apr);
|
||||
NOEXCEPT_CONVERSION(ym - one_decamonth);
|
||||
CPP14_ASSERT((copy(ym) += one_decamonth) == 2001_y/dec);
|
||||
NOEXCEPT_CONVERSION(copy(ym) += one_decamonth);
|
||||
CPP14_ASSERT((copy(ym) -= one_decamonth) == 2000_y/apr);
|
||||
NOEXCEPT_CONVERSION(copy(ym) -= one_decamonth);
|
||||
|
||||
CPP14_ASSERT(ym + custom_month == 2001_y/mar);
|
||||
NOEXCEPT_ASSERT(ym + custom_month);
|
||||
CPP14_ASSERT(custom_month + ym == 2001_y/mar);
|
||||
NOEXCEPT_ASSERT(custom_month + ym);
|
||||
CPP14_ASSERT(ym - custom_month == 2001_y/jan);
|
||||
NOEXCEPT_ASSERT(ym - custom_month);
|
||||
CPP14_ASSERT((copy(ym) += custom_month) == 2001_y/mar);
|
||||
NOEXCEPT_ASSERT(copy(ym) += custom_month);
|
||||
CPP14_ASSERT((copy(ym) -= custom_month) == 2001_y/jan);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= custom_month);
|
||||
|
||||
CPP11_ASSERT(ym + custom_year == 2002_y/feb);
|
||||
NOEXCEPT_ASSERT(ym + custom_year);
|
||||
CPP11_ASSERT(custom_year + ym == 2002_y/feb);
|
||||
NOEXCEPT_ASSERT(custom_year + ym);
|
||||
CPP11_ASSERT(ym - custom_year == 2000_y/feb);
|
||||
NOEXCEPT_ASSERT(ym - custom_year);
|
||||
CPP14_ASSERT((copy(ym) += custom_year) == 2002_y/feb);
|
||||
NOEXCEPT_ASSERT(copy(ym) += custom_year);
|
||||
CPP14_ASSERT((copy(ym) -= custom_year) == 2000_y/feb);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= custom_year);
|
||||
|
||||
CPP11_ASSERT(ym + prefer_year == 2002_y/feb);
|
||||
NOEXCEPT_ASSERT(ym + prefer_year);
|
||||
CPP11_ASSERT(prefer_year + ym == 2002_y/feb);
|
||||
NOEXCEPT_ASSERT(prefer_year + ym);
|
||||
CPP11_ASSERT(ym - prefer_year == 2000_y/feb);
|
||||
NOEXCEPT_ASSERT(ym - prefer_year);
|
||||
CPP14_ASSERT((copy(ym) += prefer_year) == 2002_y/feb);
|
||||
NOEXCEPT_ASSERT(copy(ym) += prefer_year);
|
||||
CPP14_ASSERT((copy(ym) -= prefer_year) == 2000_y/feb);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= prefer_year);
|
||||
}
|
||||
|
||||
{
|
||||
constexpr year_month_day ym = 2001_y/feb/10;
|
||||
CPP14_ASSERT(ym + one_month == 2001_y/mar/10);
|
||||
NOEXCEPT_ASSERT(ym + one_month);
|
||||
CPP14_ASSERT(one_month + ym == 2001_y/mar/10);
|
||||
NOEXCEPT_ASSERT(one_month + ym);
|
||||
CPP14_ASSERT(ym - one_month == 2001_y/jan/10);
|
||||
NOEXCEPT_ASSERT(ym - one_month);
|
||||
CPP14_ASSERT((copy(ym) += one_month) == 2001_y/mar/10);
|
||||
NOEXCEPT_ASSERT(copy(ym) += one_month);
|
||||
CPP14_ASSERT((copy(ym) -= one_month) == 2001_y/jan/10);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= one_month);
|
||||
|
||||
CPP11_ASSERT(ym + one_year == 2002_y/feb/10);
|
||||
NOEXCEPT_ASSERT(ym + one_year);
|
||||
CPP11_ASSERT(one_year + ym == 2002_y/feb/10);
|
||||
NOEXCEPT_ASSERT(one_year + ym);
|
||||
CPP11_ASSERT(ym - one_year == 2000_y/feb/10);
|
||||
NOEXCEPT_ASSERT(ym - one_year);
|
||||
CPP14_ASSERT((copy(ym) += one_year) == 2002_y/feb/10);
|
||||
NOEXCEPT_ASSERT(copy(ym) += one_year);
|
||||
CPP14_ASSERT((copy(ym) -= one_year) == 2000_y/feb/10);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= one_year);
|
||||
|
||||
CPP11_ASSERT(ym + one_decade == 2011_y/feb/10);
|
||||
NOEXCEPT_CONVERSION(ym + one_decade);
|
||||
CPP11_ASSERT(one_decade + ym == 2011_y/feb/10);
|
||||
NOEXCEPT_CONVERSION(one_decade + ym);
|
||||
CPP11_ASSERT(ym - one_decade == 1991_y/feb/10);
|
||||
NOEXCEPT_CONVERSION(ym - one_decade);
|
||||
CPP14_ASSERT((copy(ym) += one_decade) == 2011_y/feb/10);
|
||||
NOEXCEPT_CONVERSION(copy(ym) += one_decade);
|
||||
CPP14_ASSERT((copy(ym) -= one_decade) == 1991_y/feb/10);
|
||||
NOEXCEPT_CONVERSION(copy(ym) -= one_decade);
|
||||
|
||||
CPP14_ASSERT(ym + one_decamonth == 2001_y/dec/10);
|
||||
NOEXCEPT_CONVERSION(ym + one_decamonth);
|
||||
CPP14_ASSERT(one_decamonth + ym == 2001_y/dec/10);
|
||||
NOEXCEPT_CONVERSION(one_decamonth + ym);
|
||||
CPP14_ASSERT(ym - one_decamonth == 2000_y/apr/10);
|
||||
NOEXCEPT_CONVERSION(ym - one_decamonth);
|
||||
CPP14_ASSERT((copy(ym) += one_decamonth) == 2001_y/dec/10);
|
||||
NOEXCEPT_CONVERSION(copy(ym) += one_decamonth);
|
||||
CPP14_ASSERT((copy(ym) -= one_decamonth) == 2000_y/apr/10);
|
||||
NOEXCEPT_CONVERSION(copy(ym) -= one_decamonth);
|
||||
|
||||
CPP14_ASSERT(ym + custom_month == 2001_y/mar/10);
|
||||
NOEXCEPT_ASSERT(ym + custom_month);
|
||||
CPP14_ASSERT(custom_month + ym == 2001_y/mar/10);
|
||||
NOEXCEPT_ASSERT(custom_month + ym);
|
||||
CPP14_ASSERT(ym - custom_month == 2001_y/jan/10);
|
||||
NOEXCEPT_ASSERT(ym - custom_month);
|
||||
CPP14_ASSERT((copy(ym) += custom_month) == 2001_y/mar/10);
|
||||
NOEXCEPT_ASSERT(copy(ym) += custom_month);
|
||||
CPP14_ASSERT((copy(ym) -= custom_month) == 2001_y/jan/10);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= custom_month);
|
||||
|
||||
CPP11_ASSERT(ym + custom_year == 2002_y/feb/10);
|
||||
NOEXCEPT_ASSERT(ym + custom_year);
|
||||
CPP11_ASSERT(custom_year + ym == 2002_y/feb/10);
|
||||
NOEXCEPT_ASSERT(custom_year + ym);
|
||||
CPP11_ASSERT(ym - custom_year == 2000_y/feb/10);
|
||||
NOEXCEPT_ASSERT(ym - custom_year);
|
||||
CPP14_ASSERT((copy(ym) += custom_year) == 2002_y/feb/10);
|
||||
NOEXCEPT_ASSERT(copy(ym) += custom_year);
|
||||
CPP14_ASSERT((copy(ym) -= custom_year) == 2000_y/feb/10);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= custom_year);
|
||||
|
||||
CPP11_ASSERT(ym + prefer_year == 2002_y/feb/10);
|
||||
NOEXCEPT_ASSERT(ym + prefer_year);
|
||||
CPP11_ASSERT(prefer_year + ym == 2002_y/feb/10);
|
||||
NOEXCEPT_ASSERT(prefer_year + ym);
|
||||
CPP11_ASSERT(ym - prefer_year == 2000_y/feb/10);
|
||||
NOEXCEPT_ASSERT(ym - prefer_year);
|
||||
CPP14_ASSERT((copy(ym) += prefer_year) == 2002_y/feb/10);
|
||||
NOEXCEPT_ASSERT(copy(ym) += prefer_year);
|
||||
CPP14_ASSERT((copy(ym) -= prefer_year) == 2000_y/feb/10);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= prefer_year);
|
||||
}
|
||||
|
||||
{
|
||||
constexpr year_month_day_last ym = 2001_y/feb/last;
|
||||
CPP14_ASSERT(ym + one_month == 2001_y/mar/last);
|
||||
NOEXCEPT_ASSERT(ym + one_month);
|
||||
CPP14_ASSERT(one_month + ym == 2001_y/mar/last);
|
||||
NOEXCEPT_ASSERT(one_month + ym);
|
||||
CPP14_ASSERT(ym - one_month == 2001_y/jan/last);
|
||||
NOEXCEPT_ASSERT(ym - one_month);
|
||||
CPP14_ASSERT((copy(ym) += one_month) == 2001_y/mar/last);
|
||||
NOEXCEPT_ASSERT(copy(ym) += one_month);
|
||||
CPP14_ASSERT((copy(ym) -= one_month) == 2001_y/jan/last);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= one_month);
|
||||
|
||||
CPP11_ASSERT(ym + one_year == 2002_y/feb/last);
|
||||
NOEXCEPT_ASSERT(ym + one_year);
|
||||
CPP11_ASSERT(one_year + ym == 2002_y/feb/last);
|
||||
NOEXCEPT_ASSERT(one_year + ym);
|
||||
CPP11_ASSERT(ym - one_year == 2000_y/feb/last);
|
||||
NOEXCEPT_ASSERT(ym - one_year);
|
||||
CPP14_ASSERT((copy(ym) += one_year) == 2002_y/feb/last);
|
||||
NOEXCEPT_ASSERT(copy(ym) += one_year);
|
||||
CPP14_ASSERT((copy(ym) -= one_year) == 2000_y/feb/last);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= one_year);
|
||||
|
||||
CPP11_ASSERT(ym + one_decade == 2011_y/feb/last);
|
||||
NOEXCEPT_CONVERSION(ym + one_decade);
|
||||
CPP11_ASSERT(one_decade + ym == 2011_y/feb/last);
|
||||
NOEXCEPT_CONVERSION(one_decade + ym);
|
||||
CPP11_ASSERT(ym - one_decade == 1991_y/feb/last);
|
||||
NOEXCEPT_CONVERSION(ym - one_decade);
|
||||
CPP14_ASSERT((copy(ym) += one_decade) == 2011_y/feb/last);
|
||||
NOEXCEPT_CONVERSION(copy(ym) += one_decade);
|
||||
CPP14_ASSERT((copy(ym) -= one_decade) == 1991_y/feb/last);
|
||||
NOEXCEPT_CONVERSION(copy(ym) -= one_decade);
|
||||
|
||||
CPP14_ASSERT(ym + one_decamonth == 2001_y/dec/last);
|
||||
NOEXCEPT_CONVERSION(ym + one_decamonth);
|
||||
CPP14_ASSERT(one_decamonth + ym == 2001_y/dec/last);
|
||||
NOEXCEPT_CONVERSION(one_decamonth + ym);
|
||||
CPP14_ASSERT(ym - one_decamonth == 2000_y/apr/last);
|
||||
NOEXCEPT_CONVERSION(ym - one_decamonth);
|
||||
CPP14_ASSERT((copy(ym) += one_decamonth) == 2001_y/dec/last);
|
||||
NOEXCEPT_CONVERSION(copy(ym) += one_decamonth);
|
||||
CPP14_ASSERT((copy(ym) -= one_decamonth) == 2000_y/apr/last);
|
||||
NOEXCEPT_CONVERSION(copy(ym) -= one_decamonth);
|
||||
|
||||
CPP14_ASSERT(ym + custom_month == 2001_y/mar/last);
|
||||
NOEXCEPT_ASSERT(ym + custom_month);
|
||||
CPP14_ASSERT(custom_month + ym == 2001_y/mar/last);
|
||||
NOEXCEPT_ASSERT(custom_month + ym);
|
||||
CPP14_ASSERT(ym - custom_month == 2001_y/jan/last);
|
||||
NOEXCEPT_ASSERT(ym - custom_month);
|
||||
CPP14_ASSERT((copy(ym) += custom_month) == 2001_y/mar/last);
|
||||
NOEXCEPT_ASSERT(copy(ym) += custom_month);
|
||||
CPP14_ASSERT((copy(ym) -= custom_month) == 2001_y/jan/last);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= custom_month);
|
||||
|
||||
CPP11_ASSERT(ym + custom_year == 2002_y/feb/last);
|
||||
NOEXCEPT_ASSERT(ym + custom_year);
|
||||
CPP11_ASSERT(custom_year + ym == 2002_y/feb/last);
|
||||
NOEXCEPT_ASSERT(custom_year + ym);
|
||||
CPP11_ASSERT(ym - custom_year == 2000_y/feb/last);
|
||||
NOEXCEPT_ASSERT(ym - custom_year);
|
||||
CPP14_ASSERT((copy(ym) += custom_year) == 2002_y/feb/last);
|
||||
NOEXCEPT_ASSERT(copy(ym) += custom_year);
|
||||
CPP14_ASSERT((copy(ym) -= custom_year) == 2000_y/feb/last);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= custom_year);
|
||||
|
||||
CPP11_ASSERT(ym + prefer_year == 2002_y/feb/last);
|
||||
NOEXCEPT_ASSERT(ym + prefer_year);
|
||||
CPP11_ASSERT(prefer_year + ym == 2002_y/feb/last);
|
||||
NOEXCEPT_ASSERT(prefer_year + ym);
|
||||
CPP11_ASSERT(ym - prefer_year == 2000_y/feb/last);
|
||||
NOEXCEPT_ASSERT(ym - prefer_year);
|
||||
CPP14_ASSERT((copy(ym) += prefer_year) == 2002_y/feb/last);
|
||||
NOEXCEPT_ASSERT(copy(ym) += prefer_year);
|
||||
CPP14_ASSERT((copy(ym) -= prefer_year) == 2000_y/feb/last);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= prefer_year);
|
||||
}
|
||||
|
||||
{
|
||||
constexpr year_month_weekday ym = 2001_y/feb/fri[4];
|
||||
CPP14_ASSERT(ym + one_month == 2001_y/mar/fri[4]);
|
||||
NOEXCEPT_ASSERT(ym + one_month);
|
||||
CPP14_ASSERT(one_month + ym == 2001_y/mar/fri[4]);
|
||||
NOEXCEPT_ASSERT(one_month + ym);
|
||||
CPP14_ASSERT(ym - one_month == 2001_y/jan/fri[4]);
|
||||
NOEXCEPT_ASSERT(ym - one_month);
|
||||
CPP14_ASSERT((copy(ym) += one_month) == 2001_y/mar/fri[4]);
|
||||
NOEXCEPT_ASSERT(copy(ym) += one_month);
|
||||
CPP14_ASSERT((copy(ym) -= one_month) == 2001_y/jan/fri[4]);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= one_month);
|
||||
|
||||
CPP11_ASSERT(ym + one_year == 2002_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(ym + one_year);
|
||||
CPP11_ASSERT(one_year + ym == 2002_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(one_year + ym);
|
||||
CPP11_ASSERT(ym - one_year == 2000_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(ym - one_year);
|
||||
CPP14_ASSERT((copy(ym) += one_year) == 2002_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(copy(ym) += one_year);
|
||||
CPP14_ASSERT((copy(ym) -= one_year) == 2000_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= one_year);
|
||||
|
||||
CPP11_ASSERT(ym + one_decade == 2011_y/feb/fri[4]);
|
||||
NOEXCEPT_CONVERSION(ym + one_decade);
|
||||
CPP11_ASSERT(one_decade + ym == 2011_y/feb/fri[4]);
|
||||
NOEXCEPT_CONVERSION(one_decade + ym);
|
||||
CPP11_ASSERT(ym - one_decade == 1991_y/feb/fri[4]);
|
||||
NOEXCEPT_CONVERSION(ym - one_decade);
|
||||
CPP14_ASSERT((copy(ym) += one_decade) == 2011_y/feb/fri[4]);
|
||||
NOEXCEPT_CONVERSION(copy(ym) += one_decade);
|
||||
CPP14_ASSERT((copy(ym) -= one_decade) == 1991_y/feb/fri[4]);
|
||||
NOEXCEPT_CONVERSION(copy(ym) -= one_decade);
|
||||
|
||||
CPP14_ASSERT(ym + one_decamonth == 2001_y/dec/fri[4]);
|
||||
NOEXCEPT_CONVERSION(ym + one_decamonth);
|
||||
CPP14_ASSERT(one_decamonth + ym == 2001_y/dec/fri[4]);
|
||||
NOEXCEPT_CONVERSION(one_decamonth + ym);
|
||||
CPP14_ASSERT(ym - one_decamonth == 2000_y/apr/fri[4]);
|
||||
NOEXCEPT_CONVERSION(ym - one_decamonth);
|
||||
CPP14_ASSERT((copy(ym) += one_decamonth) == 2001_y/dec/fri[4]);
|
||||
NOEXCEPT_CONVERSION(copy(ym) += one_decamonth);
|
||||
CPP14_ASSERT((copy(ym) -= one_decamonth) == 2000_y/apr/fri[4]);
|
||||
NOEXCEPT_CONVERSION(copy(ym) -= one_decamonth);
|
||||
|
||||
CPP14_ASSERT(ym + custom_month == 2001_y/mar/fri[4]);
|
||||
NOEXCEPT_ASSERT(ym + custom_month);
|
||||
CPP14_ASSERT(custom_month + ym == 2001_y/mar/fri[4]);
|
||||
NOEXCEPT_ASSERT(custom_month + ym);
|
||||
CPP14_ASSERT(ym - custom_month == 2001_y/jan/fri[4]);
|
||||
NOEXCEPT_ASSERT(ym - custom_month);
|
||||
CPP14_ASSERT((copy(ym) += custom_month) == 2001_y/mar/fri[4]);
|
||||
NOEXCEPT_ASSERT(copy(ym) += custom_month);
|
||||
CPP14_ASSERT((copy(ym) -= custom_month) == 2001_y/jan/fri[4]);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= custom_month);
|
||||
|
||||
CPP11_ASSERT(ym + custom_year == 2002_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(ym + custom_year);
|
||||
CPP11_ASSERT(custom_year + ym == 2002_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(custom_year + ym);
|
||||
CPP11_ASSERT(ym - custom_year == 2000_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(ym - custom_year);
|
||||
CPP14_ASSERT((copy(ym) += custom_year) == 2002_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(copy(ym) += custom_year);
|
||||
CPP14_ASSERT((copy(ym) -= custom_year) == 2000_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= custom_year);
|
||||
|
||||
CPP11_ASSERT(ym + prefer_year == 2002_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(ym + prefer_year);
|
||||
CPP11_ASSERT(prefer_year + ym == 2002_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(prefer_year + ym);
|
||||
CPP11_ASSERT(ym - prefer_year == 2000_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(ym - prefer_year);
|
||||
CPP14_ASSERT((copy(ym) += prefer_year) == 2002_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(copy(ym) += prefer_year);
|
||||
CPP14_ASSERT((copy(ym) -= prefer_year) == 2000_y/feb/fri[4]);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= prefer_year);
|
||||
}
|
||||
|
||||
{
|
||||
constexpr year_month_weekday_last ym = 2001_y/feb/fri[last];
|
||||
CPP14_ASSERT(ym + one_month == 2001_y/mar/fri[last]);
|
||||
NOEXCEPT_ASSERT(ym + one_month);
|
||||
CPP14_ASSERT(one_month + ym == 2001_y/mar/fri[last]);
|
||||
NOEXCEPT_ASSERT(one_month + ym);
|
||||
CPP14_ASSERT(ym - one_month == 2001_y/jan/fri[last]);
|
||||
NOEXCEPT_ASSERT(ym - one_month);
|
||||
CPP14_ASSERT((copy(ym) += one_month) == 2001_y/mar/fri[last]);
|
||||
NOEXCEPT_ASSERT(copy(ym) += one_month);
|
||||
CPP14_ASSERT((copy(ym) -= one_month) == 2001_y/jan/fri[last]);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= one_month);
|
||||
|
||||
CPP11_ASSERT(ym + one_year == 2002_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(ym + one_year);
|
||||
CPP11_ASSERT(one_year + ym == 2002_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(one_year + ym);
|
||||
CPP11_ASSERT(ym - one_year == 2000_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(ym - one_year);
|
||||
CPP14_ASSERT((copy(ym) += one_year) == 2002_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(copy(ym) += one_year);
|
||||
CPP14_ASSERT((copy(ym) -= one_year) == 2000_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= one_year);
|
||||
|
||||
CPP11_ASSERT(ym + one_decade == 2011_y/feb/fri[last]);
|
||||
NOEXCEPT_CONVERSION(ym + one_decade);
|
||||
CPP11_ASSERT(one_decade + ym == 2011_y/feb/fri[last]);
|
||||
NOEXCEPT_CONVERSION(one_decade + ym);
|
||||
CPP11_ASSERT(ym - one_decade == 1991_y/feb/fri[last]);
|
||||
NOEXCEPT_CONVERSION(ym - one_decade);
|
||||
CPP14_ASSERT((copy(ym) += one_decade) == 2011_y/feb/fri[last]);
|
||||
NOEXCEPT_CONVERSION(copy(ym) += one_decade);
|
||||
CPP14_ASSERT((copy(ym) -= one_decade) == 1991_y/feb/fri[last]);
|
||||
NOEXCEPT_CONVERSION(copy(ym) -= one_decade);
|
||||
|
||||
CPP14_ASSERT(ym + one_decamonth == 2001_y/dec/fri[last]);
|
||||
NOEXCEPT_CONVERSION(ym + one_decamonth);
|
||||
CPP14_ASSERT(one_decamonth + ym == 2001_y/dec/fri[last]);
|
||||
NOEXCEPT_CONVERSION(one_decamonth + ym);
|
||||
CPP14_ASSERT(ym - one_decamonth == 2000_y/apr/fri[last]);
|
||||
NOEXCEPT_CONVERSION(ym - one_decamonth);
|
||||
CPP14_ASSERT((copy(ym) += one_decamonth) == 2001_y/dec/fri[last]);
|
||||
NOEXCEPT_CONVERSION(copy(ym) += one_decamonth);
|
||||
CPP14_ASSERT((copy(ym) -= one_decamonth) == 2000_y/apr/fri[last]);
|
||||
NOEXCEPT_CONVERSION(copy(ym) -= one_decamonth);
|
||||
|
||||
CPP14_ASSERT(ym + custom_month == 2001_y/mar/fri[last]);
|
||||
NOEXCEPT_ASSERT(ym + custom_month);
|
||||
CPP14_ASSERT(custom_month + ym == 2001_y/mar/fri[last]);
|
||||
NOEXCEPT_ASSERT(custom_month + ym);
|
||||
CPP14_ASSERT(ym - custom_month == 2001_y/jan/fri[last]);
|
||||
NOEXCEPT_ASSERT(ym - custom_month);
|
||||
CPP14_ASSERT((copy(ym) += custom_month) == 2001_y/mar/fri[last]);
|
||||
NOEXCEPT_ASSERT(copy(ym) += custom_month);
|
||||
CPP14_ASSERT((copy(ym) -= custom_month) == 2001_y/jan/fri[last]);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= custom_month);
|
||||
|
||||
CPP11_ASSERT(ym + custom_year == 2002_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(ym + custom_year);
|
||||
CPP11_ASSERT(custom_year + ym == 2002_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(custom_year + ym);
|
||||
CPP11_ASSERT(ym - custom_year == 2000_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(ym - custom_year);
|
||||
CPP14_ASSERT((copy(ym) += custom_year) == 2002_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(copy(ym) += custom_year);
|
||||
CPP14_ASSERT((copy(ym) -= custom_year) == 2000_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= custom_year);
|
||||
|
||||
CPP11_ASSERT(ym + prefer_year == 2002_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(ym + prefer_year);
|
||||
CPP11_ASSERT(prefer_year + ym == 2002_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(prefer_year + ym);
|
||||
CPP11_ASSERT(ym - prefer_year == 2000_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(ym - prefer_year);
|
||||
CPP14_ASSERT((copy(ym) += prefer_year) == 2002_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(copy(ym) += prefer_year);
|
||||
CPP14_ASSERT((copy(ym) -= prefer_year) == 2000_y/feb/fri[last]);
|
||||
NOEXCEPT_ASSERT(copy(ym) -= prefer_year);
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// day / day not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// int / month not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// int / year not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// last / last not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -24,7 +24,7 @@
|
||||
// constexpr month_day_last operator/(int m, last_spec) noexcept;
|
||||
// constexpr month_day_last operator/(last_spec, const month& m) noexcept;
|
||||
// constexpr month_day_last operator/(last_spec, int m) noexcept;
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// month_day / month_day not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// month / month not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// month / year not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -42,7 +42,7 @@ main()
|
||||
{
|
||||
using std::is_same;
|
||||
using namespace date;
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1, 1, 1)), int>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1, 1_d)), month_day>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1, jan)), void>{}, "");
|
||||
@ -50,7 +50,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1, 1, last)), month_day_last>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1, sun[1])), month_weekday>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1, sun[last])), month_weekday_last>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1, 1_d, 1)), year_month_day>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1_d, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1_d, jan)), void>{}, "");
|
||||
@ -58,7 +58,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1, 1_d, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1_d, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1_d, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1, jan, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, jan, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, jan, jan)), void>{}, "");
|
||||
@ -66,7 +66,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1, jan, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, jan, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, jan, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1, 1_y, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1_y, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1_y, jan)), void>{}, "");
|
||||
@ -74,7 +74,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1, 1_y, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1_y, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, 1_y, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1, last, 1)), year_month_day_last>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, last, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, last, jan)), void>{}, "");
|
||||
@ -82,7 +82,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1, last, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, last, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, last, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1, sun[1], 1)), year_month_weekday>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, sun[1], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, sun[1], jan)), void>{}, "");
|
||||
@ -90,7 +90,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1, sun[1], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, sun[1], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, sun[1], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1, sun[last], 1)), year_month_weekday_last>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, sun[last], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, sun[last], jan)), void>{}, "");
|
||||
@ -98,7 +98,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1, sun[last], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, sun[last], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1, sun[last], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_d, 1, 1)), year_month_day>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1, jan)), void>{}, "");
|
||||
@ -106,7 +106,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_d, 1, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_d, 1_d, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1_d, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1_d, jan)), void>{}, "");
|
||||
@ -114,7 +114,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_d, 1_d, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1_d, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1_d, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_d, jan, 1)), year_month_day>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, jan, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, jan, jan)), void>{}, "");
|
||||
@ -122,7 +122,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_d, jan, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, jan, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, jan, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_d, 1_y, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1_y, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1_y, jan)), void>{}, "");
|
||||
@ -130,7 +130,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_d, 1_y, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1_y, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, 1_y, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_d, last, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, last, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, last, jan)), void>{}, "");
|
||||
@ -138,7 +138,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_d, last, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, last, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, last, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_d, sun[1], 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, sun[1], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, sun[1], jan)), void>{}, "");
|
||||
@ -146,7 +146,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_d, sun[1], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, sun[1], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, sun[1], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_d, sun[last], 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, sun[last], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, sun[last], jan)), void>{}, "");
|
||||
@ -154,7 +154,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_d, sun[last], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, sun[last], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_d, sun[last], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( jan, 1, 1)), year_month_day>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1, jan)), void>{}, "");
|
||||
@ -162,7 +162,7 @@ main()
|
||||
static_assert(is_same<decltype(test( jan, 1, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( jan, 1_d, 1)), year_month_day>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1_d, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1_d, jan)), void>{}, "");
|
||||
@ -170,7 +170,7 @@ main()
|
||||
static_assert(is_same<decltype(test( jan, 1_d, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1_d, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1_d, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( jan, jan, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, jan, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, jan, jan)), void>{}, "");
|
||||
@ -178,7 +178,7 @@ main()
|
||||
static_assert(is_same<decltype(test( jan, jan, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, jan, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, jan, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( jan, 1_y, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1_y, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1_y, jan)), void>{}, "");
|
||||
@ -186,7 +186,7 @@ main()
|
||||
static_assert(is_same<decltype(test( jan, 1_y, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1_y, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, 1_y, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( jan, last, 1)), year_month_day_last>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, last, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, last, jan)), void>{}, "");
|
||||
@ -194,7 +194,7 @@ main()
|
||||
static_assert(is_same<decltype(test( jan, last, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, last, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, last, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( jan, sun[1], 1)), year_month_weekday>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, sun[1], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, sun[1], jan)), void>{}, "");
|
||||
@ -202,7 +202,7 @@ main()
|
||||
static_assert(is_same<decltype(test( jan, sun[1], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, sun[1], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, sun[1], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( jan, sun[last], 1)), year_month_weekday_last>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, sun[last], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, sun[last], jan)), void>{}, "");
|
||||
@ -210,7 +210,7 @@ main()
|
||||
static_assert(is_same<decltype(test( jan, sun[last], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, sun[last], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( jan, sun[last], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_y, 1, 1)), year_month_day>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1, 1_d)), year_month_day>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1, jan)), void>{}, "");
|
||||
@ -218,7 +218,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_y, 1, last)), year_month_day_last>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1, sun[1])), year_month_weekday>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1, sun[last])), year_month_weekday_last>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_y, 1_d, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1_d, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1_d, jan)), void>{}, "");
|
||||
@ -226,7 +226,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_y, 1_d, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1_d, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1_d, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_y, jan, 1)), year_month_day>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, jan, 1_d)), year_month_day>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, jan, jan)), void>{}, "");
|
||||
@ -234,7 +234,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_y, jan, last)), year_month_day_last>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, jan, sun[1])), year_month_weekday>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, jan, sun[last])), year_month_weekday_last>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_y, 1_y, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1_y, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1_y, jan)), void>{}, "");
|
||||
@ -242,7 +242,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_y, 1_y, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1_y, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, 1_y, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_y, last, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, last, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, last, jan)), void>{}, "");
|
||||
@ -250,7 +250,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_y, last, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, last, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, last, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_y, sun[1], 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, sun[1], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, sun[1], jan)), void>{}, "");
|
||||
@ -258,7 +258,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_y, sun[1], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, sun[1], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, sun[1], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( 1_y, sun[last], 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, sun[last], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, sun[last], jan)), void>{}, "");
|
||||
@ -266,7 +266,7 @@ main()
|
||||
static_assert(is_same<decltype(test( 1_y, sun[last], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, sun[last], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( 1_y, sun[last], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( last, 1, 1)), year_month_day_last>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1, jan)), void>{}, "");
|
||||
@ -274,7 +274,7 @@ main()
|
||||
static_assert(is_same<decltype(test( last, 1, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( last, 1_d, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1_d, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1_d, jan)), void>{}, "");
|
||||
@ -282,7 +282,7 @@ main()
|
||||
static_assert(is_same<decltype(test( last, 1_d, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1_d, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1_d, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( last, jan, 1)), year_month_day_last>{}, "");
|
||||
static_assert(is_same<decltype(test( last, jan, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, jan, jan)), void>{}, "");
|
||||
@ -290,7 +290,7 @@ main()
|
||||
static_assert(is_same<decltype(test( last, jan, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, jan, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, jan, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( last, 1_y, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1_y, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1_y, jan)), void>{}, "");
|
||||
@ -298,7 +298,7 @@ main()
|
||||
static_assert(is_same<decltype(test( last, 1_y, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1_y, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, 1_y, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( last, last, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, last, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, last, jan)), void>{}, "");
|
||||
@ -306,7 +306,7 @@ main()
|
||||
static_assert(is_same<decltype(test( last, last, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, last, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, last, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( last, sun[1], 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, sun[1], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, sun[1], jan)), void>{}, "");
|
||||
@ -314,7 +314,7 @@ main()
|
||||
static_assert(is_same<decltype(test( last, sun[1], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, sun[1], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, sun[1], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( last, sun[last], 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, sun[last], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, sun[last], jan)), void>{}, "");
|
||||
@ -322,7 +322,7 @@ main()
|
||||
static_assert(is_same<decltype(test( last, sun[last], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, sun[last], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( last, sun[last], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( sun[1], 1, 1)), year_month_weekday>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1, jan)), void>{}, "");
|
||||
@ -330,7 +330,7 @@ main()
|
||||
static_assert(is_same<decltype(test( sun[1], 1, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( sun[1], 1_d, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1_d, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1_d, jan)), void>{}, "");
|
||||
@ -338,7 +338,7 @@ main()
|
||||
static_assert(is_same<decltype(test( sun[1], 1_d, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1_d, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1_d, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( sun[1], jan, 1)), year_month_weekday>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], jan, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], jan, jan)), void>{}, "");
|
||||
@ -346,7 +346,7 @@ main()
|
||||
static_assert(is_same<decltype(test( sun[1], jan, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], jan, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], jan, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( sun[1], 1_y, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1_y, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1_y, jan)), void>{}, "");
|
||||
@ -354,7 +354,7 @@ main()
|
||||
static_assert(is_same<decltype(test( sun[1], 1_y, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1_y, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], 1_y, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( sun[1], last, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], last, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], last, jan)), void>{}, "");
|
||||
@ -362,7 +362,7 @@ main()
|
||||
static_assert(is_same<decltype(test( sun[1], last, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], last, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], last, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( sun[1], sun[1], 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], sun[1], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], sun[1], jan)), void>{}, "");
|
||||
@ -370,7 +370,7 @@ main()
|
||||
static_assert(is_same<decltype(test( sun[1], sun[1], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], sun[1], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], sun[1], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test( sun[1], sun[last], 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], sun[last], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], sun[last], jan)), void>{}, "");
|
||||
@ -378,7 +378,7 @@ main()
|
||||
static_assert(is_same<decltype(test( sun[1], sun[last], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], sun[last], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test( sun[1], sun[last], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test(sun[last], 1, 1)), year_month_weekday_last>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1, jan)), void>{}, "");
|
||||
@ -386,7 +386,7 @@ main()
|
||||
static_assert(is_same<decltype(test(sun[last], 1, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test(sun[last], 1_d, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1_d, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1_d, jan)), void>{}, "");
|
||||
@ -394,7 +394,7 @@ main()
|
||||
static_assert(is_same<decltype(test(sun[last], 1_d, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1_d, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1_d, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test(sun[last], jan, 1)), year_month_weekday_last>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], jan, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], jan, jan)), void>{}, "");
|
||||
@ -402,7 +402,7 @@ main()
|
||||
static_assert(is_same<decltype(test(sun[last], jan, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], jan, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], jan, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test(sun[last], 1_y, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1_y, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1_y, jan)), void>{}, "");
|
||||
@ -410,7 +410,7 @@ main()
|
||||
static_assert(is_same<decltype(test(sun[last], 1_y, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1_y, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], 1_y, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test(sun[last], last, 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], last, 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], last, jan)), void>{}, "");
|
||||
@ -418,7 +418,7 @@ main()
|
||||
static_assert(is_same<decltype(test(sun[last], last, last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], last, sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], last, sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test(sun[last], sun[1], 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], sun[1], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], sun[1], jan)), void>{}, "");
|
||||
@ -426,7 +426,7 @@ main()
|
||||
static_assert(is_same<decltype(test(sun[last], sun[1], last)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], sun[1], sun[1])), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], sun[1], sun[last])), void>{}, "");
|
||||
|
||||
|
||||
static_assert(is_same<decltype(test(sun[last], sun[last], 1)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], sun[last], 1_d)), void>{}, "");
|
||||
static_assert(is_same<decltype(test(sun[last], sun[last], jan)), void>{}, "");
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// weekday_indexed / weekday_indexed not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// weekday_last / weekday_last not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
// constexpr year_month operator/(const year& y, const month& m) noexcept;
|
||||
// constexpr year_month operator/(const year& y, int m) noexcept;
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -25,7 +25,7 @@
|
||||
// constexpr year_month_day_last operator/(int y, const month_day_last& mdl) noexcept;
|
||||
// constexpr year_month_day_last operator/(const month_day_last& mdl, const year& y) noexcept;
|
||||
// constexpr year_month_day_last operator/(const month_day_last& mdl, int y) noexcept;
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// year_month / year_month not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -21,7 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
// year / year not allowed
|
||||
|
||||
|
||||
#include "date.h"
|
||||
|
||||
int
|
||||
|
906
test/date_test/parse.pass.cpp
Normal file
906
test/date_test/parse.pass.cpp
Normal file
@ -0,0 +1,906 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// This test is meant to maintain a record of the sizeof each type.
|
||||
|
||||
#include "date.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
|
||||
void
|
||||
test_a()
|
||||
{
|
||||
using namespace date;
|
||||
{
|
||||
// correct abbreviation
|
||||
std::istringstream in{"Sun 2016-12-11"};
|
||||
sys_days tp;
|
||||
in >> parse("%a %F", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// correct abbreviation
|
||||
std::istringstream in{"Sun 2016-12-11"};
|
||||
sys_days tp;
|
||||
in >> parse("%A %F", tp);
|
||||
// this may fail with libstdc++, see https://github.com/HowardHinnant/date/issues/388
|
||||
// possible workaround: compile date.h with -DONLY_C_LOCALE=1
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// correct full name
|
||||
std::istringstream in{"Sunday 2016-12-11"};
|
||||
sys_days tp;
|
||||
in >> parse("%a %F", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// correct full name
|
||||
std::istringstream in{"Sunday 2016-12-11"};
|
||||
sys_days tp;
|
||||
in >> parse("%A %F", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// not a valid name
|
||||
std::istringstream in{"Dec 2016-12-11"};
|
||||
sys_days tp;
|
||||
in >> parse("%a %F", tp);
|
||||
assert( in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 1970_y/1/1);
|
||||
}
|
||||
{
|
||||
// wrong name
|
||||
std::istringstream in{"Sat 2016-12-11"};
|
||||
sys_days tp;
|
||||
in >> parse("%a %F", tp);
|
||||
assert( in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 1970_y/1/1);
|
||||
}
|
||||
{
|
||||
// extra ws in input
|
||||
std::istringstream in{"Sun 2016-12-11"};
|
||||
sys_days tp;
|
||||
in >> parse("%a %F", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// extra ws in format
|
||||
std::istringstream in{"Sun 2016-12-11"};
|
||||
sys_days tp;
|
||||
in >> parse("%a %F", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_b()
|
||||
{
|
||||
using namespace date;
|
||||
{
|
||||
// correct abbreviation
|
||||
std::istringstream in{"Dec 11 2016"};
|
||||
sys_days tp;
|
||||
in >> parse("%b %d %Y", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// correct abbreviation
|
||||
std::istringstream in{"Dec 11 2016"};
|
||||
sys_days tp;
|
||||
in >> parse("%B %d %Y", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// correct abbreviation
|
||||
std::istringstream in{"Dec 11 2016"};
|
||||
sys_days tp;
|
||||
in >> parse("%h %d %Y", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// correct full name
|
||||
std::istringstream in{"December 11 2016"};
|
||||
sys_days tp;
|
||||
in >> parse("%b %d %Y", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// correct full name
|
||||
std::istringstream in{"December 11 2016"};
|
||||
sys_days tp;
|
||||
in >> parse("%B %d %Y", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// correct full name
|
||||
std::istringstream in{"December 11 2016"};
|
||||
sys_days tp;
|
||||
in >> parse("%h %d %Y", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
// incorrect abbreviation
|
||||
std::istringstream in{"Dece 11 2016"};
|
||||
sys_days tp;
|
||||
in >> parse("%b %d %Y", tp);
|
||||
assert( in.fail());
|
||||
assert(!in.bad());
|
||||
assert(!in.eof());
|
||||
assert(tp == 1970_y/1/1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_c()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
// correct abbreviation
|
||||
std::istringstream in{"Sun Dec 11 14:02:43 2016"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%c", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{14} + minutes{2} + seconds{43});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_x()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
// correct abbreviation
|
||||
std::istringstream in{"12/11/16"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%x", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_X()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
// correct abbreviation
|
||||
std::istringstream in{"2016-12-11 14:02:43"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %X", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{14} + minutes{2} + seconds{43});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_C()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"20 16 12 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %y %m %d", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"-2 1 12 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %y %m %d", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == -101_y/12/11);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"-1 0 12 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %y %m %d", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == -100_y/12/11);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"-1 99 12 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %y %m %d", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == -99_y/12/11);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"-1 1 12 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %y %m %d", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == -1_y/12/11);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"0 0 12 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %y %m %d", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 0_y/12/11);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"0 1 12 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %y %m %d", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 1_y/12/11);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"0 99 12 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %y %m %d", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 99_y/12/11);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"1 0 12 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %y %m %d", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 100_y/12/11);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"1 1 12 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %y %m %d", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 101_y/12/11);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_d()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016 09 12"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %d %m", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/12/9);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016 09 12"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %e %m", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/12/9);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016 9 12"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %d %m", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/12/9);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016 9 12"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %e %m", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/12/9);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016 31 11"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %e %m", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_D()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"12/11/16"};
|
||||
sys_days tp;
|
||||
in >> parse("%D", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/12/11);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_F()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-12-13"};
|
||||
sys_days tp;
|
||||
in >> parse("%F", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/12/13);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-13"};
|
||||
year_month_day tp;
|
||||
in >> parse("%F", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/12/13);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_H()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15"};
|
||||
sys_time<hours> tp;
|
||||
in >> parse("%F %H", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{15});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 24"};
|
||||
sys_time<hours> tp;
|
||||
in >> parse("%F %H", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_Ip()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-12-11 1 pm"};
|
||||
sys_time<hours> tp;
|
||||
in >> parse("%F %I %p", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{13});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 1 am"};
|
||||
sys_time<hours> tp;
|
||||
in >> parse("%F %I %p", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{1});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 13 am"};
|
||||
sys_time<hours> tp;
|
||||
in >> parse("%F %I %p", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_j()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016 361"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %j", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_m()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016 12 09"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %d %m", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/9/12);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016 12 9"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %d %m", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == 2016_y/9/12);
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016 12 13"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y %d %m", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_M()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15"};
|
||||
sys_time<minutes> tp;
|
||||
in >> parse("%F %M", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + minutes{15});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 65"};
|
||||
sys_time<minutes> tp;
|
||||
in >> parse("%F %M", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_S()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %S", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + seconds{15});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15.001"};
|
||||
sys_time<milliseconds> tp;
|
||||
in >> parse("%F %S", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + seconds{15} + milliseconds{1});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 60"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %S", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_T()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15:43:22"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %T", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{15} + minutes{43} + seconds{22});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15:43:22.001"};
|
||||
sys_time<milliseconds> tp;
|
||||
in >> parse("%F %T", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{15} + minutes{43} + seconds{22} +
|
||||
milliseconds{1});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15:43:22"};
|
||||
sys_time<milliseconds> tp;
|
||||
in >> parse("%F %T", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{15} + minutes{43} + seconds{22});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"15:43:22.001"};
|
||||
milliseconds d;
|
||||
in >> parse("%T", d);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(d == hours{15} + minutes{43} + seconds{22} + milliseconds{1});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 24:43:22"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %T", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15:60:22"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %T", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-11 15:43:60"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %T", tp);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_p()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-12-11 11pm"};
|
||||
sys_time<hours> tp;
|
||||
in >> parse("%F %I%p", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/11} + hours{23});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_r()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-12-26 1:36:57 pm"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %r", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26} + hours{13} + minutes{36} + seconds{57});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_R()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-12-26 13:36"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %R", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26} + hours{13} + minutes{36});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_U()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-52-1"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y-%U-%w", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_W()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-52-1"};
|
||||
sys_days tp;
|
||||
in >> parse("%Y-%W-%w", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_GV()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-52-1"};
|
||||
sys_days tp;
|
||||
in >> parse("%G-%V-%w", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-52-1"};
|
||||
sys_days tp;
|
||||
in >> parse("%G-%V-%w", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"20 16-52-1"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %g-%V-%w", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"20 16-52-1"};
|
||||
sys_days tp;
|
||||
in >> parse("%C %g-%V-%u", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_z()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::istringstream in{"2016-12-26 15:53:22 -0500"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %T %z", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26} + hours{20} + minutes{53} + seconds{22});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-26 15:53:22 -0500"};
|
||||
local_seconds tp;
|
||||
in >> parse("%F %T %z", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == local_days{2016_y/12/26} + hours{15} + minutes{53} + seconds{22});
|
||||
}
|
||||
{
|
||||
std::istringstream in{"2016-12-26 15:53:22 -05:00"};
|
||||
sys_seconds tp;
|
||||
in >> parse("%F %T %Ez", tp);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == sys_days{2016_y/12/26} + hours{20} + minutes{53} + seconds{22});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_Z()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
{
|
||||
std::string a;
|
||||
std::istringstream in{"2016-12-26 15:53:22 word"};
|
||||
local_seconds tp;
|
||||
in >> parse("%F %T %Z", tp, a);
|
||||
assert(!in.fail());
|
||||
assert(!in.bad());
|
||||
assert(tp == local_days{2016_y/12/26} + hours{15} + minutes{53} + seconds{22});
|
||||
assert(a == "word");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_trailing_Z()
|
||||
{
|
||||
std::string format = "%FT%TZ";
|
||||
std::string datetime = "2017-2-15T13:13:13";
|
||||
std::istringstream input(datetime);
|
||||
date::sys_seconds tp;
|
||||
input >> date::parse(format, tp);
|
||||
assert(input.fail());
|
||||
assert(input.eof());
|
||||
}
|
||||
|
||||
void
|
||||
test_leading_ws()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace date;
|
||||
istringstream in{"05/04/17 5/4/17"};
|
||||
year_month_day d1, d2;
|
||||
in >> parse("%D", d1) >> parse("%n%D", d2);
|
||||
assert(d1 == may/4/2017);
|
||||
assert(d2 == may/4/2017);
|
||||
}
|
||||
|
||||
void
|
||||
test_space()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace date;
|
||||
{
|
||||
istringstream in{"05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse(" %D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse(" %D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse(" %D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_n()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace date;
|
||||
{
|
||||
istringstream in{"05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%n%D", d1);
|
||||
assert(in.fail());
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%n%D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%n%D", d1);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_t()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace date;
|
||||
{
|
||||
istringstream in{"05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%t%D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%t%D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%t%D", d1);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test_a();
|
||||
test_b();
|
||||
test_c();
|
||||
test_C();
|
||||
test_d();
|
||||
test_D();
|
||||
test_F();
|
||||
test_H();
|
||||
test_Ip();
|
||||
test_j();
|
||||
test_m();
|
||||
test_M();
|
||||
test_p();
|
||||
test_r();
|
||||
test_R();
|
||||
test_S();
|
||||
test_T();
|
||||
test_U();
|
||||
test_W();
|
||||
test_GV();
|
||||
test_x();
|
||||
test_X();
|
||||
test_z();
|
||||
test_Z();
|
||||
test_trailing_Z();
|
||||
test_leading_ws();
|
||||
test_space();
|
||||
test_n();
|
||||
test_t();
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -34,7 +34,7 @@ main()
|
||||
static_assert(sizeof(months) == 4, "");
|
||||
static_assert(sizeof(years) == 4, "");
|
||||
|
||||
static_assert(sizeof(day_point) == 4, "");
|
||||
static_assert(sizeof(sys_days) == 4, "");
|
||||
|
||||
static_assert(sizeof(last_spec) == 1, "");
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -26,16 +26,16 @@
|
||||
// {
|
||||
// public:
|
||||
// using precision = std::chrono::hours;
|
||||
//
|
||||
//
|
||||
// constexpr explicit time_of_day(std::chrono::hours since_midnight) noexcept;
|
||||
// constexpr time_of_day(std::chrono::hours h, unsigned md) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr std::chrono::hours hours() const noexcept;
|
||||
// constexpr unsigned mode() const noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr explicit operator precision() const noexcept;
|
||||
// constexpr precision to_duration() const noexcept;
|
||||
//
|
||||
//
|
||||
// void make24() noexcept;
|
||||
// void make12() noexcept;
|
||||
// };
|
||||
@ -57,10 +57,10 @@ main()
|
||||
|
||||
using tod = time_of_day<hours>;
|
||||
|
||||
static_assert(is_same<tod::precision, hours>{}, "");
|
||||
static_assert(is_same<tod::precision::period, seconds::period>{}, "");
|
||||
|
||||
static_assert( is_trivially_destructible<tod>{}, "");
|
||||
static_assert(!is_default_constructible<tod>{}, "");
|
||||
static_assert( is_default_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_assignable<tod>{}, "");
|
||||
static_assert( is_trivially_move_constructible<tod>{}, "");
|
||||
@ -68,14 +68,12 @@ main()
|
||||
|
||||
static_assert(is_nothrow_constructible<tod, hours>{}, "");
|
||||
static_assert(!is_convertible<hours, tod>{}, "");
|
||||
static_assert(is_nothrow_constructible<tod, hours, unsigned>{}, "");
|
||||
|
||||
static_assert(is_nothrow_constructible<tod::precision, tod>{}, "");
|
||||
static_assert(!is_convertible<tod, tod::precision>{}, "");
|
||||
|
||||
constexpr tod t1 = tod{hours{13}};
|
||||
static_assert(t1.hours() == hours{13}, "");
|
||||
static_assert(t1.mode() == 0, "");
|
||||
#if __cplusplus >= 201402
|
||||
static_assert(static_cast<tod::precision>(t1) == hours{13}, "");
|
||||
static_assert(t1.to_duration() == hours{13}, "");
|
||||
@ -83,23 +81,14 @@ main()
|
||||
|
||||
auto t2 = t1;
|
||||
assert(t2.hours() == t1.hours());
|
||||
assert(t2.mode() == t1.mode());
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
ostringstream os;
|
||||
os << t2;
|
||||
assert(os.str() == "1300");
|
||||
t2.make12();
|
||||
assert(os.str() == "13:00:00");
|
||||
auto h = make12(t2.hours());
|
||||
os.str("");
|
||||
assert(t2.hours() == hours{1});
|
||||
assert(t2.mode() == pm);
|
||||
assert(h == hours{1});
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
os << t2;
|
||||
assert(os.str() == "1pm");
|
||||
t2.make24();
|
||||
os.str("");
|
||||
assert(t2.hours() == hours{13});
|
||||
assert(t2.mode() == 0);
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
os << t2;
|
||||
assert(os.str() == "1300");
|
||||
assert(!is_am(t2.hours()));
|
||||
assert(is_pm(t2.hours()));
|
||||
}
|
||||
|
111
test/date_test/time_of_day_microfortnights.pass.cpp
Normal file
111
test/date_test/time_of_day_microfortnights.pass.cpp
Normal file
@ -0,0 +1,111 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
// enum {am = 1, pm};
|
||||
|
||||
// template <class Rep, class Period>
|
||||
// class time_of_day<std::chrono::duration<Rep, Period>>
|
||||
// {
|
||||
// public:
|
||||
// using precision = std::chrono::std::chrono::duration<Rep, Period>;
|
||||
//
|
||||
// constexpr explicit time_of_day(precision since_midnight) noexcept;
|
||||
// constexpr time_of_day(std::chrono::hours h, std::chrono::minutes m,
|
||||
// std::chrono::seconds s, precision sub_s,
|
||||
// unsigned md) noexcept;
|
||||
//
|
||||
// constexpr std::chrono::hours hours() const noexcept;
|
||||
// constexpr std::chrono::minutes minutes() const noexcept;
|
||||
// constexpr std::chrono::seconds seconds() const noexcept;
|
||||
// constexpr precision subseconds() const noexcept;
|
||||
// constexpr unsigned mode() const noexcept;
|
||||
//
|
||||
// constexpr explicit operator precision() const noexcept;
|
||||
// constexpr precision to_duration() const noexcept;
|
||||
//
|
||||
// void make24() noexcept;
|
||||
// void make12() noexcept;
|
||||
// };
|
||||
|
||||
// template <class Rep, class Period>
|
||||
// std::ostream&
|
||||
// operator<<(std::ostream& os, const time_of_day<std::chrono::duration<Rep, Period>>& t);
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
using fortnights = std::chrono::duration<date::weeks::rep,
|
||||
date::detail::ratio_multiply<std::ratio<2>,
|
||||
date::weeks::period>>;
|
||||
|
||||
using microfortnights = std::chrono::duration<std::int64_t,
|
||||
date::detail::ratio_multiply<fortnights::period,
|
||||
std::micro>>;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
|
||||
using tod = time_of_day<typename common_type<hours, minutes, microfortnights>::type>;
|
||||
|
||||
static_assert(is_same<tod::precision::period, ratio<1, 10000>>{}, "");
|
||||
|
||||
static_assert( is_trivially_destructible<tod>{}, "");
|
||||
static_assert( is_default_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_assignable<tod>{}, "");
|
||||
static_assert( is_trivially_move_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_move_assignable<tod>{}, "");
|
||||
|
||||
static_assert(is_constructible<tod, microfortnights>{}, "");
|
||||
static_assert(!is_convertible<microfortnights, tod>{}, "");
|
||||
|
||||
static_assert(is_nothrow_constructible<tod::precision, tod>{}, "");
|
||||
static_assert(!is_convertible<tod, tod::precision>{}, "");
|
||||
|
||||
constexpr tod t1 = tod{hours{13} + minutes{7} + microfortnights{5}};
|
||||
static_assert(t1.hours() == hours{13}, "");
|
||||
static_assert(t1.minutes() == minutes{7}, "");
|
||||
static_assert(t1.seconds() == seconds{6}, "");
|
||||
static_assert(t1.subseconds() == tod::precision{480}, "");
|
||||
#if __cplusplus >= 201402
|
||||
static_assert(static_cast<tod::precision>(t1) == hours{13} + minutes{7}
|
||||
+ microfortnights{5}, "");
|
||||
static_assert(t1.to_duration() == hours{13} + minutes{7} + microfortnights{5}, "");
|
||||
#endif
|
||||
|
||||
auto t2 = t1;
|
||||
assert(t2.hours() == t1.hours());
|
||||
assert(t2.minutes() == t1.minutes());
|
||||
assert(t2.seconds() == t1.seconds());
|
||||
assert(t2.subseconds() == t1.subseconds());
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
ostringstream os;
|
||||
os << t2;
|
||||
assert(os.str() == "13:07:06.0480");
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -27,21 +27,21 @@
|
||||
// {
|
||||
// public:
|
||||
// using precision = std::chrono::std::chrono::duration<Rep, Period>;
|
||||
//
|
||||
//
|
||||
// constexpr explicit time_of_day(precision since_midnight) noexcept;
|
||||
// constexpr time_of_day(std::chrono::hours h, std::chrono::minutes m,
|
||||
// std::chrono::seconds s, precision sub_s,
|
||||
// unsigned md) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr std::chrono::hours hours() const noexcept;
|
||||
// constexpr std::chrono::minutes minutes() const noexcept;
|
||||
// constexpr std::chrono::seconds seconds() const noexcept;
|
||||
// constexpr precision subseconds() const noexcept;
|
||||
// constexpr unsigned mode() const noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr explicit operator precision() const noexcept;
|
||||
// constexpr precision to_duration() const noexcept;
|
||||
//
|
||||
//
|
||||
// void make24() noexcept;
|
||||
// void make12() noexcept;
|
||||
// };
|
||||
@ -65,10 +65,10 @@ main()
|
||||
|
||||
using tod = time_of_day<milliseconds>;
|
||||
|
||||
static_assert(is_same<tod::precision, milliseconds>{}, "");
|
||||
static_assert(is_same<tod::precision::period, milliseconds::period>{}, "");
|
||||
|
||||
static_assert( is_trivially_destructible<tod>{}, "");
|
||||
static_assert(!is_default_constructible<tod>{}, "");
|
||||
static_assert( is_default_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_assignable<tod>{}, "");
|
||||
static_assert( is_trivially_move_constructible<tod>{}, "");
|
||||
@ -76,8 +76,6 @@ main()
|
||||
|
||||
static_assert(is_nothrow_constructible<tod, milliseconds>{}, "");
|
||||
static_assert(!is_convertible<milliseconds, tod>{}, "");
|
||||
static_assert(is_nothrow_constructible<tod, hours, minutes, seconds, milliseconds,
|
||||
unsigned>{}, "");
|
||||
|
||||
static_assert(is_nothrow_constructible<tod::precision, tod>{}, "");
|
||||
static_assert(!is_convertible<tod, tod::precision>{}, "");
|
||||
@ -87,7 +85,6 @@ main()
|
||||
static_assert(t1.minutes() == minutes{7}, "");
|
||||
static_assert(t1.seconds() == seconds{5}, "");
|
||||
static_assert(t1.subseconds() == milliseconds{22}, "");
|
||||
static_assert(t1.mode() == 0, "");
|
||||
#if __cplusplus >= 201402
|
||||
static_assert(static_cast<tod::precision>(t1) == hours{13} + minutes{7}
|
||||
+ seconds{5} + milliseconds{22}, "");
|
||||
@ -100,29 +97,8 @@ main()
|
||||
assert(t2.minutes() == t1.minutes());
|
||||
assert(t2.seconds() == t1.seconds());
|
||||
assert(t2.subseconds() == t1.subseconds());
|
||||
assert(t2.mode() == t1.mode());
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
ostringstream os;
|
||||
os << t2;
|
||||
assert(os.str() == "13:07:05.022");
|
||||
t2.make12();
|
||||
os.str("");
|
||||
assert(t2.hours() == hours{1});
|
||||
assert(t2.minutes() == minutes{7});
|
||||
assert(t2.seconds() == seconds{5});
|
||||
assert(t2.subseconds() == milliseconds{22});
|
||||
assert(t2.mode() == pm);
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
os << t2;
|
||||
assert(os.str() == "1:07:05.022pm");
|
||||
t2.make24();
|
||||
os.str("");
|
||||
assert(t2.hours() == hours{13});
|
||||
assert(t2.minutes() == minutes{7});
|
||||
assert(t2.seconds() == seconds{5});
|
||||
assert(t2.subseconds() == milliseconds{22});
|
||||
assert(t2.mode() == 0);
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
os << t2;
|
||||
assert(os.str() == "13:07:05.022");
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -26,18 +26,18 @@
|
||||
// {
|
||||
// public:
|
||||
// using precision = std::chrono::minutes;
|
||||
//
|
||||
//
|
||||
// constexpr explicit time_of_day(std::chrono::minutes since_midnight) noexcept;
|
||||
// constexpr time_of_day(std::chrono::hours h, std::chrono::minutes m,
|
||||
// unsigned md) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr std::chrono::hours hours() const noexcept;
|
||||
// constexpr std::chrono::minutes minutes() const noexcept;
|
||||
// constexpr unsigned mode() const noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr explicit operator precision() const noexcept;
|
||||
// constexpr precision to_duration() const noexcept;
|
||||
//
|
||||
//
|
||||
// void make24() noexcept;
|
||||
// void make12() noexcept;
|
||||
// };
|
||||
@ -59,10 +59,10 @@ main()
|
||||
|
||||
using tod = time_of_day<minutes>;
|
||||
|
||||
static_assert(is_same<tod::precision, minutes>{}, "");
|
||||
static_assert(is_same<tod::precision::period, seconds::period>{}, "");
|
||||
|
||||
static_assert( is_trivially_destructible<tod>{}, "");
|
||||
static_assert(!is_default_constructible<tod>{}, "");
|
||||
static_assert( is_default_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_assignable<tod>{}, "");
|
||||
static_assert( is_trivially_move_constructible<tod>{}, "");
|
||||
@ -70,7 +70,6 @@ main()
|
||||
|
||||
static_assert(is_nothrow_constructible<tod, minutes>{}, "");
|
||||
static_assert(!is_convertible<minutes, tod>{}, "");
|
||||
static_assert(is_nothrow_constructible<tod, hours, minutes, unsigned>{}, "");
|
||||
|
||||
static_assert(is_nothrow_constructible<tod::precision, tod>{}, "");
|
||||
static_assert(!is_convertible<tod, tod::precision>{}, "");
|
||||
@ -78,7 +77,6 @@ main()
|
||||
constexpr tod t1 = tod{hours{13} + minutes{7}};
|
||||
static_assert(t1.hours() == hours{13}, "");
|
||||
static_assert(t1.minutes() == minutes{7}, "");
|
||||
static_assert(t1.mode() == 0, "");
|
||||
#if __cplusplus >= 201402
|
||||
static_assert(static_cast<tod::precision>(t1) == hours{13} + minutes{7}, "");
|
||||
static_assert(t1.to_duration() == hours{13} + minutes{7}, "");
|
||||
@ -87,25 +85,8 @@ main()
|
||||
auto t2 = t1;
|
||||
assert(t2.hours() == t1.hours());
|
||||
assert(t2.minutes() == t1.minutes());
|
||||
assert(t2.mode() == t1.mode());
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
ostringstream os;
|
||||
os << t2;
|
||||
assert(os.str() == "13:07");
|
||||
t2.make12();
|
||||
os.str("");
|
||||
assert(t2.hours() == hours{1});
|
||||
assert(t2.minutes() == minutes{7});
|
||||
assert(t2.mode() == pm);
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
os << t2;
|
||||
assert(os.str() == "1:07pm");
|
||||
t2.make24();
|
||||
os.str("");
|
||||
assert(t2.hours() == hours{13});
|
||||
assert(t2.minutes() == minutes{7});
|
||||
assert(t2.mode() == 0);
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
os << t2;
|
||||
assert(os.str() == "13:07");
|
||||
assert(os.str() == "13:07:00");
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -27,21 +27,21 @@
|
||||
// {
|
||||
// public:
|
||||
// using precision = std::chrono::std::chrono::duration<Rep, Period>;
|
||||
//
|
||||
//
|
||||
// constexpr explicit time_of_day(precision since_midnight) noexcept;
|
||||
// constexpr time_of_day(std::chrono::hours h, std::chrono::minutes m,
|
||||
// std::chrono::seconds s, precision sub_s,
|
||||
// unsigned md) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr std::chrono::hours hours() const noexcept;
|
||||
// constexpr std::chrono::minutes minutes() const noexcept;
|
||||
// constexpr std::chrono::seconds seconds() const noexcept;
|
||||
// constexpr precision subseconds() const noexcept;
|
||||
// constexpr unsigned mode() const noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr explicit operator precision() const noexcept;
|
||||
// constexpr precision to_duration() const noexcept;
|
||||
//
|
||||
//
|
||||
// void make24() noexcept;
|
||||
// void make12() noexcept;
|
||||
// };
|
||||
@ -65,10 +65,10 @@ main()
|
||||
|
||||
using tod = time_of_day<nanoseconds>;
|
||||
|
||||
static_assert(is_same<tod::precision, nanoseconds>{}, "");
|
||||
static_assert(is_same<tod::precision::period, nanoseconds::period>{}, "");
|
||||
|
||||
static_assert( is_trivially_destructible<tod>{}, "");
|
||||
static_assert(!is_default_constructible<tod>{}, "");
|
||||
static_assert( is_default_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_assignable<tod>{}, "");
|
||||
static_assert( is_trivially_move_constructible<tod>{}, "");
|
||||
@ -76,8 +76,6 @@ main()
|
||||
|
||||
static_assert(is_nothrow_constructible<tod, nanoseconds>{}, "");
|
||||
static_assert(!is_convertible<nanoseconds, tod>{}, "");
|
||||
static_assert(is_nothrow_constructible<tod, hours, minutes, seconds, nanoseconds,
|
||||
unsigned>{}, "");
|
||||
|
||||
static_assert(is_nothrow_constructible<tod::precision, tod>{}, "");
|
||||
static_assert(!is_convertible<tod, tod::precision>{}, "");
|
||||
@ -87,7 +85,6 @@ main()
|
||||
static_assert(t1.minutes() == minutes{7}, "");
|
||||
static_assert(t1.seconds() == seconds{5}, "");
|
||||
static_assert(t1.subseconds() == nanoseconds{22}, "");
|
||||
static_assert(t1.mode() == 0, "");
|
||||
#if __cplusplus >= 201402
|
||||
static_assert(static_cast<tod::precision>(t1) == hours{13} + minutes{7}
|
||||
+ seconds{5} + nanoseconds{22}, "");
|
||||
@ -100,29 +97,8 @@ main()
|
||||
assert(t2.minutes() == t1.minutes());
|
||||
assert(t2.seconds() == t1.seconds());
|
||||
assert(t2.subseconds() == t1.subseconds());
|
||||
assert(t2.mode() == t1.mode());
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
ostringstream os;
|
||||
os << t2;
|
||||
assert(os.str() == "13:07:05.000000022");
|
||||
t2.make12();
|
||||
os.str("");
|
||||
assert(t2.hours() == hours{1});
|
||||
assert(t2.minutes() == minutes{7});
|
||||
assert(t2.seconds() == seconds{5});
|
||||
assert(t2.subseconds() == nanoseconds{22});
|
||||
assert(t2.mode() == pm);
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
os << t2;
|
||||
assert(os.str() == "1:07:05.000000022pm");
|
||||
t2.make24();
|
||||
os.str("");
|
||||
assert(t2.hours() == hours{13});
|
||||
assert(t2.minutes() == minutes{7});
|
||||
assert(t2.seconds() == seconds{5});
|
||||
assert(t2.subseconds() == nanoseconds{22});
|
||||
assert(t2.mode() == 0);
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
os << t2;
|
||||
assert(os.str() == "13:07:05.000000022");
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -26,19 +26,19 @@
|
||||
// {
|
||||
// public:
|
||||
// using precision = std::chrono::seconds;
|
||||
//
|
||||
//
|
||||
// constexpr explicit time_of_day(std::chrono::seconds since_midnight) noexcept;
|
||||
// constexpr time_of_day(std::chrono::hours h, std::chrono::minutes m,
|
||||
// std::chrono::seconds s, unsigned md) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr std::chrono::hours hours() const noexcept;
|
||||
// constexpr std::chrono::minutes minutes() const noexcept;
|
||||
// constexpr std::chrono::seconds seconds() const noexcept;
|
||||
// constexpr unsigned mode() const noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr explicit operator precision() const noexcept;
|
||||
// constexpr precision to_duration() const noexcept;
|
||||
//
|
||||
//
|
||||
// void make24() noexcept;
|
||||
// void make12() noexcept;
|
||||
// };
|
||||
@ -60,10 +60,10 @@ main()
|
||||
|
||||
using tod = time_of_day<seconds>;
|
||||
|
||||
static_assert(is_same<tod::precision, seconds>{}, "");
|
||||
static_assert(is_same<tod::precision::period, seconds::period>{}, "");
|
||||
|
||||
static_assert( is_trivially_destructible<tod>{}, "");
|
||||
static_assert(!is_default_constructible<tod>{}, "");
|
||||
static_assert( is_default_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_constructible<tod>{}, "");
|
||||
static_assert( is_trivially_copy_assignable<tod>{}, "");
|
||||
static_assert( is_trivially_move_constructible<tod>{}, "");
|
||||
@ -71,7 +71,6 @@ main()
|
||||
|
||||
static_assert(is_nothrow_constructible<tod, seconds>{}, "");
|
||||
static_assert(!is_convertible<seconds, tod>{}, "");
|
||||
static_assert(is_nothrow_constructible<tod, hours, minutes, seconds, unsigned>{}, "");
|
||||
|
||||
static_assert(is_nothrow_constructible<tod::precision, tod>{}, "");
|
||||
static_assert(!is_convertible<tod, tod::precision>{}, "");
|
||||
@ -80,7 +79,6 @@ main()
|
||||
static_assert(t1.hours() == hours{13}, "");
|
||||
static_assert(t1.minutes() == minutes{7}, "");
|
||||
static_assert(t1.seconds() == seconds{5}, "");
|
||||
static_assert(t1.mode() == 0, "");
|
||||
#if __cplusplus >= 201402
|
||||
static_assert(static_cast<tod::precision>(t1) == hours{13} + minutes{7}
|
||||
+ seconds{5}, "");
|
||||
@ -91,27 +89,8 @@ main()
|
||||
assert(t2.hours() == t1.hours());
|
||||
assert(t2.minutes() == t1.minutes());
|
||||
assert(t2.seconds() == t1.seconds());
|
||||
assert(t2.mode() == t1.mode());
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
ostringstream os;
|
||||
os << t2;
|
||||
assert(os.str() == "13:07:05");
|
||||
t2.make12();
|
||||
os.str("");
|
||||
assert(t2.hours() == hours{1});
|
||||
assert(t2.minutes() == minutes{7});
|
||||
assert(t2.seconds() == seconds{5});
|
||||
assert(t2.mode() == pm);
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
os << t2;
|
||||
assert(os.str() == "1:07:05pm");
|
||||
t2.make24();
|
||||
os.str("");
|
||||
assert(t2.hours() == hours{13});
|
||||
assert(t2.minutes() == minutes{7});
|
||||
assert(t2.seconds() == seconds{5});
|
||||
assert(t2.mode() == 0);
|
||||
assert(t2.to_duration() == t1.to_duration());
|
||||
os << t2;
|
||||
assert(os.str() == "13:07:05");
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -25,19 +25,19 @@
|
||||
// unsigned char wd_;
|
||||
// public:
|
||||
// explicit constexpr weekday(unsigned wd) noexcept;
|
||||
// constexpr weekday(const day_point& dp) noexcept;
|
||||
//
|
||||
// constexpr weekday(const sys_days& dp) noexcept;
|
||||
//
|
||||
// weekday& operator++() noexcept;
|
||||
// weekday operator++(int) noexcept;
|
||||
// weekday& operator--() noexcept;
|
||||
// weekday operator--(int) noexcept;
|
||||
//
|
||||
//
|
||||
// weekday& operator+=(const days& d) noexcept;
|
||||
// weekday& operator-=(const days& d) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr explicit operator unsigned() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
//
|
||||
//
|
||||
// // tested with weekday_indexed
|
||||
// constexpr weekday_indexed operator[](unsigned index) const noexcept;
|
||||
// // tested with weekday_last
|
||||
@ -69,19 +69,17 @@
|
||||
#include <type_traits>
|
||||
|
||||
static_assert( std::is_trivially_destructible<date::weekday>{}, "");
|
||||
static_assert(!std::is_default_constructible<date::weekday>{}, "");
|
||||
static_assert( std::is_default_constructible<date::weekday>{}, "");
|
||||
static_assert( std::is_trivially_copy_constructible<date::weekday>{}, "");
|
||||
static_assert( std::is_trivially_copy_assignable<date::weekday>{}, "");
|
||||
static_assert( std::is_trivially_move_constructible<date::weekday>{}, "");
|
||||
static_assert( std::is_trivially_move_assignable<date::weekday>{}, "");
|
||||
|
||||
static_assert( std::is_nothrow_constructible<date::weekday, unsigned>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<date::weekday, date::day_point>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<unsigned, date::weekday>{}, "");
|
||||
static_assert( std::is_nothrow_constructible<date::weekday, date::sys_days>{}, "");
|
||||
static_assert(!std::is_convertible<unsigned, date::weekday>{}, "");
|
||||
static_assert( std::is_convertible<date::day_point, date::weekday>{}, "");
|
||||
static_assert( std::is_convertible<date::sys_days, date::weekday>{}, "");
|
||||
static_assert(!std::is_convertible<date::weekday, unsigned>{}, "");
|
||||
static_assert(static_cast<unsigned>(date::weekday{1u}) == 1, "");
|
||||
|
||||
static_assert( date::weekday{0u}.ok(), "");
|
||||
static_assert( date::weekday{1u}.ok(), "");
|
||||
@ -90,7 +88,8 @@ static_assert( date::weekday{3u}.ok(), "");
|
||||
static_assert( date::weekday{4u}.ok(), "");
|
||||
static_assert( date::weekday{5u}.ok(), "");
|
||||
static_assert( date::weekday{6u}.ok(), "");
|
||||
static_assert(!date::weekday{7u}.ok(), "");
|
||||
static_assert( date::weekday{7u}.ok(), "");
|
||||
static_assert(!date::weekday{8u}.ok(), "");
|
||||
|
||||
void
|
||||
test_weekday_arithmetic()
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -23,16 +23,17 @@
|
||||
// class weekday_indexed
|
||||
// {
|
||||
// public:
|
||||
// weekday_indexed() = default;
|
||||
// constexpr weekday_indexed(const date::weekday& wd, unsigned index) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr date::weekday weekday() const noexcept;
|
||||
// constexpr unsigned index() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
|
||||
// constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept;
|
||||
//
|
||||
//
|
||||
// std::ostream& operator<<(std::ostream& os, const weekday_indexed& wdi);
|
||||
|
||||
#include "date.h"
|
||||
@ -42,7 +43,7 @@
|
||||
#include <type_traits>
|
||||
|
||||
static_assert( std::is_trivially_destructible<date::weekday_indexed>{}, "");
|
||||
static_assert(!std::is_default_constructible<date::weekday_indexed>{}, "");
|
||||
static_assert( std::is_default_constructible<date::weekday_indexed>{}, "");
|
||||
static_assert( std::is_trivially_copy_constructible<date::weekday_indexed>{}, "");
|
||||
static_assert( std::is_trivially_copy_assignable<date::weekday_indexed>{}, "");
|
||||
static_assert( std::is_trivially_move_constructible<date::weekday_indexed>{}, "");
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -24,14 +24,14 @@
|
||||
// {
|
||||
// public:
|
||||
// explicit constexpr weekday_last(const date::weekday& wd) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr date::weekday weekday() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
//
|
||||
//
|
||||
// constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
|
||||
// constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept;
|
||||
//
|
||||
//
|
||||
// std::ostream& operator<<(std::ostream& os, const weekday_last& wdl);
|
||||
|
||||
#include "date.h"
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -24,20 +24,20 @@
|
||||
// {
|
||||
// public:
|
||||
// explicit constexpr year(int y) noexcept;
|
||||
//
|
||||
//
|
||||
// year& operator++() noexcept;
|
||||
// year operator++(int) noexcept;
|
||||
// year& operator--() noexcept;
|
||||
// year operator--(int) noexcept;
|
||||
//
|
||||
//
|
||||
// year& operator+=(const years& y) noexcept;
|
||||
// year& operator-=(const years& y) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr bool is_leap() const noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr explicit operator int() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
//
|
||||
//
|
||||
// static constexpr year min() noexcept;
|
||||
// static constexpr year max() noexcept;
|
||||
// };
|
||||
@ -64,7 +64,7 @@
|
||||
#include <type_traits>
|
||||
|
||||
static_assert( std::is_trivially_destructible<date::year>{}, "");
|
||||
static_assert(!std::is_default_constructible<date::year>{}, "");
|
||||
static_assert( std::is_default_constructible<date::year>{}, "");
|
||||
static_assert( std::is_trivially_copy_constructible<date::year>{}, "");
|
||||
static_assert( std::is_trivially_copy_assignable<date::year>{}, "");
|
||||
static_assert( std::is_trivially_move_constructible<date::year>{}, "");
|
||||
@ -107,30 +107,30 @@ main()
|
||||
static_assert(year::max().ok(), "");
|
||||
|
||||
#if __cplusplus >= 201402
|
||||
using int64_t = std::int64_t;
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
using std::int64_t;
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(days::min()), "");
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(hours::min()), "");
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(minutes::min()), "");
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(seconds::min()), "");
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(milliseconds::min()), "");
|
||||
static_assert(day_point(year::min()/jan/1) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::min()/jan/1) - sys_days(1970_y/jan/1)
|
||||
>= as<int64_t>(microseconds::min()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(microseconds::max()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(milliseconds::max()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(seconds::max()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(minutes::max()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(hours::max()), "");
|
||||
static_assert(day_point(year::max()/dec/31) - day_point(1970_y/jan/1)
|
||||
static_assert(sys_days(year::max()/dec/31) - sys_days(1970_y/jan/1)
|
||||
<= as<int64_t>(days::max()), "");
|
||||
#endif
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -24,15 +24,15 @@
|
||||
// {
|
||||
// public:
|
||||
// constexpr year_month(const date::year& y, const date::month& m) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr date::year year() const noexcept;
|
||||
// constexpr date::month month() const noexcept;
|
||||
//
|
||||
//
|
||||
// year_month& operator+=(const months& dm) noexcept;
|
||||
// year_month& operator-=(const months& dm) noexcept;
|
||||
// year_month& operator+=(const years& dy) noexcept;
|
||||
// year_month& operator-=(const years& dy) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
#include <type_traits>
|
||||
|
||||
static_assert( std::is_trivially_destructible<date::year_month>{}, "");
|
||||
static_assert(!std::is_default_constructible<date::year_month>{}, "");
|
||||
static_assert( std::is_default_constructible<date::year_month>{}, "");
|
||||
static_assert( std::is_trivially_copy_constructible<date::year_month>{}, "");
|
||||
static_assert( std::is_trivially_copy_assignable<date::year_month>{}, "");
|
||||
static_assert( std::is_trivially_move_constructible<date::year_month>{}, "");
|
||||
@ -109,6 +109,90 @@ test_arithmetic()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_arithemtic_not_ok()
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
|
||||
year_month ym{2018_y, month{14}};
|
||||
|
||||
{
|
||||
year_month ym2{2019_y, month{2}};
|
||||
assert(ym + months{0} == ym2);
|
||||
assert(ym - months{0} == ym2);
|
||||
assert(ym - ym2 == months{0});
|
||||
assert(ym2 - ym == months{0});
|
||||
|
||||
auto ymc = ym;
|
||||
ymc += months{0};
|
||||
assert(ymc.ok());
|
||||
assert(ymc == ym2);
|
||||
}
|
||||
|
||||
{
|
||||
year_month ym2{2019_y, month{6}};
|
||||
assert(ym + months{4} == ym2);
|
||||
assert(ym2 - ym == months{4});
|
||||
assert(ym - ym2 == -months{4});
|
||||
|
||||
auto ymc = ym;
|
||||
ymc += months{4};
|
||||
assert(ymc.ok());
|
||||
assert(ymc == ym2);
|
||||
}
|
||||
|
||||
{
|
||||
year_month ym2{2018_y, month{10}};
|
||||
assert(ym - months{4} == ym2);
|
||||
assert(ym2 - ym == -months{4});
|
||||
assert(ym - ym2 == months{4});
|
||||
|
||||
auto ymc = ym;
|
||||
ymc -= months{4};
|
||||
assert(ymc.ok());
|
||||
assert(ymc == ym2);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
year_month ym2{2020_y, month{6}};
|
||||
assert(ym + months{16} == ym2);
|
||||
assert(ym2 - ym == months{16});
|
||||
assert(ym - ym2 == -months{16});
|
||||
|
||||
auto ymc = ym;
|
||||
ymc += months{16};
|
||||
assert(ymc.ok());
|
||||
assert(ymc == ym2);
|
||||
}
|
||||
|
||||
{
|
||||
year_month ym2{2017_y, month{10}};
|
||||
assert(ym - months{16} == ym2);
|
||||
assert(ym2 - ym == -months{16});
|
||||
assert(ym - ym2 == months(16));
|
||||
|
||||
auto ymc = ym;
|
||||
ymc -= months{16};
|
||||
assert(ymc.ok());
|
||||
assert(ymc == ym2);
|
||||
}
|
||||
|
||||
{
|
||||
year_month ym2{2018_y, month{25}};
|
||||
assert(ym2 - ym == months{11});
|
||||
assert(ym - ym2 == -months{11});
|
||||
}
|
||||
|
||||
{
|
||||
year_month ym2{2019_y, month{25}};
|
||||
assert(ym2 - ym == months{23});
|
||||
assert(ym - ym2 == -months{23});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
@ -135,6 +219,7 @@ main()
|
||||
static_assert(ym1 - ym2 == -months{11}, "");
|
||||
|
||||
test_arithmetic();
|
||||
test_arithemtic_not_ok();
|
||||
|
||||
std::ostringstream os;
|
||||
os << ym1;
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -26,18 +26,18 @@
|
||||
// constexpr year_month_day(const date::year& y, const date::month& m,
|
||||
// const date::day& d) noexcept;
|
||||
// constexpr year_month_day(const year_month_day_last& ymdl) noexcept;
|
||||
// constexpr year_month_day(const day_point& dp) noexcept;
|
||||
//
|
||||
// constexpr year_month_day(const sys_days& dp) noexcept;
|
||||
//
|
||||
// year_month_day& operator+=(const months& m) noexcept;
|
||||
// year_month_day& operator-=(const months& m) noexcept;
|
||||
// year_month_day& operator+=(const years& y) noexcept;
|
||||
// year_month_day& operator-=(const years& y) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr date::year year() const noexcept;
|
||||
// constexpr date::month month() const noexcept;
|
||||
// constexpr date::day day() const noexcept;
|
||||
//
|
||||
// constexpr operator day_point() const noexcept;
|
||||
//
|
||||
// constexpr operator sys_days() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
|
||||
@ -64,7 +64,7 @@
|
||||
#include <type_traits>
|
||||
|
||||
static_assert( std::is_trivially_destructible<date::year_month_day>{}, "");
|
||||
static_assert(!std::is_default_constructible<date::year_month_day>{}, "");
|
||||
static_assert( std::is_default_constructible<date::year_month_day>{}, "");
|
||||
static_assert( std::is_trivially_copy_constructible<date::year_month_day>{}, "");
|
||||
static_assert( std::is_trivially_copy_assignable<date::year_month_day>{}, "");
|
||||
static_assert( std::is_trivially_move_constructible<date::year_month_day>{}, "");
|
||||
@ -76,10 +76,10 @@ static_assert(std::is_nothrow_constructible<date::year_month_day, date::year,
|
||||
static_assert(std::is_nothrow_constructible<date::year_month_day,
|
||||
date::year_month_day_last>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_day_last, date::year_month_day>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::year_month_day, date::day_point>{}, "");
|
||||
static_assert(std::is_convertible<date::day_point, date::year_month_day>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::day_point, date::year_month_day>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_day, date::day_point>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::year_month_day, date::sys_days>{}, "");
|
||||
static_assert(std::is_convertible<date::sys_days, date::year_month_day>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::sys_days, date::year_month_day>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_day, date::sys_days>{}, "");
|
||||
|
||||
void
|
||||
test_arithmetic()
|
||||
@ -131,7 +131,7 @@ test_day_point_conversion()
|
||||
using namespace date;
|
||||
year y = year{-1000};
|
||||
year end = 3000_y;
|
||||
day_point prev_dp = day_point(year_month_day{y, jan, 1_d}) - days{1};
|
||||
sys_days prev_dp = sys_days(year_month_day{y, jan, 1_d}) - days{1};
|
||||
weekday prev_wd = weekday{prev_dp};
|
||||
for (; y <= end; ++y)
|
||||
{
|
||||
@ -143,7 +143,7 @@ test_day_point_conversion()
|
||||
{
|
||||
year_month_day ymd = {y, m, d};
|
||||
assert(ymd.ok());
|
||||
day_point dp = ymd;
|
||||
sys_days dp = ymd;
|
||||
assert(dp == prev_dp + days{1});
|
||||
year_month_day ymd2 = dp;
|
||||
assert(ymd2 == ymd);
|
||||
@ -171,7 +171,7 @@ main()
|
||||
static_assert(ymd1.day() == 9_d, "");
|
||||
|
||||
#if __cplusplus >= 201402
|
||||
constexpr day_point dp = ymd1;
|
||||
constexpr sys_days dp = ymd1;
|
||||
static_assert(dp.time_since_epoch() == days{16656}, "");
|
||||
constexpr year_month_day ymd2 = dp;
|
||||
static_assert(ymd1 == ymd2, "");
|
||||
@ -186,7 +186,7 @@ main()
|
||||
static_assert(ymd3.day() == 31_d, "");
|
||||
|
||||
#if __cplusplus >= 201402
|
||||
constexpr day_point dp3 = ymd3;
|
||||
constexpr sys_days dp3 = ymd3;
|
||||
static_assert(dp3.time_since_epoch() == days{-1}, "");
|
||||
constexpr year_month_day ymd4 = dp3;
|
||||
static_assert(ymd3 == ymd4, "");
|
||||
@ -211,9 +211,9 @@ main()
|
||||
static_assert( (2100_y/feb/28).ok(), "");
|
||||
static_assert(!(2100_y/feb/29).ok(), "");
|
||||
|
||||
static_assert(day_point(2100_y/feb/28) + days{1} == day_point(2100_y/mar/1), "");
|
||||
static_assert(day_point(2000_y/mar/1) - day_point(2000_y/feb/28) == days{2}, "");
|
||||
static_assert(day_point(2100_y/mar/1) - day_point(2100_y/feb/28) == days{1}, "");
|
||||
static_assert(sys_days(2100_y/feb/28) + days{1} == sys_days(2100_y/mar/1), "");
|
||||
static_assert(sys_days(2000_y/mar/1) - sys_days(2000_y/feb/28) == days{2}, "");
|
||||
static_assert(sys_days(2100_y/mar/1) - sys_days(2100_y/feb/28) == days{1}, "");
|
||||
|
||||
static_assert(jan/31/2015 == jan/last/2015, "");
|
||||
static_assert(feb/28/2015 == feb/last/2015, "");
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -25,18 +25,18 @@
|
||||
// public:
|
||||
// constexpr year_month_day_last(const date::year& y,
|
||||
// const date::month_day_last& mdl) noexcept;
|
||||
//
|
||||
//
|
||||
// year_month_day_last& operator+=(const months& m) noexcept;
|
||||
// year_month_day_last& operator-=(const months& m) noexcept;
|
||||
// year_month_day_last& operator+=(const years& y) noexcept;
|
||||
// year_month_day_last& operator-=(const years& y) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr date::year year() const noexcept;
|
||||
// constexpr date::month month() const noexcept;
|
||||
// constexpr date::month_day_last month_day_last() const noexcept;
|
||||
// constexpr date::day day() const noexcept;
|
||||
//
|
||||
// constexpr operator day_point() const noexcept;
|
||||
//
|
||||
// constexpr operator sys_days() const noexcept;
|
||||
// constexpr bool ok() const noexcept;
|
||||
// };
|
||||
|
||||
@ -56,23 +56,23 @@
|
||||
// constexpr
|
||||
// year_month_day_last
|
||||
// operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr
|
||||
// year_month_day_last
|
||||
// operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr
|
||||
// year_month_day_last
|
||||
// operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr
|
||||
// year_month_day_last
|
||||
// operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr
|
||||
// year_month_day_last
|
||||
// operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
|
||||
//
|
||||
//
|
||||
// constexpr
|
||||
// year_month_day_last
|
||||
// operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
|
||||
@ -94,9 +94,9 @@ static_assert( std::is_trivially_move_assignable<date::year_month_day_last>{}, "
|
||||
|
||||
static_assert(std::is_nothrow_constructible<date::year_month_day_last,
|
||||
date::year, date::month_day_last>{}, "");
|
||||
static_assert(std::is_nothrow_constructible<date::day_point,
|
||||
static_assert(std::is_nothrow_constructible<date::sys_days,
|
||||
date::year_month_day_last>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_day_last, date::day_point>{}, "");
|
||||
static_assert(std::is_convertible<date::year_month_day_last, date::sys_days>{}, "");
|
||||
|
||||
void
|
||||
test_arithmetic()
|
||||
@ -105,7 +105,7 @@ test_arithmetic()
|
||||
|
||||
for (int y1 = 2010; y1 <= 2015; ++y1)
|
||||
{
|
||||
for (unsigned m1 = 1; m1 <= 12; ++m1)
|
||||
for (int m1 = 1; m1 <= 12; ++m1)
|
||||
{
|
||||
auto ymd1 = last/m1/y1;;
|
||||
auto ymd2 = ymd1 + months(24);
|
||||
@ -154,7 +154,7 @@ main()
|
||||
static_assert(ymdl1.month_day_last() == month_day_last{aug}, "");
|
||||
#if __cplusplus >= 201402
|
||||
static_assert(ymdl1.day() == 31_d, "");
|
||||
constexpr day_point dp = ymdl1;
|
||||
constexpr sys_days dp = ymdl1;
|
||||
constexpr year_month_day ymd = dp;
|
||||
static_assert(ymd == 2015_y/aug/31, "");
|
||||
#endif
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
@ -1,17 +1,17 @@
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Howard Hinnant
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2015, 2016 Howard Hinnant
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user