mirror of
https://github.com/boostorg/date_time.git
synced 2026-07-22 13:23:37 +00:00
Compare commits
1100 Commits
boost-1.30.2
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 6248d64ed9 | |||
| 6b387c4969 | |||
| 69c45b7a2b | |||
| 19ffa6232d | |||
| 363e04d7ec | |||
| 64c1df1e3e | |||
| 645574e5df | |||
| 85e637cb32 | |||
| 39714907b7 | |||
| abef5a147a | |||
| ddcfd00391 | |||
| c02d713cef | |||
| b81ed2874f | |||
| 0aed920bfb | |||
| f972dc9656 | |||
| 7677fdce5a | |||
| 8729945096 | |||
| cbad9bcec9 | |||
| 64fe6586fe | |||
| a20a5c8b7c | |||
| ff77162265 | |||
| 0be5d92c90 | |||
| 33dc6136f1 | |||
| 7156392706 | |||
| 561ccb878d | |||
| 3feaece6d2 | |||
| 9970590094 | |||
| 4b97311ca7 | |||
| a94bcf288d | |||
| 8011fdf0bc | |||
| 15be01a02d | |||
| acbee0dc6a | |||
| aa9c5dfd48 | |||
| 47de78e4fc | |||
| 79ca1aa0a7 | |||
| ccc21804bd | |||
| 31c983b256 | |||
| f92b2b3bfc | |||
| b43d605ad2 | |||
| fa46e55ca8 | |||
| 61677ba228 | |||
| 30795441e4 | |||
| 77495803c1 | |||
| 247424d08d | |||
| ab066e3601 | |||
| 76852e4aab | |||
| 356c5c2600 | |||
| 3d55c15cbb | |||
| d77ee59bc2 | |||
| 5093074e0e | |||
| ecf042f538 | |||
| d0b3c1da88 | |||
| b03272650e | |||
| e9a9ce3e35 | |||
| 0c1d8fddd8 | |||
| ad3239b722 | |||
| d335a54e9f | |||
| cb3bd50b90 | |||
| 4a46476358 | |||
| 44618f1632 | |||
| bbac2178ed | |||
| d8c7a59ed9 | |||
| d8a894c44a | |||
| 139f44776d | |||
| 6f7b2b5056 | |||
| 4e1b7cde45 | |||
| e26fd2ed98 | |||
| 061aec856d | |||
| 1a95e81043 | |||
| c0b71da135 | |||
| 2fabfad443 | |||
| 3cc68a4642 | |||
| 29bb209464 | |||
| 345abc6b67 | |||
| b0437e2999 | |||
| 5902a0e577 | |||
| c18805c4ba | |||
| 81d60863b6 | |||
| a3d61f0d30 | |||
| dc5ce19c27 | |||
| 66ee8bf48f | |||
| aa19739c55 | |||
| f76ef169a0 | |||
| fd5f9aea7c | |||
| 6875e73a03 | |||
| 8e1f2be360 | |||
| 1838518b41 | |||
| a7ec0146c7 | |||
| 9690a13c55 | |||
| 5a70608c65 | |||
| dae0fa1b47 | |||
| 3f092da750 | |||
| 960c959f10 | |||
| 1a2700d527 | |||
| 8b92513a94 | |||
| d8a1ed32fb | |||
| 313c1a38f8 | |||
| e0da18162a | |||
| f35bbbe906 | |||
| f280794280 | |||
| 18b6ca8160 | |||
| b1193100b0 | |||
| e78132c031 | |||
| e4379f752e | |||
| d0aec34055 | |||
| 3c794d085a | |||
| 00ab3d7226 | |||
| 6e3761271d | |||
| 2bf11e74a2 | |||
| 53d5131244 | |||
| 73178412b0 | |||
| 2e4a3010f0 | |||
| de171954fe | |||
| 1a931e2f5e | |||
| f302689484 | |||
| f9f2aaf521 | |||
| af8832799f | |||
| e87b7120ac | |||
| 5d94c6d65d | |||
| 313ba3be94 | |||
| 91e931cbc7 | |||
| 484c28d442 | |||
| 78e7772ad5 | |||
| b3b6ddd5ba | |||
| 2f616517b5 | |||
| f6ab5fc0fd | |||
| afa1a44f97 | |||
| 53da52ee05 | |||
| 2434bc8f4d | |||
| f983eef46b | |||
| dcab4d2bfa | |||
| 3a5f651c30 | |||
| 26249ccbc0 | |||
| 405e66e7e7 | |||
| 5f2d1fad55 | |||
| 805b89d987 | |||
| d9b355d2c2 | |||
| e86cc2c4d5 | |||
| efa45ac4ed | |||
| da6038df30 | |||
| 313ad06704 | |||
| 8e2a8fdcb2 | |||
| 266e6cc8e1 | |||
| b3a1f75376 | |||
| e9ddfa6400 | |||
| 1e844a3143 | |||
| e46fda1c9e | |||
| e67bf74ac6 | |||
| 6b3452954e | |||
| 587a677ebc | |||
| d3986cf902 | |||
| 82f61328b2 | |||
| cbcb9923e7 | |||
| d972d0cd69 | |||
| 7cf4f75e74 | |||
| 6af6215e9e | |||
| 2f1b24518e | |||
| 729af79cc5 | |||
| 24d297ba79 | |||
| 8cc821fa9b | |||
| 5459990493 | |||
| 786b9eb948 | |||
| 5974bdcbb9 | |||
| 4e31167489 | |||
| b1dc2b306e | |||
| 8c85874006 | |||
| 1388380be8 | |||
| 8e299776fa | |||
| f690b29348 | |||
| 818dea52f3 | |||
| 9817537a2c | |||
| 47cf10d5fd | |||
| 1e71530fb4 | |||
| 51659e3404 | |||
| 22a3727798 | |||
| ef8fa5b5d5 | |||
| 8e45258f00 | |||
| e6050c81e6 | |||
| f4c2ca351b | |||
| 6015e30391 | |||
| ee4ceddc52 | |||
| d20ad3083e | |||
| e37ce12d57 | |||
| 6cad962159 | |||
| a742fcbffd | |||
| 9fbd8db5c9 | |||
| bd3973017c | |||
| 73de7bc29f | |||
| d7673dddb9 | |||
| 03c419d8b6 | |||
| 350dc3342d | |||
| d5041e7075 | |||
| 6d09aabddc | |||
| 75176687d7 | |||
| 1519c8784e | |||
| 86703c4df9 | |||
| 75d979c03a | |||
| f1f27d9a55 | |||
| b13b2a2b42 | |||
| ca30f6a01e | |||
| 2c3a8b21b9 | |||
| 7002518d0f | |||
| 79ea55aae4 | |||
| e9c5af3c45 | |||
| b43dd52cdc | |||
| e4f4a89339 | |||
| f1f69e1c78 | |||
| ae536816ee | |||
| 6cc1cb5ae5 | |||
| 805bf4dffe | |||
| 1753a38289 | |||
| a403bdac5b | |||
| 6636f49f13 | |||
| 98d1ae6536 | |||
| 23f7406095 | |||
| 2df204ba78 | |||
| 6f82742918 | |||
| c32726ec7e | |||
| 9ad0419530 | |||
| ffe85c7d4b | |||
| 21a29b977b | |||
| ef81faff5f | |||
| 4d44fae9ac | |||
| f9d548ae92 | |||
| f42e7f6287 | |||
| c4abfc8cbb | |||
| 344c0dceb4 | |||
| 30e7e7ae46 | |||
| c88efdea68 | |||
| ad1899abd9 | |||
| 057e0aaf64 | |||
| 072b4e1b61 | |||
| fe1f823e3a | |||
| dee09f0e62 | |||
| af581a1f2a | |||
| 71ccdd2fe5 | |||
| d123f62bdc | |||
| 98f041d7fd | |||
| 990187b70c | |||
| 0054ff1ab7 | |||
| 0764743fb9 | |||
| 250b88cfb5 | |||
| d9874a3140 | |||
| 47c81a9033 | |||
| 5e009f6002 | |||
| 9454bb4e1c | |||
| 5126bfbc0a | |||
| 6bbd9f50bc | |||
| 98bbc0b95c | |||
| 29c0f85c14 | |||
| 11974f29b2 | |||
| 365c29f1a1 | |||
| 2e31c3b92e | |||
| db1f46894e | |||
| 318a6ce7ea | |||
| 2da515b579 | |||
| e86d5f310f | |||
| 7ce2128b11 | |||
| 4a5c1d20a3 | |||
| 7b1b5aa452 | |||
| 693c89198f | |||
| 006adfaa84 | |||
| 2dd066d92c | |||
| f0381aab02 | |||
| 9b94605972 | |||
| e6515ce73c | |||
| a6bca8a4a5 | |||
| 97c2acd867 | |||
| c2861c6305 | |||
| 75c53e7b75 | |||
| 2490f1c985 | |||
| c81a7f7f0c | |||
| 7f89ef42b6 | |||
| 72eb4479ea | |||
| 77d6aa82bb | |||
| dbc9491a32 | |||
| bd7d632c66 | |||
| 2303ba2fbc | |||
| 0872610990 | |||
| e5ccaeb9e8 | |||
| a77b19d9d7 | |||
| 1e00a75273 | |||
| 9bb7d42086 | |||
| 88c18beb87 | |||
| 7052c3c5f7 | |||
| abdd3169e4 | |||
| f049671aa3 | |||
| 20286c8d74 | |||
| 6baaaaf783 | |||
| 6d73f377d3 | |||
| 2f18c57465 | |||
| 39fc9958ce | |||
| 2869d0f722 | |||
| 6b7e271ba8 | |||
| 7f0f89d624 | |||
| b498fbdd1b | |||
| bc68ffd15b | |||
| a856c75856 | |||
| 5c9a890972 | |||
| d444c164c2 | |||
| e524b7b26b | |||
| a161660022 | |||
| df5886f64e | |||
| 2c8be13241 | |||
| 85d61ef073 | |||
| 80ffd14c8c | |||
| aa1b72b62a | |||
| 836b5faa3e | |||
| e8561914b1 | |||
| 4e56397de2 | |||
| 116869304c | |||
| 565d7d13a8 | |||
| 4db9fc1777 | |||
| 3a779defdb | |||
| 5bad0e79de | |||
| a3e84e42be | |||
| 2cf2957cd5 | |||
| 901cb1fd20 | |||
| b85f86f35e | |||
| 3fce52f4e3 | |||
| 149e759f06 | |||
| 3d472009f2 | |||
| 98d8bd1ded | |||
| 73e55ee157 | |||
| 09b0c7c183 | |||
| 0d90e990da | |||
| 865feda955 | |||
| 0255dcd796 | |||
| cbd73eb665 | |||
| 4558ebe892 | |||
| 9be8ef4831 | |||
| 4ebe9e7979 | |||
| 7b3b24632e | |||
| 820a0b311f | |||
| e229437b9e | |||
| fa0df44386 | |||
| 5851351380 | |||
| 84ae903714 | |||
| 525b5dcf4c | |||
| f4f2c6dd81 | |||
| 69592d46fe | |||
| 87dab33026 | |||
| 8184015b34 | |||
| dddbec8577 | |||
| 94fe1d551e | |||
| f985c62668 | |||
| 9496e6ba33 | |||
| b0d4735d98 | |||
| e5d7b20d17 | |||
| a7d470ff86 | |||
| 024f7bb976 | |||
| 7f908f13d9 | |||
| 0970985b80 | |||
| ec094bd865 | |||
| 72e2a74cb9 | |||
| df3999c141 | |||
| ee7665b716 | |||
| 1510fb009d | |||
| 3e558911e4 | |||
| 8e9f05161d | |||
| d1877bf9de | |||
| 02b34018f4 | |||
| 34e2312fa5 | |||
| d72c172d31 | |||
| 49fe4d03ff | |||
| eff091cd97 | |||
| 8a5d48f39c | |||
| c4531a9c0e | |||
| e0efb39092 | |||
| fbab6c1ddf | |||
| acc5739dbd | |||
| 4812f46d4e | |||
| 15c4ebd523 | |||
| 5ac35edc3a | |||
| 983db9f225 | |||
| 86a65b062a | |||
| bffbf251f0 | |||
| 854864f008 | |||
| 45512be109 | |||
| 4a238482e8 | |||
| ee9241c634 | |||
| 462d59604b | |||
| 4ea026b835 | |||
| 125082430e | |||
| 415b9adb49 | |||
| b27566e158 | |||
| 33fb3ebfe0 | |||
| a89cb66083 | |||
| f518db10a5 | |||
| 3af0a51e62 | |||
| e3fcd06a86 | |||
| a2049a59d6 | |||
| 58f4e4bbd7 | |||
| 841625c1ac | |||
| 334b57e8d9 | |||
| 4bc6196a71 | |||
| e68bd489a6 | |||
| ac3a5b489a | |||
| ca3bb2dfe8 | |||
| 1dd61b0f86 | |||
| f15712c448 | |||
| b59c3dab04 | |||
| fe220e57b3 | |||
| aa74081aff | |||
| d170c71007 | |||
| 7c851f60d3 | |||
| 9c0fb985c1 | |||
| 6c6a6b3a1c | |||
| 19cdab0cd5 | |||
| 7c5395ddad | |||
| 2ff01baa21 | |||
| e6bb691886 | |||
| 2bed3cb1a2 | |||
| aebbc1c144 | |||
| 48a959accb | |||
| 6cfc268a27 | |||
| 40dd655abf | |||
| 342e17aa5a | |||
| 890e8ed154 | |||
| 9a267135c1 | |||
| c9f634b1d4 | |||
| 9b5d99078e | |||
| 53665b53d7 | |||
| 1629ac31d0 | |||
| e7e613f518 | |||
| 00782e4d6a | |||
| a9c191bb59 | |||
| 957b7ae81c | |||
| c72177cb58 | |||
| b04e84c09c | |||
| f79faf89f8 | |||
| 43f9e6bc25 | |||
| 7171662c11 | |||
| 1cbafb20d0 | |||
| eb66d74eb4 | |||
| 62c7e837f1 | |||
| 908a40bdc1 | |||
| 0414642fc6 | |||
| ccab546ab9 | |||
| ff8d2cf762 | |||
| f2860feacb | |||
| 387f8b7bf6 | |||
| 9586e247ac | |||
| 2cbb73d151 | |||
| 2a19fc5fb0 | |||
| d9ae9fb1cf | |||
| 998143109f | |||
| 461e80afd6 | |||
| 07b8df62f0 | |||
| b232691602 | |||
| 0b401d8914 | |||
| f504c68f58 | |||
| 4a404c0a45 | |||
| 3dba864d34 | |||
| 69695af4ac | |||
| 5becc5c309 | |||
| 6cfc007431 | |||
| 0ed19eeb72 | |||
| 37aae6e922 | |||
| 53042733a8 | |||
| fa70a30546 | |||
| 1d86211a3b | |||
| 9aec576490 | |||
| bf9502ac86 | |||
| bc53043e5c | |||
| 325834a1d7 | |||
| 68f806176d | |||
| 4288e5fc08 | |||
| cbebd173e3 | |||
| ed1cb467d0 | |||
| 0249249c48 | |||
| 907f1131c7 | |||
| 97d1a0a7af | |||
| ef9df63195 | |||
| 53030e4527 | |||
| c6074c0df7 | |||
| 627693d12d | |||
| a178b0149a | |||
| 17b02e954c | |||
| 19e07d6bf2 | |||
| 0dadfe419a | |||
| 5cd09b1cfb | |||
| 963cb4d5c8 | |||
| c95b124905 | |||
| 2f8e311836 | |||
| c1302ab112 | |||
| 0ba0b0ad23 | |||
| abee080986 | |||
| 9ff67ef64d | |||
| e9752ce604 | |||
| 2d22341ee6 | |||
| 0f7188c4c2 | |||
| 269f799e99 | |||
| 4a3a71749e | |||
| bd25005368 | |||
| 2af5cd1361 | |||
| 485762ff72 | |||
| 6d728ddd40 | |||
| d877231543 | |||
| ac92083505 | |||
| 83be4dd883 | |||
| e9261beb4c | |||
| f9576c4a32 | |||
| d3a6dd9385 | |||
| 27ca552ed8 | |||
| ee74aad32f | |||
| b3e3232bbd | |||
| 7984815e6e | |||
| 8a6b03a744 | |||
| b5a98e0321 | |||
| 7e1b6bbef4 | |||
| 26f14eda80 | |||
| 258a9d72f3 | |||
| 66721a13e4 | |||
| 334a28d8ce | |||
| c2a307320b | |||
| cfc379713a | |||
| cfea9b8090 | |||
| 6f7fc0d116 | |||
| f2d4fac8cd | |||
| c83211770f | |||
| 267c42d33f | |||
| 6ab46fc3d4 | |||
| 2edb54a390 | |||
| e8ba437845 | |||
| 09ff47960f | |||
| 1ed0baf300 | |||
| 33bce3542a | |||
| 71b24a55de | |||
| 73ddcd7ead | |||
| 0117462bf5 | |||
| 895869d16f | |||
| e73f083d86 | |||
| 7ae423541f | |||
| 3b99d4e120 | |||
| 2e0211f0f8 | |||
| 9910fd906e | |||
| 9b1d477e1c | |||
| 01736f5847 | |||
| ebd6ac409c | |||
| 05de944281 | |||
| ee65dedf4d | |||
| f8b6cee61b | |||
| 1154781c0b | |||
| 7e719a84d9 | |||
| 748fe1433d | |||
| 74de942d09 | |||
| fe0f322e98 | |||
| 8ff4398901 | |||
| 38af1f49cf | |||
| 6cfa174d56 | |||
| 04674429a9 | |||
| cd68e581a6 | |||
| 64185b666d | |||
| 8bb7f140af | |||
| ad50aac6b7 | |||
| 4901ad91e4 | |||
| bc754d907c | |||
| 443ab4fce8 | |||
| 12d121e876 | |||
| 54e7c78df6 | |||
| 3be30cf06b | |||
| 4f9cd8f96e | |||
| 5ee5fd5d7f | |||
| 7472b1e047 | |||
| bb21d778a0 | |||
| fa053e1172 | |||
| ea43217c2b | |||
| ede9a3cc00 | |||
| f9e74aada5 | |||
| 1f5d0d6f47 | |||
| d863baf4c7 | |||
| 68e74fee37 | |||
| 04aa7bd9b1 | |||
| 3ff7c8d1d4 | |||
| 0230f5d871 | |||
| 99c989d1da | |||
| 8f247814a4 | |||
| fde785ab90 | |||
| c30df89277 | |||
| 925b49e7dc | |||
| 08db1dce9e | |||
| 351d9fcacf | |||
| fc701ebdf3 | |||
| 6596484fb1 | |||
| aadfbadf35 | |||
| 82db0bf9bc | |||
| ce98b2ac63 | |||
| 394bb9911e | |||
| ea0e997bf5 | |||
| 431cb1cbf4 | |||
| 61d6ee9a86 | |||
| 82acf7ac18 | |||
| 1f5669aacb | |||
| 4a2f3352b7 | |||
| a9ca8beb87 | |||
| d25dab13ef | |||
| 85e8d01166 | |||
| 4ae5fca3ca | |||
| 2e4f021ab6 | |||
| 1beebb2eb5 | |||
| 94b388e3c9 | |||
| 43839c4d19 | |||
| 898e0a4524 | |||
| 9992b00c59 | |||
| d13c4ec9f3 | |||
| dd789080fd | |||
| 54d9cbc1bf | |||
| 83b9057a68 | |||
| b0f888e7b6 | |||
| 7635f9334d | |||
| dd0c9127e0 | |||
| 9bec7b8111 | |||
| 1d5b9be500 | |||
| ad38989a3a | |||
| 908e14ae23 | |||
| 792631d009 | |||
| b695e765a5 | |||
| 8966d8b567 | |||
| ad9ab4c15e | |||
| a47da49ee9 | |||
| 8b5a417459 | |||
| 68a03f5ec9 | |||
| f9c5429756 | |||
| 22953c181c | |||
| 6304827f3a | |||
| 3257d1297a | |||
| 9e7902c79e | |||
| 44fec40c5f | |||
| 23f9750b7a | |||
| 971a9cc630 | |||
| 5b47132eb5 | |||
| 2624ed0a45 | |||
| 9eed73ddd6 | |||
| bf47dadf80 | |||
| faa1bdc2f9 | |||
| dbe8af4393 | |||
| ea0f30f26e | |||
| 823e263e51 | |||
| 2821d374ea | |||
| c346cce82f | |||
| 116b195367 | |||
| 96eac159dc | |||
| 1f31372e84 | |||
| 6f1a591083 | |||
| 821d9bce88 | |||
| 82fbd7f7df | |||
| c4167b847e | |||
| 40fc786a46 | |||
| f88d8130a5 | |||
| aac4bbfd98 | |||
| b03be5374f | |||
| 527c482a9f | |||
| 46a8a6c4f5 | |||
| b88926bc0d | |||
| ba33687a2b | |||
| e71ce4bf36 | |||
| 174bea2604 | |||
| a62c95047c | |||
| b880f4c50a | |||
| c6292bcabc | |||
| 7971e6658a | |||
| 09fc884f2d | |||
| 09bfa592a6 | |||
| 0aab889bfe | |||
| c5d45806bd | |||
| 965643e13f | |||
| 32d0fd2cd1 | |||
| 8b48ef6483 | |||
| 039d89c800 | |||
| bec5356557 | |||
| 7b2035e21f | |||
| f4038f5df4 | |||
| 462c4f4112 | |||
| c812fbed5a | |||
| f060e8752a | |||
| 8c7d41bd85 | |||
| aadbd5f054 | |||
| 1981aae5ba | |||
| 1db70c3342 | |||
| 3683b78bd7 | |||
| 3295744a1a | |||
| f18f2ddeff | |||
| 31383c0c8e | |||
| 94de717857 | |||
| faf814d4e1 | |||
| d9a4057d06 | |||
| a62d8b80c9 | |||
| 5783232967 | |||
| 2c22145a5b | |||
| 8da8b543ab | |||
| 678e87764f | |||
| fff2e8e38d | |||
| 70ccb62a4c | |||
| f82a252c95 | |||
| f5fcfac64c | |||
| 021b754074 | |||
| 09b747bb1c | |||
| 94591c956a | |||
| 5505ebb621 | |||
| a3463b52bc | |||
| b27dfd4666 | |||
| c4ec04ca2a | |||
| 5c85586294 | |||
| dcaf8594e1 | |||
| c0c724e6dd | |||
| 389747604e | |||
| 79797814ad | |||
| 0202d24f66 | |||
| c584da75f3 | |||
| 10aad83bd6 | |||
| af9cfeac5e | |||
| 200d17fd13 | |||
| 447077e0c8 | |||
| d76afc09e4 | |||
| d43895dfea | |||
| cf90ddbda3 | |||
| 02e78e9bb7 | |||
| 950d235994 | |||
| 245fcbe19c | |||
| fe49e0bfd3 | |||
| 797214ef7d | |||
| 835af017ee | |||
| 90a28a5988 | |||
| 5f545d33fc | |||
| 57280ba606 | |||
| b4f82b8eee | |||
| 54111584c9 | |||
| 5ab9ac8eba | |||
| a93beae7e7 | |||
| 052553503c | |||
| 32954414b1 | |||
| ade6682a9a | |||
| c649f13a92 | |||
| 97df759fb5 | |||
| beb447b6d6 | |||
| 8f2c5d0ecd | |||
| 21f35fcb5b | |||
| 3009081c27 | |||
| fecb89c9f5 | |||
| 454277023d | |||
| fb6fdb1709 | |||
| 8a472229cc | |||
| 856addc8fb | |||
| dab9c8da43 | |||
| 41c5641e26 | |||
| 9cd73d687c | |||
| 9c838d673b | |||
| 3e79cacead | |||
| 9acddb2511 | |||
| 502ea0be0b | |||
| e5ab27b9c4 | |||
| fbf8417e5c | |||
| 83e4e6951f | |||
| 33292a72d4 | |||
| d20bccf25e | |||
| c9ec79739f | |||
| 12d162eeb9 | |||
| 300351689d | |||
| 46ad604c88 | |||
| e5212e79eb | |||
| 2b8a54a05a | |||
| 9d5addacb8 | |||
| 7967d77192 | |||
| 296c90df0d | |||
| ce3d531e5e | |||
| 136c22ef57 | |||
| 6e380e3a31 | |||
| 76cf5446d9 | |||
| 473f8bc215 | |||
| 716336bbb4 | |||
| 45dfa84bda | |||
| 84333ae50e | |||
| 61cd10c7e3 | |||
| 9fd48fcf10 | |||
| 5b27258c0b | |||
| ecf45ee1db | |||
| 25ec632a14 | |||
| f95bc451ff | |||
| 9f2cb94b43 | |||
| c05b51d43d | |||
| 6971a0a694 | |||
| 2895c56757 | |||
| dbaf5dadb9 | |||
| fbb6724e34 | |||
| 372e67c4c0 | |||
| 35657ae6ed | |||
| 3cda2cc5be | |||
| f96d2d6eb7 | |||
| 535c9262a4 | |||
| c9c302df63 | |||
| 2510dc1874 | |||
| e016287186 | |||
| 37e6d6cc04 | |||
| 131c72ebcd | |||
| 55bbae6806 | |||
| ebf89f3e77 | |||
| 11fccff25e | |||
| 7cee02385f | |||
| b5a96e031a | |||
| cbef298ff1 | |||
| 76bdb1c1fc | |||
| 93bfb202e6 | |||
| 4e7377cff8 | |||
| d8e03bfcc7 | |||
| f11a00a212 | |||
| 09dbdae01f | |||
| d2a21d7637 | |||
| 0417c47bae | |||
| 3213dd494f | |||
| b30b80cb50 | |||
| 9bdf39be02 | |||
| 0991815019 | |||
| 0aa38b0621 | |||
| b4eb06cd05 | |||
| af4ba244fc | |||
| bb6f2cbc1e | |||
| e5567ab0b4 | |||
| 7aaa215d3b | |||
| 7025a5f212 | |||
| 14ea07a5f1 | |||
| 183851cc85 | |||
| 8fe514be11 | |||
| 61ccbde085 | |||
| 848bfac50d | |||
| 3de5a6118d | |||
| e263e5f2fd | |||
| 6fede05b10 | |||
| c3159ed981 | |||
| 83eadf93f1 | |||
| b84df08623 | |||
| 42d61df6e0 | |||
| db85b0a744 | |||
| 50740c8b49 | |||
| d0d87f8050 | |||
| edfead56f4 | |||
| 5297335ca9 | |||
| cd95e12062 | |||
| 077be45205 | |||
| e3cb62754a | |||
| 327ec13e47 | |||
| 30dd302f5c | |||
| b9f4a17d6b | |||
| 7259f49533 | |||
| ca9cd67304 | |||
| 396d237e90 | |||
| e8e29dcc00 | |||
| 0cfe74866c | |||
| 2acf121fb1 | |||
| ea7ab68a48 | |||
| 4e8d8f57f5 | |||
| 74a2cc77c7 | |||
| 04e95788fd | |||
| 0b7cdb3930 | |||
| 645966a844 | |||
| 531428121a | |||
| fef15f220c | |||
| 8c42b6a80f | |||
| e5ef645c01 | |||
| ff2404a7b7 | |||
| aba0b3d378 | |||
| e2fb13a350 | |||
| 7ab37b1489 | |||
| b4b43fae6a | |||
| 7cfd84f434 | |||
| af4f6424be | |||
| f78a609709 | |||
| 5294032944 | |||
| 4ae0c51316 | |||
| c627cb8f82 | |||
| f1cb8ba336 | |||
| 058431aed0 | |||
| fa299bb703 | |||
| ffd02f547d | |||
| 7996611fbf | |||
| 283455973c | |||
| 0c047d46c0 | |||
| ba361a0de2 | |||
| b8e1a2ca30 | |||
| 79d6848e7d | |||
| aba3f7ed05 | |||
| 2b6d32acca | |||
| 2287dda4ea | |||
| 68aa043dfd | |||
| aa7a964a1d | |||
| 8096967c61 | |||
| 36968c543f | |||
| ee5cdf9d4b | |||
| 5a51cb75a8 | |||
| 5b77dc8fc2 | |||
| e142167816 | |||
| 72d0e65a9b | |||
| 7070a214ca | |||
| f2b5eff23d | |||
| 004288d779 | |||
| 21977374eb | |||
| b4cfc37ce7 | |||
| 8a97ff010e | |||
| 2b38d8da8d | |||
| 447569e1e0 | |||
| 3671b2e023 | |||
| 09e20fbf1a | |||
| f32029704b | |||
| cdf23a00d6 | |||
| acb4191993 | |||
| db5da36efe | |||
| b216663e3e | |||
| 88aa551f54 | |||
| 32ee2bd343 | |||
| 1873fbb643 | |||
| be2b60a3ee | |||
| 77823c63ee | |||
| 3c4ce069c1 | |||
| 8b69f3713a | |||
| 42b4f1ac6e | |||
| 2a37f91d19 | |||
| 5f5d424213 | |||
| 66b5128a08 | |||
| af9a2aea07 | |||
| 8f6259134c | |||
| 8c4bdeee46 | |||
| 249be91540 | |||
| 4d93bc2a86 | |||
| f96304dad4 | |||
| d687da72a6 | |||
| f73e7508bc | |||
| 1ce4297c3a | |||
| 7e47845ebb | |||
| 5de8b60886 | |||
| 20fbc851e3 | |||
| 364adc1165 | |||
| dfb0230147 | |||
| 28e89841c7 | |||
| 2e04b5cd6d | |||
| ff4253a4da | |||
| c498ea51c2 | |||
| 047a1aa17d | |||
| 1c8c15b707 | |||
| c755b03260 | |||
| b8a42c49a6 | |||
| 3844415e7d | |||
| 4db575f16f | |||
| 2d9ac463ec | |||
| 105abd33fc | |||
| 71a8d6bf70 | |||
| 6dfe20cd95 | |||
| 79bba50bb1 | |||
| a3ac6fd873 | |||
| b44b6bc0c1 | |||
| 9fc167b721 | |||
| 96a607e2d2 | |||
| 7f3d05d39c | |||
| cabb996dc2 | |||
| f19fe76dde | |||
| aa4b705aa9 | |||
| 85d3d20014 | |||
| 1fe09852ca | |||
| ae58601e2b | |||
| 7094455723 | |||
| 5089e18937 | |||
| 2654a5861d | |||
| 3321b2df4a | |||
| c91d1c8da8 | |||
| 8bbde67c3b | |||
| a35f4f2590 | |||
| f27c407599 | |||
| f74d481e92 | |||
| ebac5a5a8e | |||
| 8e3875a3ea | |||
| 0e853defeb | |||
| 868fce50dc | |||
| 3b30273c21 | |||
| ca98cb0859 | |||
| a6fa4a8023 | |||
| 0ae2743116 | |||
| e29baa357b | |||
| 92d95130d7 | |||
| 277cef10f8 | |||
| 673abc18bb | |||
| 16669d60fa | |||
| 08d4d6a09b | |||
| 2b1aa58bda | |||
| 56fb6aa8e1 | |||
| 8aea9fa6fa | |||
| 077ec3ef61 | |||
| 85d87a220e | |||
| 8a4b1a6001 | |||
| 44fb871dc5 | |||
| f881a67b0e | |||
| d503bb0496 | |||
| c46cecccd4 | |||
| 9241531a49 | |||
| 2523a7fc61 | |||
| 1a8a857f22 | |||
| 690486c4b2 | |||
| 0f9f372295 | |||
| b9fe05875a | |||
| 5c5f8bd576 | |||
| 8ec542234c | |||
| 901244927d | |||
| e29d9fcbe9 | |||
| 8572fff355 | |||
| c39bb1ed6f | |||
| ac5f0a0dd5 | |||
| fe9be81269 | |||
| 6893422d7e | |||
| 137b13e5ac | |||
| b69a2fd11a | |||
| e7b821d39a | |||
| c5806120ad | |||
| 6230c495fd | |||
| c8c4897df2 | |||
| 22ed668f9b | |||
| f5f0fb52a9 | |||
| 68c42ff3bd | |||
| d3716e2513 | |||
| 9f34050074 | |||
| 605d381c3c | |||
| ff796a6c08 | |||
| d4a4db1138 | |||
| 82f49159e0 | |||
| 10f1a829be | |||
| 4fe9b0dcc6 | |||
| 579777976e | |||
| 055def3eb4 | |||
| 9824f14ab0 | |||
| c99ca996b9 | |||
| a3121f37e9 | |||
| adad180a08 | |||
| 14471d7045 | |||
| d74439f1e3 | |||
| 1616a54f19 | |||
| c47fbcd90c | |||
| e091d8ec66 | |||
| 315965c292 | |||
| cbd8d650e5 | |||
| 87821ff9c6 | |||
| 15abcff1b9 | |||
| 38f8a0b6ae | |||
| d117ba3069 | |||
| 03e130cb18 | |||
| b24305e0c2 | |||
| 18c9082f51 | |||
| c4e2043622 | |||
| 43cfb9fa51 | |||
| f57e968395 | |||
| f9e4b0b66d | |||
| b6d1462174 | |||
| bfd330c431 | |||
| fab8c1a12f | |||
| 7a7ba29d66 | |||
| b761ce6c1b | |||
| 752991b1af | |||
| 3c8a40a335 | |||
| 2b24317b12 | |||
| 8dfed5b6dc | |||
| 6b600e6309 | |||
| 560b37e503 | |||
| ed36eb7322 | |||
| 1f8f0c5026 | |||
| 6112bc2ded | |||
| ca7d503b1a | |||
| f25e5ef65f | |||
| 6f73ec235e | |||
| c1dc1fefd7 | |||
| fcadebac35 | |||
| 30f3921399 | |||
| 54b85d14ed | |||
| 60cc78225f | |||
| f3ee29612d | |||
| aa2876adf4 | |||
| 9d6fedb8e5 | |||
| 6f4de9431a | |||
| 3c82684e3e | |||
| 0a86d8e186 | |||
| eb04a5c5ae | |||
| 2020482302 | |||
| 3b778e1a45 | |||
| a520d6aedd | |||
| 2d0572c6db | |||
| 9cd2a4b039 | |||
| 43e5728bab | |||
| 09b5b2c11e | |||
| 091a30280f | |||
| 7deb6833a7 | |||
| 824646c38c | |||
| 6f4487efdb | |||
| 3e78819c59 | |||
| efe82193b6 | |||
| c4a58941b2 | |||
| 1eb07c09de | |||
| fb726c9d59 | |||
| 757f9f3aa7 | |||
| b3d100de3c | |||
| 79625f8b11 | |||
| d81b8ee85a | |||
| 3703aad2f8 | |||
| 019634b25b | |||
| 03acae34f9 | |||
| c895a85254 |
+116
@@ -0,0 +1,116 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright 2017 - 2019 James E. King III
|
||||
# Copyright 2019 - 2021 Alexander Grund
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#
|
||||
# Generic Appveyor build script for boostorg repositories
|
||||
# See: https://github.com/boostorg/boost-ci/
|
||||
#
|
||||
# Instructions for customizing this script for your library:
|
||||
#
|
||||
# 1. Customize the compilers and language levels you want.
|
||||
# 2. If you have more than include/, src/, test/, example/, examples/,
|
||||
# benchmark/ or tools/ directories, set the environment variable DEPINST.
|
||||
# For example if your build uses code in "bench/" and "fog/" directories:
|
||||
# - DEPINST: --include bench --include fog
|
||||
# 3. Enable pull request builds in your boostorg/<library> account.
|
||||
#
|
||||
# That's it - the script will do everything else for you.
|
||||
#
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /bugfix\/.*/
|
||||
- /feature\/.*/
|
||||
- /fix\/.*/
|
||||
- /pr\/.*/
|
||||
|
||||
matrix:
|
||||
fast_finish: false
|
||||
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
|
||||
allow_failures:
|
||||
- MAYFAIL: true
|
||||
|
||||
environment:
|
||||
global:
|
||||
B2_CI_VERSION: 1
|
||||
GIT_FETCH_JOBS: 4
|
||||
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
|
||||
# to use the default for a given environment, comment it out; recommend you build debug and release however:
|
||||
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most
|
||||
# libraries that care about this exercise it in their Jamfiles...
|
||||
B2_ADDRESS_MODEL: 32,64
|
||||
B2_LINK: shared,static
|
||||
# B2_THREADING: threading=multi,single
|
||||
B2_VARIANT: release
|
||||
BOOST_DATE_TIME_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS: 1
|
||||
|
||||
matrix:
|
||||
- FLAVOR: Visual Studio 2017 C++2a Strict
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_CXXFLAGS: -permissive-
|
||||
B2_CXXSTD: 2a
|
||||
B2_TOOLSET: msvc-14.1
|
||||
|
||||
- FLAVOR: Visual Studio 2017 C++14/17
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_CXXSTD: 14,17
|
||||
B2_TOOLSET: msvc-14.1
|
||||
|
||||
- FLAVOR: clang-cl
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
B2_ADDRESS_MODEL: 64
|
||||
B2_CXXSTD: 11,14,17
|
||||
B2_TOOLSET: clang-win
|
||||
|
||||
- FLAVOR: Visual Studio 2015, 2013
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
B2_TOOLSET: msvc-12.0,msvc-14.0
|
||||
|
||||
- FLAVOR: Visual Studio 2008, 2010, 2012
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
B2_TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
B2_ADDRESS_MODEL: 32 # No 64bit support
|
||||
|
||||
- FLAVOR: cygwin (32-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
B2_ADDRESS_MODEL: 32
|
||||
B2_CXXSTD: 03,11,14,1z
|
||||
B2_THREADING: threadapi=pthread
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
- FLAVOR: cygwin (64-bit)
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
B2_ADDRESS_MODEL: 64
|
||||
B2_CXXSTD: 03,11,14,1z
|
||||
B2_THREADING: threadapi=pthread
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
- FLAVOR: mingw64
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
|
||||
B2_ADDRESS_MODEL: 64
|
||||
B2_CXXSTD: 03,11,14,17,2a
|
||||
B2_TOOLSET: gcc
|
||||
|
||||
install:
|
||||
- git clone --depth 1 https://github.com/boostorg/boost-ci.git C:\boost-ci-cloned
|
||||
# Copy ci folder if not testing Boost.CI
|
||||
- if NOT "%APPVEYOR_PROJECT_NAME%" == "boost-ci" xcopy /s /e /q /i /y C:\boost-ci-cloned\ci .\ci
|
||||
- rmdir /s /q C:\boost-ci-cloned
|
||||
- ci\appveyor\install.bat
|
||||
|
||||
build: off
|
||||
|
||||
test_script: ci\build.bat
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright 2019 - 2021 Alexander Grund
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# Sample codecov configuration file. Edit as required
|
||||
|
||||
codecov:
|
||||
max_report_age: off
|
||||
require_ci_to_pass: yes
|
||||
notify:
|
||||
# Increase this if you have multiple coverage collection jobs
|
||||
after_n_builds: 2
|
||||
wait_for_ci: yes
|
||||
|
||||
# Change how pull request comments look
|
||||
comment:
|
||||
layout: "reach,diff,flags,files,footer"
|
||||
|
||||
# Ignore specific files or folders. Glob patterns are supported.
|
||||
# See https://docs.codecov.com/docs/ignoring-paths
|
||||
ignore:
|
||||
- libs/date_time/test/
|
||||
- test
|
||||
@@ -0,0 +1,50 @@
|
||||
#
|
||||
# Copyright 2020-2021 Peter Dimov
|
||||
# Copyright 2021 Andrey Semashev
|
||||
# Copyright 2021-2024 Alexander Grund
|
||||
# Copyright 2022-2025 James E. King III
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# This workflow uses the Boost.CI reusable workflow which builds a variety of
|
||||
# configurations of your project, runs tests, and generates code coverage reports.
|
||||
#
|
||||
# To use it, copy this file into your repository as `.github/workflows/ci.yml` and
|
||||
# customize it appropriately.
|
||||
#
|
||||
---
|
||||
name: Boost.CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- bugfix/**
|
||||
- feature/**
|
||||
- fix/**
|
||||
- pr/**
|
||||
paths-ignore:
|
||||
- LICENSE
|
||||
- meta/**
|
||||
- README.md
|
||||
|
||||
jobs:
|
||||
call-boost-ci:
|
||||
name: Run Boost.CI
|
||||
uses: boostorg/boost-ci/.github/workflows/reusable.yml@master
|
||||
with:
|
||||
# no endian branches
|
||||
enable_multiarch: false
|
||||
# serialization has issues, not enough time to add suppressions
|
||||
enable_sanitizers: false
|
||||
# these compilers fail
|
||||
exclude_compiler: 'gcc-4.7,gcc-4.8,gcc-4.9,gcc-5,clang-3.5,clang-3.6,clang-3.7,clang-3.8'
|
||||
# the tests take a while; this reduces the load a bit and there isn't any C++20 specific code
|
||||
exclude_cxxstd: '98,03,0x,2a,20'
|
||||
secrets:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
|
||||
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
|
||||
@@ -0,0 +1,2 @@
|
||||
**/test_facet_file.out
|
||||
**/time_duration_serialization.*
|
||||
@@ -0,0 +1,4 @@
|
||||
# https://github.com/boostorg/serialization/issues/122
|
||||
vptr:/usr/include/c++/*/bits/ios_base.h
|
||||
# https://github.com/boostorg/serialization/issues/193
|
||||
# could not figure out how to suppress it
|
||||
@@ -0,0 +1,52 @@
|
||||
# Generated by `boostdep --cmake date_time`
|
||||
# Copyright 2020 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(boost_date_time VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_date_time
|
||||
src/gregorian/greg_month.cpp
|
||||
)
|
||||
|
||||
add_library(Boost::date_time ALIAS boost_date_time)
|
||||
|
||||
target_include_directories(boost_date_time PUBLIC include)
|
||||
|
||||
target_link_libraries(boost_date_time
|
||||
PUBLIC
|
||||
Boost::algorithm
|
||||
Boost::assert
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::io
|
||||
Boost::lexical_cast
|
||||
Boost::numeric_conversion
|
||||
Boost::range
|
||||
Boost::smart_ptr
|
||||
Boost::throw_exception
|
||||
Boost::tokenizer
|
||||
Boost::type_traits
|
||||
Boost::utility
|
||||
Boost::winapi
|
||||
)
|
||||
|
||||
target_compile_definitions(boost_date_time
|
||||
PUBLIC BOOST_DATE_TIME_NO_LIB
|
||||
PRIVATE BOOST_DATE_TIME_SOURCE
|
||||
)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(boost_date_time PUBLIC BOOST_DATE_TIME_DYN_LINK)
|
||||
else()
|
||||
target_compile_definitions(boost_date_time PUBLIC BOOST_DATE_TIME_STATIC_LINK)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,40 @@
|
||||
DateTime, part of the collection of [Boost C++ Libraries](http://github.com/boostorg), makes programming with dates and times as simple and natural as programming with strings and integers.
|
||||
|
||||
### License
|
||||
|
||||
Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
|
||||
|
||||
### Properties
|
||||
|
||||
* C++11
|
||||
* Header only
|
||||
|
||||
### Build Status
|
||||
|
||||
<!-- boost-ci/tools/makebadges.sh --repo date_time --appveyorbadge upf5c528fy09fudk --codecovbadge nDoh7t8f6g --coverity 14908 -->
|
||||
| Branch | GHA CI | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
|
||||
| :-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
|
||||
| [`master`](https://github.com/boostorg/date_time/tree/master) | [](https://github.com/boostorg/date_time/actions?query=branch:master) | [](https://ci.appveyor.com/project/cppalliance/date-time/branch/master) | [](https://scan.coverity.com/projects/boostorg-date_time) | [](https://codecov.io/gh/boostorg/date_time/tree/master) | [](https://pdimov.github.io/boostdep-report/master/date_time.html) | [](https://www.boost.org/doc/libs/master/libs/date_time) | [](https://www.boost.org/development/tests/master/developer/date_time.html) |
|
||||
| [`develop`](https://github.com/boostorg/date_time/tree/develop) | [](https://github.com/boostorg/date_time/actions?query=branch:develop) | [](https://ci.appveyor.com/project/cppalliance/date-time/branch/develop) | [](https://scan.coverity.com/projects/boostorg-date_time) | [](https://codecov.io/gh/boostorg/date_time/tree/develop) | [](https://pdimov.github.io/boostdep-report/develop/date_time.html) | [](https://www.boost.org/doc/libs/develop/libs/date_time) | [](https://www.boost.org/development/tests/develop/developer/date_time.html) |
|
||||
|
||||
### Directories
|
||||
|
||||
Note that the built library is only for build backward compatibility and contains no symbols. date_time is now header only.
|
||||
|
||||
| Name | Purpose |
|
||||
| --------- | --------------------------------------- |
|
||||
| `build` | build script for optional lib build |
|
||||
| `data` | timezone database |
|
||||
| `doc` | documentation |
|
||||
| `example` | use case examples |
|
||||
| `include` | headers |
|
||||
| `src` | source code for optional link library |
|
||||
| `test` | unit tests |
|
||||
| `xmldoc` | documentation source |
|
||||
|
||||
### More information
|
||||
|
||||
* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-date_time): Be sure to read the documentation first to see if it answers your question.
|
||||
* [Report bugs](https://github.com/boostorg/date_time/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
|
||||
* [Submit Pull Requests](https://github.com/boostorg/date_time/pulls) against the **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). Be sure to include tests proving your changes work properly.
|
||||
* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[date_time]` tag at the beginning of the subject line.
|
||||
@@ -0,0 +1,37 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2023-2024
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/algorithm//boost_algorithm
|
||||
/boost/assert//boost_assert
|
||||
/boost/config//boost_config
|
||||
/boost/core//boost_core
|
||||
/boost/io//boost_io
|
||||
/boost/lexical_cast//boost_lexical_cast
|
||||
/boost/numeric_conversion//boost_numeric_conversion
|
||||
/boost/range//boost_range
|
||||
/boost/smart_ptr//boost_smart_ptr
|
||||
/boost/throw_exception//boost_throw_exception
|
||||
/boost/tokenizer//boost_tokenizer
|
||||
/boost/type_traits//boost_type_traits
|
||||
/boost/utility//boost_utility
|
||||
/boost/winapi//boost_winapi ;
|
||||
|
||||
project /boost/date_time
|
||||
: common-requirements
|
||||
<include>include
|
||||
;
|
||||
|
||||
explicit
|
||||
[ alias boost_date_time : build//boost_date_time ]
|
||||
[ alias all : boost_date_time example test ]
|
||||
;
|
||||
|
||||
call-if : boost-library date_time
|
||||
: install boost_date_time
|
||||
;
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
# (C) Copyright 2002. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears
|
||||
# in all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
#
|
||||
#
|
||||
# Boost.date_time build
|
||||
#
|
||||
# To run all tests quietly: jam test
|
||||
#
|
||||
# Declares the following targets:
|
||||
# 1. libboost_date_time, a library to be linked with all
|
||||
# Boost.date_time modules
|
||||
#
|
||||
|
||||
# declare the location of this subproject relative to the root
|
||||
subproject libs/date_time/build ;
|
||||
|
||||
# comment the line below and comment out the line above to change to
|
||||
# 64 bit counted time implementation
|
||||
|
||||
local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG ;
|
||||
|
||||
|
||||
# Base names of the source files for libboost_date_time
|
||||
CPP_SOURCES =
|
||||
greg_month greg_weekday ;
|
||||
|
||||
dll boost_date_time : ../src/gregorian/$(CPP_SOURCES).cpp
|
||||
: <sysinclude>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
|
||||
: debug release
|
||||
;
|
||||
|
||||
lib boost_date_time : ../src/gregorian/$(CPP_SOURCES).cpp
|
||||
: <sysinclude>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
|
||||
: debug release
|
||||
;
|
||||
|
||||
+18
-30
@@ -1,36 +1,24 @@
|
||||
# (C) Copyright 2002. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears
|
||||
# in all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
# Copyright (c) 2002-2005 CrystalClear Software, Inc.
|
||||
# Use, modification and distribution is subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
#
|
||||
# Boost.date_time build and test Jamfile
|
||||
#
|
||||
# Based on boost.python Jamfile
|
||||
#
|
||||
# To run all tests quietly: jam test
|
||||
#
|
||||
# Declares the following targets:
|
||||
# 1. libboost_date_time, a static link library to be linked with all
|
||||
# Boost.date_time modules
|
||||
# date_time is now header only -- this file provides a stub for backward compatibility
|
||||
#
|
||||
|
||||
project boost/date_time
|
||||
|
||||
project
|
||||
: common-requirements <library>$(boost_dependencies)
|
||||
: requirements
|
||||
<define>DATE_TIME_INLINE <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
|
||||
: usage-requirements
|
||||
<define>DATE_TIME_INLINE <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
|
||||
<define>DATE_TIME_INLINE
|
||||
<link>shared:<define>BOOST_ALL_DYN_LINK=1
|
||||
: usage-requirements
|
||||
<define>DATE_TIME_INLINE
|
||||
<link>shared:<define>BOOST_DATE_TIME_DYN_LINK=1
|
||||
<define>BOOST_DATE_TIME_NO_LINK=1
|
||||
: source-location ../src
|
||||
;
|
||||
|
||||
#######################
|
||||
|
||||
#
|
||||
# Declare the boost date_time static link library
|
||||
#
|
||||
|
||||
# Base names of the source files for libboost_date_time
|
||||
local GREGORIAN_CPP_SOURCES = gregorian_types greg_month greg_weekday ;
|
||||
|
||||
lib boost_date_time : ../src/gregorian/$(GREGORIAN_CPP_SOURCES).cpp ;
|
||||
|
||||
#time examples
|
||||
# greg_month.cpp is now just a stub so that there is
|
||||
# still a boost_date_time library to link for backward compatibility
|
||||
lib boost_date_time : gregorian/greg_month.cpp ;
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
|
||||
The csv file containing the zone_specs used by the
|
||||
boost::local_time::tz_database is intended to be customized by the
|
||||
library user. When customizing this file (or creating your own) the
|
||||
file must follow a specific format.
|
||||
|
||||
This first line is expected to contain column headings and is therefore
|
||||
not processed by the tz_database.
|
||||
|
||||
Each record (line) must have eleven fields. Some of those fields can
|
||||
be empty. Every field (even empty ones) must be enclosed in double-quotes.
|
||||
Ex:
|
||||
"America/Phoenix" <- string enclosed in quotes
|
||||
"" <- empty field
|
||||
|
||||
Some fields represent a length of time. The format of these fields must be:
|
||||
"{+|-}hh:mm[:ss]" <- length-of-time format
|
||||
Where the plus or minus is mandatory and the seconds are optional.
|
||||
|
||||
Since some time zones do not use daylight savings it is not always necessary
|
||||
for every field in a zone_spec to contain a value. All zone_specs must have
|
||||
at least ID and GMT offset. Zones that use daylight savings must have all
|
||||
fields filled except: STD ABBR, STD NAME, DST NAME. You should take note
|
||||
that DST ABBR is mandatory for zones that use daylight savings (see field
|
||||
descriptions for further details).
|
||||
|
||||
|
||||
********* Fields and their description/details *********
|
||||
|
||||
* ID
|
||||
Contains the identifying string for the zone_spec. Any string will
|
||||
do as long as it's unique. No two ID's can be the same.
|
||||
|
||||
* STD ABBR
|
||||
* STD NAME
|
||||
* DST ABBR
|
||||
* DST NAME
|
||||
These four are all the names and abbreviations used by the time
|
||||
zone being described. While any string will do in these fields,
|
||||
care should be taken. These fields hold the strings that will be
|
||||
used in the output of many of the local_time classes.
|
||||
Ex:
|
||||
time_zone nyc = tz_db.time_zone_from_region("America/New_York");
|
||||
local_time ny_time(date(2004, Aug, 30), IS_DST, nyc);
|
||||
cout << ny_time.to_long_string() << endl;
|
||||
// 2004-Aug-30 00:00:00 Eastern Daylight Time
|
||||
cout << ny_time.to_short_string() << endl;
|
||||
// 2004-Aug-30 00:00:00 EDT
|
||||
|
||||
NOTE: The exact format/function names may vary - see local_time
|
||||
documentation for further details.
|
||||
|
||||
* GMT offset
|
||||
This is the number of hours added to utc to get the local time
|
||||
before any daylight savings adjustments are made. Some examples
|
||||
are: America/New_York offset -5 hours, & Africa/Cairo offset +2 hours.
|
||||
The format must follow the length-of-time format described above.
|
||||
|
||||
* DST adjustment
|
||||
The amount of time added to gmt_offset when daylight savings is in
|
||||
effect. The format must follow the length-of-time format described
|
||||
above.
|
||||
|
||||
#####################################################################
|
||||
##### TODO: more rule capabilities are needed - this portion of #####
|
||||
##### the tz_database is incomplete #####
|
||||
#####################################################################
|
||||
* DST Start Date rule
|
||||
This is a specially formatted string that describes the day of year
|
||||
in which the transition take place. It holds three fields of it's own,
|
||||
separated by semicolons.
|
||||
* The first field indicates the "nth" weekday of the month. The
|
||||
possible values are: 1 (first), 2 (second), 3 (third),
|
||||
4 (fourth), 5 (fifth), and -1 (last).
|
||||
* The second field indicates the day-of-week from 0-6 (Sun=0).
|
||||
* The third field indicates the month from 1-12 (Jan=1).
|
||||
|
||||
Examples are: "-1;5;9"="Last Friday of September",
|
||||
"2;1;3"="Second Monday of March"
|
||||
|
||||
* Start time
|
||||
Start time is the number of hours past midnight, on the day of the
|
||||
start transition, the transition takes place. More simply put, the
|
||||
time of day the transition is made (in 24 hours format). The format
|
||||
must follow the length-of-time format described above with the
|
||||
exception that it must always be positive.
|
||||
|
||||
* DST End date rule
|
||||
See DST Start date rule. The difference here is this is the day
|
||||
daylight savings ends (transition to STD).
|
||||
* End time
|
||||
Same as Start time.
|
||||
@@ -0,0 +1,520 @@
|
||||
"ID","STD ABBR","STD NAME","DST ABBR","DST NAME","GMT offset","DST adjustment","DST Start Date rule","Start time","DST End date rule","End time"
|
||||
"Africa/Abidjan","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Accra","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Addis_Ababa","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Algiers","CET","CET","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Asmara","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Asmera","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Bamako","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Bangui","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Banjul","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Bissau","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Blantyre","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Brazzaville","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Bujumbura","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Cairo","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Casablanca","WET","WET","WEST","WEST","+00:00:00","+01:00:00","2;0;7","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Africa/Ceuta","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Africa/Conakry","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Dakar","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Dar_es_Salaam","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Djibouti","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Douala","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/El_Aaiun","WET","WET","WEST","WEST","+00:00:00","+01:00:00","2;0;7","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Africa/Freetown","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Gaborone","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Harare","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Johannesburg","SAST","SAST","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Juba","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Kampala","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Khartoum","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Kigali","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Kinshasa","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Lagos","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Libreville","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Lome","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Luanda","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Lubumbashi","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Lusaka","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Malabo","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Maputo","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Maseru","SAST","SAST","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Mbabane","SAST","SAST","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Mogadishu","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Monrovia","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Nairobi","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Ndjamena","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Niamey","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Nouakchott","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Ouagadougou","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Porto-Novo","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Porto_Novo","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Sao_Tome","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Timbuktu","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Tripoli","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Tunis","CET","CET","","","+01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Africa/Windhoek","WAT","WAT","WAST","WAST","+01:00:00","+01:00:00","1;0;9","+02:00:00","1;0;4","+02:00:00"
|
||||
"America/Adak","HST","HST","HDT","HDT","-10:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Anchorage","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Anguilla","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Antigua","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Araguaina","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/Buenos_Aires","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/Catamarca","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/ComodRivadavia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/Cordoba","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/Jujuy","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/La_Rioja","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/Mendoza","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/Rio_Gallegos","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/Salta","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/San_Juan","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/San_Luis","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/Tucuman","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Argentina/Ushuaia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Aruba","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Asuncion","PYT","PYT","PYST","PYST","-04:00:00","+01:00:00","1;0;10","+00:00:00","-1;0;3","+00:00:00"
|
||||
"America/Atikokan","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Atka","HST","HST","HDT","HDT","-10:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Bahia","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Bahia_Banderas","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
|
||||
"America/Barbados","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Belem","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Belize","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Beulah","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Blanc-Sablon","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Blanc_Sablon","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Boa_Vista","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Bogota","COT","COT","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Boise","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Buenos_Aires","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Cambridge_Bay","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Campo_Grande","AMT","AMT","AMST","AMST","-04:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00"
|
||||
"America/Cancun","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Caracas","VET","VET","","","-04:30:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Catamarca","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Cayenne","GFT","GFT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Cayman","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Center","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Chicago","CST","Central Standard Time","CDT","Central Daylight Time","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Chihuahua","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
|
||||
"America/ComodRivadavia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Coral_Harbour","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Cordoba","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Costa_Rica","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Creston","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Cuiaba","AMT","AMT","AMST","AMST","-04:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00"
|
||||
"America/Curacao","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Danmarkshavn","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Dawson","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Dawson_Creek","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Denver","MST","Mountain Standard Time","MDT","Mountain Daylight Time","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Detroit","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Dominica","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Edmonton","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Eirunepe","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/El_Salvador","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Ensenada","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Fortaleza","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Fort_Wayne","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Glace_Bay","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Godthab","WGT","WGT","WGST","WGST","-03:00:00","+01:00:00","-1;6;3","+22:00:00","-1;6;10","+23:00:00"
|
||||
"America/Goose_Bay","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Grand_Turk","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Grenada","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Guadeloupe","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Guatemala","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Guayaquil","ECT","ECT","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Guyana","GYT","GYT","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Halifax","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Havana","CST","CST","CDT","CDT","-05:00:00","+01:00:00","2;0;3","+00:00:00","1;0;11","+01:00:00"
|
||||
"America/Hermosillo","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Indiana/Indianapolis","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Indiana/Knox","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Indiana/Marengo","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Indiana/Petersburg","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Indiana/Tell_City","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Indiana/Vevay","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Indiana/Vincennes","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Indiana/Winamac","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Indianapolis","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Inuvik","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Iqaluit","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Jamaica","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Jujuy","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Juneau","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Kentucky/Louisville","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Kentucky/Monticello","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Knox","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Knox_IN","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Kralendijk","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/La_Paz","BOT","BOT","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/La_Rioja","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Lima","PET","PET","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Los_Angeles","PST","Pacific Standard Time","PDT","Pacific Daylight Time","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Louisville","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Lower_Princes","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Maceio","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Managua","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Manaus","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Marengo","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Marigot","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Martinique","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Matamoros","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Mazatlan","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
|
||||
"America/Mendoza","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Menominee","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Merida","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
|
||||
"America/Metlakatla","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Mexico_City","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
|
||||
"America/Miquelon","PMST","PMST","PMDT","PMDT","-03:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Moncton","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Monterrey","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
|
||||
"America/Montevideo","UYT","UYT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Monticello","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Montreal","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Montserrat","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Nassau","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/New_Salem","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/New_York","EST","Eastern Standard Time","EDT","Eastern Daylight Time","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Nipigon","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Nome","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Noronha","FNT","FNT","","","-02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/North_Dakota/Beulah","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/North_Dakota/Center","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/North_Dakota/New_Salem","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Ojinaga","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Panama","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Pangnirtung","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Paramaribo","SRT","SRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Petersburg","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Phoenix","MST","Mountain Standard Time","","","-07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Port-au-Prince","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Porto_Acre","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Porto_Velho","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Port_au_Prince","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Port_of_Spain","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Puerto_Rico","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Rainy_River","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Rankin_Inlet","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Recife","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Regina","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Resolute","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Rio_Branco","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Rio_Gallegos","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Rosario","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Salta","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Santarem","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Santa_Isabel","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Santiago","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;8","+00:00:00","3;0;5","+00:00:00"
|
||||
"America/Santo_Domingo","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/San_Juan","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/San_Luis","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Sao_Paulo","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00"
|
||||
"America/Scoresbysund","EGT","EGT","EGST","EGST","-01:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+01:00:00"
|
||||
"America/Shiprock","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Sitka","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/St_Barthelemy","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/St_Johns","NST","NST","NDT","NDT","-03:30:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/St_Kitts","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/St_Lucia","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/St_Thomas","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/St_Vincent","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Swift_Current","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Tegucigalpa","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Tell_City","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Thule","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Thunder_Bay","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Tijuana","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Toronto","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Tortola","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Tucuman","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Ushuaia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Vancouver","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Vevay","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Vincennes","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Virgin","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"America/Whitehorse","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Winamac","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Winnipeg","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Yakutat","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"America/Yellowknife","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"Antarctica/Casey","AWST","AWST","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Antarctica/Davis","DAVT","DAVT","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Antarctica/DumontDUrville","DDUT","DDUT","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Antarctica/Macquarie","MIST","MIST","","","+11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Antarctica/Mawson","MAWT","MAWT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Antarctica/McMurdo","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00"
|
||||
"Antarctica/Palmer","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;8","+00:00:00","3;0;5","+00:00:00"
|
||||
"Antarctica/Rothera","ROTT","ROTT","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Antarctica/South_Pole","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00"
|
||||
"Antarctica/Syowa","SYOT","SYOT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Antarctica/Troll","UTC","UTC","CEST","CEST","+00:00:00","+02:00:00","-1;0;3","+01:00:00","-1;0;10","+03:00:00"
|
||||
"Antarctica/Vostok","VOST","VOST","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Arctic/Longyearbyen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Asia/Aden","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Almaty","ALMT","ALMT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Amman","EET","EET","EEST","EEST","+02:00:00","+01:00:00","1;5;4","+00:00:00","-1;5;10","+01:00:00"
|
||||
"Asia/Anadyr","ANAT","ANAT","","","+12:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Aqtau","AQTT","AQTT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Aqtobe","AQTT","AQTT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Ashgabat","TMT","TMT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Ashkhabad","TMT","TMT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Baghdad","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Bahrain","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Baku","AZT","AZT","","","+04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Bangkok","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Beirut","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00"
|
||||
"Asia/Bishkek","KGT","KGT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Brunei","BNT","BNT","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Calcutta","IST","IST","","","+05:30:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Chita","YAKT","YAKT","","","+09:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Choibalsan","CHOT","CHOT","CHOST","CHOST","+08:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00"
|
||||
"Asia/Chongqing","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Chungking","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Colombo","IST","IST","","","+05:30:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Dacca","BDT","BDT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Damascus","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;5;3","+00:00:00","-1;5;10","+00:00:00"
|
||||
"Asia/Dhaka","BDT","BDT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Dili","TLT","TLT","","","+09:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Dubai","GST","GST","","","+04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Dushanbe","TJT","TJT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Gaza","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;6;3","+01:00:00","3;5;10","+00:00:00"
|
||||
"Asia/Harbin","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Hebron","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;6;3","+01:00:00","3;5;10","+00:00:00"
|
||||
"Asia/Hong_Kong","HKT","HKT","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Hovd","HOVT","HOVT","HOVST","HOVST","+07:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00"
|
||||
"Asia/Ho_Chi_Minh","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Irkutsk","IRKT","IRKT","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Istanbul","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Asia/Jakarta","WIB","WIB","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Jayapura","WIT","WIT","","","+09:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Jerusalem","IST","IST","IDT","IDT","+02:00:00","+01:00:00","-1;5;3","+02:00:00","-1;0;10","+02:00:00"
|
||||
"Asia/Kabul","AFT","AFT","","","+04:30:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Kamchatka","PETT","PETT","","","+12:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Karachi","PKT","PKT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Kashgar","XJT","XJT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Kathmandu","NPT","NPT","","","+05:45:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Katmandu","NPT","NPT","","","+05:45:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Khandyga","YAKT","YAKT","","","+09:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Kolkata","IST","IST","","","+05:30:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Krasnoyarsk","KRAT","KRAT","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Kuala_Lumpur","MYT","MYT","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Kuching","MYT","MYT","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Kuwait","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Macao","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Macau","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Magadan","MAGT","MAGT","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Makassar","WITA","WITA","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Manila","PHT","PHT","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Muscat","GST","GST","","","+04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Nicosia","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Asia/Novokuznetsk","KRAT","KRAT","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Novosibirsk","NOVT","NOVT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Omsk","OMST","OMST","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Oral","ORAT","ORAT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Phnom_Penh","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Pontianak","WIB","WIB","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Pyongyang","KST","KST","","","+08:30:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Qatar","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Qyzylorda","QYZT","QYZT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Rangoon","MMT","MMT","","","+06:30:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Riyadh","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Saigon","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Sakhalin","SAKT","SAKT","","","+11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Samarkand","UZT","UZT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Seoul","KST","KST","","","+09:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Shanghai","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Singapore","SGT","SGT","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Srednekolymsk","SRET","SRET","","","+11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Taipei","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Tashkent","UZT","UZT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Tbilisi","GET","GET","","","+04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Tehran","IRST","IRST","IRDT","IRDT","+03:30:00","+01:00:00","3;1;3","+00:00:00","3;3;9","+00:00:00"
|
||||
"Asia/Tel_Aviv","IST","IST","IDT","IDT","+02:00:00","+01:00:00","-1;5;3","+02:00:00","-1;0;10","+02:00:00"
|
||||
"Asia/Thimbu","BTT","BTT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Thimphu","BTT","BTT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Tokyo","JST","JST","","","+09:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Ujung_Pandang","WITA","WITA","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Ulaanbaatar","ULAT","ULAT","ULAST","ULAST","+08:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00"
|
||||
"Asia/Ulan_Bator","ULAT","ULAT","ULAST","ULAST","+08:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00"
|
||||
"Asia/Urumqi","XJT","XJT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Ust-Nera","VLAT","VLAT","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Ust_Nera","VLAT","VLAT","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Vientiane","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Vladivostok","VLAT","VLAT","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Yakutsk","YAKT","YAKT","","","+09:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Yekaterinburg","YEKT","YEKT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Asia/Yerevan","AMT","AMT","","","+04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Atlantic/Azores","AZOT","AZOT","AZOST","AZOST","-01:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+01:00:00"
|
||||
"Atlantic/Bermuda","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"Atlantic/Canary","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Atlantic/Cape_Verde","CVT","CVT","","","-01:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Atlantic/Faeroe","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Atlantic/Faroe","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Atlantic/Jan_Mayen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Atlantic/Madeira","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Atlantic/Reykjavik","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Atlantic/South_Georgia","GST","GST","","","-02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Atlantic/Stanley","FKST","FKST","","","-03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Atlantic/St_Helena","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Australia/ACT","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/Adelaide","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/Brisbane","AEST","AEST","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Australia/Broken_Hill","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/Canberra","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/Currie","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/Darwin","ACST","ACST","","","+09:30:00","+00:00:00","","","","+00:00:00"
|
||||
"Australia/Eucla","ACWST","ACWST","","","+08:45:00","+00:00:00","","","","+00:00:00"
|
||||
"Australia/Hobart","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/LHI","LHST","LHST","LHDT","LHDT","+10:30:00","+00:30:00","1;0;10","+02:00:00","1;0;4","+02:00:00"
|
||||
"Australia/Lindeman","AEST","AEST","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Australia/Lord_Howe","LHST","LHST","LHDT","LHDT","+10:30:00","+00:30:00","1;0;10","+02:00:00","1;0;4","+02:00:00"
|
||||
"Australia/Melbourne","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/North","ACST","ACST","","","+09:30:00","+00:00:00","","","","+00:00:00"
|
||||
"Australia/NSW","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/Perth","AWST","AWST","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Australia/Queensland","AEST","AEST","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Australia/South","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/Sydney","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/Tasmania","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/Victoria","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Australia/West","AWST","AWST","","","+08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Australia/Yancowinna","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
|
||||
"Brazil/Acre","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Brazil/DeNoronha","FNT","FNT","","","-02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Brazil/East","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00"
|
||||
"Brazil/West","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Canada/Atlantic","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"Canada/Central","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"Canada/East-Saskatchewan","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Canada/Eastern","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"Canada/East_Saskatchewan","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Canada/Mountain","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"Canada/Newfoundland","NST","NST","NDT","NDT","-03:30:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"Canada/Pacific","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"Canada/Saskatchewan","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Canada/Yukon","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"Chile/Continental","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;8","+00:00:00","3;0;5","+00:00:00"
|
||||
"Chile/EasterIsland","EAST","EAST","EASST","EASST","-06:00:00","+01:00:00","2;6;8","+22:00:00","2;6;5","+22:00:00"
|
||||
"Etc/GMT","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Etc/Greenwich","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Etc/UCT","UCT","UCT","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Etc/Universal","UTC","UTC","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Etc/UTC","UTC","UTC","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Etc/Zulu","UTC","UTC","","","+00:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Europe/Amsterdam","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Andorra","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Athens","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Belfast","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Europe/Belgrade","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Berlin","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Bratislava","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Brussels","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Bucharest","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Budapest","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Busingen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Chisinau","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Copenhagen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Dublin","GMT","GMT","IST","IST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Europe/Gibraltar","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Guernsey","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Europe/Helsinki","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Isle_of_Man","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Europe/Istanbul","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Jersey","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Europe/Kaliningrad","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Europe/Kiev","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Lisbon","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Europe/Ljubljana","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/London","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
|
||||
"Europe/Luxembourg","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Madrid","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Malta","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Mariehamn","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Minsk","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Europe/Monaco","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Moscow","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Europe/Nicosia","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Oslo","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Paris","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Podgorica","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Prague","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Riga","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Rome","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Samara","SAMT","SAMT","","","+04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Europe/San_Marino","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Sarajevo","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Simferopol","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Europe/Skopje","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Sofia","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Stockholm","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Tallinn","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Tirane","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Tiraspol","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Uzhgorod","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Vaduz","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Vatican","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Vienna","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Vilnius","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Volgograd","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Europe/Warsaw","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Zagreb","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Europe/Zaporozhye","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
|
||||
"Europe/Zurich","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
|
||||
"Indian/Antananarivo","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Indian/Chagos","IOT","IOT","","","+06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Indian/Christmas","CXT","CXT","","","+07:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Indian/Cocos","CCT","CCT","","","+06:30:00","+00:00:00","","","","+00:00:00"
|
||||
"Indian/Comoro","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Indian/Kerguelen","TFT","TFT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Indian/Mahe","SCT","SCT","","","+04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Indian/Maldives","MVT","MVT","","","+05:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Indian/Mauritius","MUT","MUT","","","+04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Indian/Mayotte","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Indian/Reunion","RET","RET","","","+04:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Mexico/BajaNorte","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
|
||||
"Mexico/BajaSur","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
|
||||
"Mexico/General","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
|
||||
"Pacific/Apia","WSST","WSST","WSDT","WSDT","+13:00:00","+01:00:00","-1;0;9","+03:00:00","1;0;4","+04:00:00"
|
||||
"Pacific/Auckland","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00"
|
||||
"Pacific/Chatham","CHAST","CHAST","CHADT","CHADT","+12:45:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00"
|
||||
"Pacific/Chuuk","CHUT","CHUT","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Easter","EAST","EAST","EASST","EASST","-06:00:00","+01:00:00","2;6;8","+22:00:00","2;6;5","+22:00:00"
|
||||
"Pacific/Efate","VUT","VUT","","","+11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Enderbury","PHOT","PHOT","","","+13:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Fakaofo","TKT","TKT","","","+13:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Fiji","FJT","FJT","FJST","FJST","+12:00:00","+01:00:00","1;0;11","+02:00:00","3;0;1","+03:00:00"
|
||||
"Pacific/Funafuti","TVT","TVT","","","+12:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Galapagos","GALT","GALT","","","-06:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Gambier","GAMT","GAMT","","","-09:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Guadalcanal","SBT","SBT","","","+11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Guam","ChST","ChST","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Honolulu","HST","HST","","","-10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Johnston","HST","HST","","","-10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Kiritimati","LINT","LINT","","","+14:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Kosrae","KOST","KOST","","","+11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Kwajalein","MHT","MHT","","","+12:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Majuro","MHT","MHT","","","+12:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Marquesas","MART","MART","","","-09:30:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Midway","SST","SST","","","-11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Nauru","NRT","NRT","","","+12:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Niue","NUT","NUT","","","-11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Norfolk","NFT","NFT","","","+11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Noumea","NCT","NCT","","","+11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Pago_Pago","SST","SST","","","-11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Palau","PWT","PWT","","","+09:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Pitcairn","PST","PST","","","-08:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Pohnpei","PONT","PONT","","","+11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Ponape","PONT","PONT","","","+11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Port_Moresby","PGT","PGT","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Rarotonga","CKT","CKT","","","-10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Saipan","ChST","ChST","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Samoa","SST","SST","","","-11:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Tahiti","TAHT","TAHT","","","-10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Tarawa","GILT","GILT","","","+12:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Tongatapu","TOT","TOT","","","+13:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Truk","CHUT","CHUT","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Wake","WAKT","WAKT","","","+12:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Wallis","WFT","WFT","","","+12:00:00","+00:00:00","","","","+00:00:00"
|
||||
"Pacific/Yap","CHUT","CHUT","","","+10:00:00","+00:00:00","","","","+00:00:00"
|
||||
|
@@ -1,91 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Date-Time Terminology</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>Date-Time Terminology</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<p>
|
||||
The following are a number of terms relevant to the date-time domain.
|
||||
<P>
|
||||
<P>A taxonomy of temporal types:
|
||||
<UL>
|
||||
<LI><B>Timepoint</B> -- Specifier for a location in the time continuum.
|
||||
Similar to a number on a ruler.
|
||||
<LI><B>Timelength</B> -- A duration of time unattached to any point on the
|
||||
time continuum.
|
||||
<LI><B>Timeinterval</B> -- A duration of time attached to a specific point in
|
||||
the time continuum. </LI></UL>
|
||||
<P>And some other terms:
|
||||
<UL>
|
||||
<LI><B>Accuracy</B> -- A measure of error, the difference between the reading
|
||||
of a clock and the true time.
|
||||
<LI><B>Calendar System</B> -- A system for labeling time points with day level
|
||||
resolution.
|
||||
<LI><B>Clock Device</B> -- A software component (tied to some hardware) that
|
||||
provides the current date or time with respect to a calendar or clock system.
|
||||
<LI><B>Precision</B> -- A measure of repeatability of a clock.
|
||||
<LI><B>Resolution</B> -- A specification of the smallest representable
|
||||
duration (eg: 1 second, 1 century) for a clock/calendar system or temporal
|
||||
type.
|
||||
<LI><B>Stability</B> -- The property of a class which says that the underlying
|
||||
representation (implementation) associated with a particular (abstract) value
|
||||
will never change.
|
||||
<LI><B>Time System</B> -- A system for labeling time points with higher
|
||||
resolution than day-level. </LI></UL>
|
||||
<P>Some standard date-time terminology:
|
||||
<UL>
|
||||
<LI><B>Epoch</B> -- Starting time point of a calendar or clock system.
|
||||
<LI><B>DST -- Daylight savings time</B> - a local time adjustment made in some regions during the summer to shift the clock time of the daylight hours
|
||||
<LI><B>Time zone</B> -- A region of the earth that provides for a 'local time'
|
||||
defined by DST rules and UT offset.
|
||||
<LI><B>UTC Time</B> -- Coordinated Universal Time - Civil time system as
|
||||
measured at longitude zero. Kept adjusted to earth rotation by use of leap
|
||||
seconds. Also known as Zulu Time. Replaced the similar system known as
|
||||
Greenwich Mean Time. For more see <A
|
||||
href="http://aa.usno.navy.mil/faq/docs/UT.html">http://aa.usno.navy.mil/faq/docs/UT.html</A>
|
||||
|
||||
<LI><B>TAI Time</B> -- A high-accuracy monotonic (need better term) time
|
||||
system measured to .1 microsecond resolution by atomic clocks around the
|
||||
world. Not adjusted to earth rotation. For more see <A
|
||||
href="http://www.bipm.fr/enus/5_Scientific/c_time/time_server.html">http://www.bipm.fr/enus/5_Scientific/c_time/time_server.html</A>
|
||||
</LI></UL>
|
||||
<P>Some more experimental ones:
|
||||
<UL>
|
||||
<LI><B>Local Time</B> -- A time measured in a specific location of the
|
||||
universe.
|
||||
<LI><B>Time Label</B> -- A tuple that either completely or partially specifies
|
||||
a specific date-time with respect to a calendar or clock system. This is the
|
||||
year-month-day representation.
|
||||
<LI><B>Adjusting Time Length</B> -- A duration that represents varying
|
||||
physical durations depending on the moment in time. For example, a 1 month
|
||||
duration is typically not a fixed number of days and it depends on the date it
|
||||
is measured from to determine the actual length. </LI></UL>
|
||||
<P>These are design sorts of terms:
|
||||
<UL>
|
||||
<LI><B>Generation function</B> -- A function that generates a specific set of
|
||||
time points, lengths, or intervals based on one or more parameters. </LI></UL>
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Sat Oct 26 08:37:53 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Boost Date-Time Build-Compiler Information</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
<h1>Date-Time Build-Compiler Information</h1>
|
||||
<p> </p>
|
||||
<hr>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<a href="#overview">Overview</a> --
|
||||
<a href="#options">Compilation Options</a> --
|
||||
<a href="#portability">Compiler/Portability Notes</a> --
|
||||
<a href="#directory">Directory Structure</a> --
|
||||
<a href="#required">Required Boost Libraries</a>
|
||||
<p>
|
||||
<H2><a name="overview">Overview</a></H2>
|
||||
<p>
|
||||
The library has several functions that require the creation of a library file.
|
||||
The Jamfile in the build directory will produce a library
|
||||
(<font class="bold">libboost_date_time</font>) that contains these functions.
|
||||
<p>
|
||||
<H2><a name="options">Compilation Options</a></H2>
|
||||
<p>
|
||||
By default the posix_time system uses a 64 bit integer and a 32 bit
|
||||
integer internally to provide nano-second level resolutions. As
|
||||
an alternative, a single 64 bit integer can be used to provide a
|
||||
microsecond level resolution. This alternative implementation
|
||||
may provide better performance and more compact memory usage
|
||||
for many applications that do not require nano-second resolutions.
|
||||
<p>
|
||||
The variable <b>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG</b>, as defined in
|
||||
build/Jamfile, selects between these options. To select the 64 bit
|
||||
integer implementation simply remove this define from the Jamfile.
|
||||
<p>
|
||||
<H2><a name="portability">Compiler/Portability Notes</a></H2>
|
||||
<p>
|
||||
The Boost Date-Time library has been built and tested with many compilers.
|
||||
However, some compilers and standard libraries have issues. While some
|
||||
of these issues can be worked around, others are difficult to work
|
||||
around. The following compilers fully support all aspects of the library:
|
||||
<ul>
|
||||
<li>GCC 3.0.3 on Linux
|
||||
<li>GCC 3.1 (cygwin)
|
||||
<li>MSVC 7
|
||||
</ul>
|
||||
<p>
|
||||
In particular, a lack of support for standard locales limits the ability
|
||||
of the library to support iostream based input output. For these
|
||||
compilers a set of more limited string based input-output is provided.
|
||||
|
||||
The compilers/stadard libraries with this limitation include:
|
||||
<p>
|
||||
<ul>
|
||||
<li>GCC 2.9x on Linux
|
||||
<li>Borland 5.1.1 and 5.6
|
||||
<li>MSVC 6 SP5
|
||||
</ul>
|
||||
|
||||
Other compilers such as Comeau and Metroworks have been tested
|
||||
sucessfully with earlier versions of the library.
|
||||
|
||||
<p>
|
||||
<H2><a name="directory">Directory Structure</a></H2>
|
||||
<p>
|
||||
The date_time directory structure has been changed for boost submission.
|
||||
<p>
|
||||
The directory tree has the following structure:
|
||||
<pre>
|
||||
/boost/date_time -- common headers and template code
|
||||
/boost/date_time/gregoran -- gregorian calendar system header files
|
||||
/boost/date_time/posix_time -- posix time system headers
|
||||
/libs/date_time/build -- build files and output directory
|
||||
/libs/date_time/test -- test battery for generic code
|
||||
/libs/date_time/test/gregorian -- test battery for the gregorian system
|
||||
/libs/date_time/test/posix_time -- test battery for the posix_time system
|
||||
/libs/date_time/examples/posix_time -- time example programs
|
||||
/libs/date_time/examples/gregorian -- nifty example programs
|
||||
/libs/date_time/src/gregorian -- cpp files for libboost_date_time
|
||||
/libs/date_time/src/posix_time -- empty (one file, but no source code...)
|
||||
</pre>
|
||||
<p>
|
||||
|
||||
<H2><a name="required">Required Boost Libraries</a></H2>
|
||||
|
||||
<p>
|
||||
The library depends on
|
||||
<ul>
|
||||
<li><a href="../../tokenizer/index.htm">boost.tokenizer</a>,
|
||||
<li><a href="../../integer/cstdint.htm">boost.integer(cstdint)</a>,
|
||||
<li><a href="../../utility/operators.htm">boost.operators</a>, and
|
||||
<li><a href="../../conversion/lexical_cast.htm">boost::lexical_cast</a>
|
||||
</ul>
|
||||
so at least these libraries need to be installed.
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Sun Jan 19 16:22:27 MST 2003
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,94 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Date-Time Concepts - Calculation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>Date-Time Concepts - Calculation</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<a href="#timepoints">Timepoints</a> --
|
||||
<a href="#durations">Durations</a> --
|
||||
<a href="#intervals">Interval</a> --
|
||||
<a href="#special">Special Cases</a>
|
||||
<p>
|
||||
|
||||
<h2><a name="timepoints">Timepoints</a></h2>
|
||||
|
||||
<p>
|
||||
This section describes some of basic arithmetic rules that can be performed with timepoints.
|
||||
|
||||
<PRE>
|
||||
Timepoint + Duration --> Timepoint
|
||||
Timepoint - Duration --> Timepoint
|
||||
|
||||
Duration + Timepoint --> Undefined
|
||||
Duration - Timepoint --> Undefined
|
||||
|
||||
Timepoint + Timepoint --> Undefined
|
||||
Timepoint - Timepoint --> Duration
|
||||
</PRE>
|
||||
<p>
|
||||
<h2><a name="durations">Durations</a></h2>
|
||||
<p>
|
||||
This section describes standard operations for a time duration.
|
||||
<PRE>
|
||||
Duration + Duration --> Duration
|
||||
Duration - Duration --> Duration
|
||||
|
||||
Duration * Integer --> Duration
|
||||
Integer * Duration --> Duration
|
||||
|
||||
Duration(∞) * Integer --> Duration(∞)
|
||||
Duration(∞)/Integer --> Duration(∞)
|
||||
</PRE>
|
||||
<p>
|
||||
|
||||
|
||||
<p>
|
||||
<h2><a name="intervals">Intervals</a></h2>
|
||||
<p>
|
||||
Here are the "operations" supported by intervals. They are based on half-open
|
||||
range.
|
||||
|
||||
<PRE>
|
||||
//These can be defined by either of 2 Timepoints or a Timepoint and Duration
|
||||
Timeinterval intersects Timeinterval --> bool
|
||||
Timeinterval intersection Timeinterval --> Timeperiod //results undefined if no intersection
|
||||
Timeinterval contains Timepoint --> bool
|
||||
Timeinterval contains Timeinterval --> bool
|
||||
Timeinterval shift Duration --> shift start and end by duration amount
|
||||
|
||||
</PRE>
|
||||
|
||||
<p>
|
||||
<h2><a name="special">Special Cases</a></h2>
|
||||
|
||||
<P>In general special values such as Not A Date Time (NADT) and infinity should follow rules like floating point values. Note that it should be possible to
|
||||
configure NADT based systems to throw an exception instead of result in NADT.
|
||||
<PRE>
|
||||
Timepoint(NADT) + Duration --> Timepoint(NADT)
|
||||
Timepoint(∞) + Duration --> Timepoint(∞)
|
||||
Timepoint + Duration(∞) --> Timepoint(∞)
|
||||
Timepoint - Duration(∞) --> Timepoint(-∞)
|
||||
</PRE>
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Sat Oct 26 07:12:02 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Overall Design Goals</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>Overall Design Goals</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<table border="1" width="95%" >
|
||||
<tr><td>Category</td><td>Description</td><td>Functions</td></tr>
|
||||
<tr><td>Interfaces</td>
|
||||
<td>Provide concrete classes for manipulation of dates and times</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>date, time, date_duration, time_duration, date_period, time_period, etc
|
||||
<li>support for infinity - positive infinity, negative infinity
|
||||
<li>iterators over time and date ranges
|
||||
<li>allow date and time implemenations to be separate as much as possible
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Calculation</td>
|
||||
<td>Provide a basis for performing efficient time calculations </td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>days between dates
|
||||
<li>durations of times
|
||||
<li>durations of dates and times together
|
||||
</ul>
|
||||
</td></tr>
|
||||
<tr><td>Representation Flexibility</td>
|
||||
<td>Provide the maximum possible reusability and flexibility</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>traits based customization of internal
|
||||
representations for size versus resolution control
|
||||
<li>Allowing the use of different epochs and resolution
|
||||
(eg: seconds versus microseconds, dates starting at the
|
||||
year 2000 versus dates starting in 1700)
|
||||
<li>Options for configuring unique calendar
|
||||
representations (Gregorian + others)
|
||||
<li> the use of Julian Day number and the conversion between this and the Gregorian/Julian calendar date
|
||||
<li>Allow for flexible adjustments including
|
||||
leap seconds
|
||||
</ul>
|
||||
<tr><td>Date Calculations</td>
|
||||
<td>Provide tools for date calculations</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>provide basis for calculation of complex event specs like holidays
|
||||
<li>calendar to calendar conversions
|
||||
<li>provide for ability to extend to new calendar systems
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>Time Calculations</td>
|
||||
<td>Provide concrete classes for manipulation of time</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>provide the ability to handle cross time-zone issues
|
||||
<li>provide adjustments for daylight savings time (summer time)
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>Clock Interfaces</td>
|
||||
<td>Provide classes for retrieving time current time</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>access to a network / high resolution time sources
|
||||
<li>retrieving the current date time information to populate classes
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>I/O Interfaces</td>
|
||||
<td>Provide input and output for time including</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>multi-lingual support
|
||||
<li>provide ISO8601 compliant time facet
|
||||
<li>use I/O facets for different local behavior
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Wed Aug 21 15:42:19 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,200 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Date-Time References</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>Date-Time References</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<p>
|
||||
The following are a number of references and sources of information about the
|
||||
date-time domain.
|
||||
<P>
|
||||
<UL>
|
||||
<LI><a href="#dateref">Date References</a></LI>
|
||||
<LI><a href="#timeref">Time References</a></LI>
|
||||
<LI><a href="#othercpp">Other C/C++ Libraries</a></LI>
|
||||
<LI><a href="#java">JAVA Date-Time Libraries</a></LI>
|
||||
<LI><a href="#scripting">Scriping Language Libraries</a></LI>
|
||||
<LI><a href="#commercial">Related Commerical and Fanciful Pages</a></LI>
|
||||
<LI><a href="#resolution">Resolution, Precision, and Accuracy</a></LI>
|
||||
</UL>
|
||||
<HR>
|
||||
<H3><a name="dateref">Date Calendar References</a></H3>
|
||||
<P>
|
||||
<UL>
|
||||
<LI>ISO 8601 date time standard -- <A
|
||||
href="http://www.cl.cam.ac.uk/~mgk25/iso-time.html">Summary by Markus Kuhn</A>
|
||||
|
||||
<LI><A
|
||||
href="http://emr.cs.iit.edu/home/reingold/calendar-book/second-edition/">Calendrical
|
||||
Calculations</A> book by Reingold & Dershowitz
|
||||
<LI>Calendar FAQ by Claus Tøndering <A
|
||||
href="http://www.pauahtun.org/CalendarFAQ/cal/calendar24.html">[html]</A><A
|
||||
href="http://www.pauahtun.org/CalendarFAQ/cal/calendar24.pdf">[pdf]</A>
|
||||
<LI>Calendar zone <A
|
||||
href="http://www.calendarzone.com/">http://www.calendarzone.com/</A>
|
||||
<LI><A href="http://www.w3.org/TR/xmlschema-2/#dateTime">XML schema for date
|
||||
time</A>
|
||||
<LI>Will Linden's <A href="http://www.ecben.net/calendar.shtml">Calendar
|
||||
Links</A>
|
||||
<LI><A href="http://www21.brinkster.com/lonwolve/melt/index.htm">XMAS calendar
|
||||
melt</A> </LI></UL>
|
||||
<HR>
|
||||
|
||||
<H3><a name="timeref">Time</a></H3>
|
||||
<UL>
|
||||
<LI>Martin Folwer on time patterns
|
||||
<UL>
|
||||
<LI><A
|
||||
href="http://www.aw.com/cseng/titles/0-201-89542-0/apsupp/events2-1.html">Recurring
|
||||
Events for Calendars</A>
|
||||
<LI>Patterns for things that <A
|
||||
href="http://martinfowler.com/ap2/timeNarrative.html">Change with time</A>
|
||||
</LI></UL></LI></UL>
|
||||
<P>
|
||||
<UL>
|
||||
<LI>US National Institute of Standards and Technology <A
|
||||
href="http://nist.time.gov/exhibits.html">Time Exhibits</A>
|
||||
<LI>Network Time Protocol at <A href="http://www.ntp.org/">NTP.org</A>
|
||||
<LI>US Navy <A href="http://tycho.usno.navy.mil/systime.html">Systems of
|
||||
Time</A>
|
||||
<LI><A
|
||||
href="http://www.bipm.fr/enus/5_Scientific/c_time/time_1.html">International
|
||||
Atomic Time</A>
|
||||
<LI><A
|
||||
href="http://beta.zyprexia.com/docs/pgsql/user/datatype1130.htm">Date-Time
|
||||
type PostgreSQL</A> User Guide </LI></UL>
|
||||
<P>
|
||||
<HR>
|
||||
|
||||
<H3><a name="othercpp">Other C/C++ Libraries</a></H3>
|
||||
<UL>
|
||||
<LI><A href="http://www.cplusplus.com/ref/ctime/index.html">ctime C
|
||||
</A>Standard library reference at cplusplus.com
|
||||
<LI><A href="http://www.cl.cam.ac.uk/~mgk25/c-time/">XTime C extension</A>
|
||||
proposal
|
||||
<LI><A
|
||||
href="http://david.tribble.com/text/c0xcalendar.html#author-info">Another C
|
||||
library extension proposal</A> by David Tribble
|
||||
<LI><A href="http://cr.yp.to/libtai.html">libTAI</A> is a C based time library
|
||||
|
||||
<LI><A href="http://www.twinsun.com/tz/tz-link.htm">Time Zone Database</A> C
|
||||
library for managing timezones/places
|
||||
<LI>International Components for Unicode by IBM (open source)
|
||||
<UL>
|
||||
<LI><A
|
||||
href="http://oss.software.ibm.com/icu/userguide/dateCalendar.html">Calendar
|
||||
Class</A>
|
||||
<LI><A href="http://oss.software.ibm.com/icu/userguide/dateTime.html">Date
|
||||
Time Services</A>
|
||||
<LI><A
|
||||
href="http://oss.software.ibm.com/icu/userguide/dateTimezone.html">Time Zone
|
||||
Class</A>
|
||||
<LI><A
|
||||
href="http://oss.software.ibm.com/icu/userguide/formatDateTime.html">Date-Time
|
||||
Formatting</A>
|
||||
</UL>
|
||||
<LI><A
|
||||
href="http://ringside.arc.nasa.gov/www/toolkits/julian_13/aareadme.html">Julian
|
||||
Library in C by Mark Showalter -- NASA</A> </LI></UL>
|
||||
<P>
|
||||
<P>
|
||||
<HR>
|
||||
|
||||
<H3><a name="java">JAVA Date & Time Library Quick Reference</a></H3>
|
||||
<P>
|
||||
<UL>
|
||||
<LI><A
|
||||
href="http://java.sun.com/products/jdk/1.1/docs/api/java.util.Calendar.html#_top_">Calendar
|
||||
class </A>
|
||||
<LI><A
|
||||
href="http://java.sun.com/products/jdk/1.1/docs/api/java.util.GregorianCalendar.html#_top_">Gregorian
|
||||
calendar</A>
|
||||
<LI><A
|
||||
href="http://java.sun.com/products/jdk/1.1/docs/api/java.util.Date.html">Date
|
||||
class</A>
|
||||
<LI><A
|
||||
href="http://java.sun.com/products/jdk/1.1/docs/api/java.sql.Time.html#_top_">sql.time
|
||||
class</A>
|
||||
<LI><A
|
||||
href="http://java.sun.com/products/jdk/1.1/docs/api/java.text.DateFormatSymbols.html#_top_">Date
|
||||
format symbols</A>
|
||||
<LI><A
|
||||
href="http://java.sun.com/products/jdk/1.1/docs/api/java.text.DateFormat.html#_top_">Date
|
||||
format</A>
|
||||
<LI><A
|
||||
href="http://java.sun.com/products/jdk/1.1/docs/api/java.text.SimpleDateFormat.html#_top_">Simple
|
||||
Date Format</A>
|
||||
<LI><A
|
||||
href="http://java.sun.com/products/jdk/1.1/docs/api/java.util.SimpleTimeZone.html#_top_">Simple
|
||||
Time Zone</A> </LI></UL>
|
||||
<HR>
|
||||
|
||||
<H3><a name="scripting">Scripting Language Libraries</a></H3>
|
||||
<UL>
|
||||
<LI>A python date library <A
|
||||
href="http://www.lemburg.com/files/python/mxDateTime.html">MX Date Time</A>
|
||||
<LI>Perl date-time
|
||||
<UL>
|
||||
<LI><A
|
||||
href="http://search.cpan.org/Catalog/Data_and_Data_Type/Date/">Date-Time
|
||||
packages at CPAN</A>
|
||||
<LI><A
|
||||
href="http://search.cpan.org/doc/TWEGNER/Date-Calc-4.3-bin56Mac/Calc.pm">Date::Calc</A>
|
||||
at CPAN
|
||||
<LI><A
|
||||
href="http://search.cpan.org/doc/MORTY/DateConvert-0.16/Convert.pm">Date::Convert</A>
|
||||
calendar conversions at CPAN </LI></UL>
|
||||
<LI>A PHP library <A
|
||||
href="http://vlib.activefish.com/docs/vlibDate.html">Vlib Date Library</A>
|
||||
</UL>
|
||||
|
||||
<HR>
|
||||
|
||||
<H3><a name="commercial">Related Commercial and Fanciful Pages</a></H3>
|
||||
<UL>
|
||||
<LI><A href="http://www.leapsecond.com/java/gpsclock.htm">Leapsecond.com
|
||||
time</A> page
|
||||
<LI><A href="http://www.worldtimeserver.com/">World Time Server / TZ
|
||||
database</A>
|
||||
<LI><A href="http://www.longnow.org/10kclock/clock.htm">10000 year clock</A>
|
||||
at Long Now Foundation
|
||||
<LI><A href="http://www.timezonesforpcs.com/">Timezones for PCs</A> </LI></UL>
|
||||
<HR>
|
||||
|
||||
<H3><a name="resolution">Resolution, Precision, and Accuracy</a></H3>
|
||||
<UL>
|
||||
<LI>Definitions with pictures from <A
|
||||
href="http://metrologyforum.tm.agilent.com/specs.shtml">Agilent
|
||||
Technologies</A>
|
||||
<LI>Another set of pictures from <A
|
||||
href="http://www.teamlabs.com/catalog/performance.asp">Team Labs</A>
|
||||
<LI>Definitions from <A
|
||||
href="http://www.solent.ac.uk/hydrography/notes/errorthe/accuracy.htm">Southampton
|
||||
Institute</A>
|
||||
<LI>Definitions from <A
|
||||
href="http://www.newport.com/Support/Tutorials/OptoMech/om4a.asp">Newport
|
||||
Corporation</A> in the context of instrumentation </LI></UL>
|
||||
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Thu Sep 5 07:32:51 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Date-Time Concepts - Theoretical Foundations</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
<h1>Tradeoffs: Stability, Predictability, and Approximations</h1>
|
||||
<p> </p>
|
||||
<hr>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
|
||||
<H2>Unavoidable Trade-offs</H2>
|
||||
|
||||
<p>
|
||||
The library does its best to provide everything a user could want, but there are certain inherent constraints that limit what <i>any</i> temporal library can do. Specifically, a user much choose which two of the following three capabilities are desired in any particular application:
|
||||
<UL>
|
||||
<li>exact agreement with wall-clock time
|
||||
<li>accurate math, e.g. duration calculations
|
||||
<li>ability to handle timepoints in the future
|
||||
</UL>
|
||||
Some libraries may implicitly promise to deliver all three, but if you actually put them to the test, only two can be true at once. This limitation is not a deficiency in the design or implementation of any particular library; rather it is a consequence of the way different time systems are defined by international standards. Let's look at each of the three cases:
|
||||
<p>
|
||||
If you want exact agreement with wall-clock time, you must use either UTC or local time. If you compute a duration by subtracting one UTC time from another and you want an answer accurate to the second, the two times must not be too far in the future because leap seconds affect the count but are only determined about 6 months in advance. With local times a future duration calculation could be off by an entire hour, since legislatures can and do change DST rules at will.
|
||||
<p>
|
||||
If you want to handle wall-clock times in the future, you won't be able (in the general case) to calculate exact durations, for the same reasons described above.
|
||||
<p>
|
||||
If you want accurate calculations with future times, you will have to use TAI or an equivalent, but the mapping from TAI to UTC or local time depends on leap seconds, so you will not have exact agreement with wall-clock time.
|
||||
<p>
|
||||
<H2>Stability, Predictability, and Approximations</H2>
|
||||
|
||||
<p>
|
||||
Here is some underlying theory that helps to explain what's going on.
|
||||
Remember that a temporal type, like any abstract data type (ADT),
|
||||
is a set of values together with operations on those values.
|
||||
<p>
|
||||
<H3>Stability</H3>
|
||||
|
||||
<p>
|
||||
The representation of a type is <i>stable</i> if the bit pattern associated with a given value does not change over time.
|
||||
A type with an unstable representation is unlikely to be of much
|
||||
use to anyone, so we will insist that any temporal library use
|
||||
only stable representations.
|
||||
<p>
|
||||
An operation on a type is stable if the result of applying the operation to a particular operand(s) does not change over time.
|
||||
<p>
|
||||
<H3>Predictability</H3>
|
||||
|
||||
<p>
|
||||
|
||||
Sets are most often classified into two categories: well-defined
|
||||
and ill-defined. Since a type is a set, we can extend these definitions
|
||||
to cover types. For any type T, there must be a predicate
|
||||
<i>is_member( x )</i>
|
||||
which determines whether a value x is a member of type T.
|
||||
This predicate must return <i>true</i>, <i>false</i>, or <i>dont_know</i>.
|
||||
<p>
|
||||
If for all x, is_member( x ) returns either true or false, we
|
||||
say the set T is <i>well-defined</i>.
|
||||
<p>
|
||||
If for any x, is_member( x ) returns dont_know, we say the
|
||||
set T is <i>ill-defined</i>.
|
||||
<p>
|
||||
Those are the rules normally used in math. However,
|
||||
because of the special characteristics of temporal
|
||||
types, it is useful to refine this view and create a third category
|
||||
as follows:
|
||||
<p>
|
||||
For any temporal type T, there must be a predicate <i>is_member( x, t )</i>
|
||||
which determines whether a value x is a member of T.
|
||||
The parameter t represents the time when the predicate is evaluated.
|
||||
For each x<sub>i</sub>, there must be a time t<sub>i</sub> and a value v
|
||||
such that:
|
||||
<ul>
|
||||
<li>v = true or v = false, and
|
||||
<li>for all t < t<sub>i</sub>, is_member( x<sub>i</sub>, t ) returns dont_know, and
|
||||
<li>for all t >= t<sub>i</sub>, is_member( x<sub>i</sub>, t ) returns v.
|
||||
</ul>
|
||||
t<sub>i</sub> is thus the time when we "find out" whether x<sub>i</sub> is a
|
||||
member of T.
|
||||
Now we can define three categories of temporal types:
|
||||
<p>
|
||||
If for all x<sub>i</sub>, t<sub>i</sub> = negative infinity,
|
||||
we say the type T is <i>predictable</i>.
|
||||
<p>
|
||||
If for some x<sub>i</sub>, t<sub>i</sub> = positive infinity,
|
||||
we say the type T is <i>ill-formed</i>.
|
||||
<p>
|
||||
Otherwise we say the type T is <i>unpredictable</i> (this
|
||||
implies that for some x<sub>i</sub>, t<sub>i</sub> is finite).
|
||||
<p>
|
||||
Ill-formed sets are not of much practical use, so we will
|
||||
not discuss them further. In plain english the above
|
||||
simply says that all the values of a predictable type are
|
||||
known ahead of time, but some values of an unpredictable
|
||||
type are not known until some particular time.
|
||||
|
||||
<p>
|
||||
<H3>Stability of Operations</H3>
|
||||
|
||||
<p>
|
||||
Predictable types have a couple of important properties:
|
||||
<UL>
|
||||
<li> there is an order-preserving mapping from their elements onto a set of consecutive integers, and
|
||||
<li> duration operations on their values are stable
|
||||
</UL>
|
||||
The practical effect of this is that duration calculations
|
||||
can be implemented with simple integer subtraction.
|
||||
Examples of predictable types are TAI timepoints and
|
||||
Gregorian dates.
|
||||
<p>
|
||||
Unpredictable types have exactly the opposite properties:
|
||||
<UL>
|
||||
<li> there is no order-preserving mapping from their elements onto a set of consecutive integers, and
|
||||
<li> duration operations on their values are not stable.
|
||||
</UL>
|
||||
Examples of unpredictable types are UTC timepoints and
|
||||
Local Time timepoints.
|
||||
<p>
|
||||
We can refine this a little by saying that a range within
|
||||
an unpredicatable type can be predictable, and operations performed
|
||||
entirely on values within that range will be stable.
|
||||
For example, the range of UTC timepoints from 1970-01-01
|
||||
through the present is predictable, so calculations of durations within that range will be stable.
|
||||
<p>
|
||||
<H3>Approximations</H3>
|
||||
|
||||
<p>
|
||||
These limitations are problematical, because important temporal
|
||||
types like UTC and Local Time are in fact unpredictable, and
|
||||
therefore operations on them are sometimes unstable. Yet as a practical matter we often want to perform this kind of operation, such as computing the duration between two timepoints in the future that are specified in Local Time.
|
||||
<p>
|
||||
The best the library can do is to provide an approximation,
|
||||
which is generally possible and for most purposes will be
|
||||
good enough. Of course the documentation must specify when
|
||||
an answer will be approximate (and thus unstable) and how
|
||||
big the error may be. In many respects calculating with unpredictable sets is analogous to the use of floating point numbers, for which results are expected to only be approximately correct. Calculating with predictable sets would then be
|
||||
analagous to the user of integers, where results are expected
|
||||
to be exact.
|
||||
<p>
|
||||
For situations where exact answers are required or instability cannot be tolerated, the user must
|
||||
be able to specify this, and then the library should throw an
|
||||
exception if the user requests a computation for which an
|
||||
exact, stable answer is not possible.
|
||||
<p>
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Wed Aug 21 14:46:55 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2016 Rene Rivera
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc
|
||||
: ../xmldoc/date_time.xml
|
||||
:
|
||||
: <dependency>../xmldoc//date_time_autodoc <dependency>../xmldoc//gregorian_autodoc
|
||||
<dependency>../xmldoc//posix_time_autodoc <dependency>../xmldoc//local_time_autodoc
|
||||
: ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease ;
|
||||
explicit boostrelease ;
|
||||
@@ -1,211 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>gregorian::date Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>gregorian::date</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<p>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">Date Documentation</font>
|
||||
<p>
|
||||
<a href="class_date.html#header">Header</a> --
|
||||
<a href="class_date.html#construct">Construction</a> --
|
||||
<a href="class_date.html#constructfromstring">Construct from String</a> --
|
||||
<a href="class_date.html#constructfromclock"> Construct from Clock</a> --
|
||||
<a href="class_date.html#accessors">Accessors</a> --
|
||||
<a href="class_date.html#conversiontostring">Conversion To String</a> --
|
||||
<a href="class_date.html#operators">Operators</a>
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
The class boost::gregorian::date is the primary interface for date programming. In general, the date class is immutable once constructed although it does allow assignment.
|
||||
|
||||
<p>
|
||||
Other techniques for creating dates include <a href="date_iterators.html">date iterators</a> and <a href="date_algorithms.html">date algorithms or generators</a>.
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
|
||||
or
|
||||
#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
|
||||
</pre>
|
||||
<h2><a name="construct">Construction</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>date(greg_year year, greg_month month, greg_day day)</td>
|
||||
<td>Construct from parts of date. <b>Throws</b> bad_year,
|
||||
bad_day_of_month, or bad_day_month (derivatives
|
||||
of std::out_of_range) if
|
||||
the year, month or day are out of range.
|
||||
</td>
|
||||
<td>date d(2002,Jan,10)</td></tr>
|
||||
<tr><td>date(date d)</td>
|
||||
<td>Copy constructor</td>
|
||||
<td>date d1(d)</td></tr>
|
||||
<tr><td>date(special_values sv)</td>
|
||||
<td>Constructor for infinitites, not-a-date-time, max_date, and min_date</td>
|
||||
<td>date d1(neg_infin);<br>date d2(pos_infin);<br>date d3(not_a_date_time);<br>date d4(max_date);<br>date d5(min_date);</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<h2><a name="constructfromstring">Construction From String</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>date <font class="func">from_string</font>(const std::string&)</td>
|
||||
<td>From delimited date string where with order year-month-day eg: 2002-1-25</td>
|
||||
<td>std::string ds("2002/1/25");<br>
|
||||
date d(from_string(ds))</td></tr>
|
||||
<tr><td>date <font class="func">from_undelimited_string</font>(const std::string&)</td>
|
||||
<td>From iso type date string where with order year-month-day eg: 20020125</td>
|
||||
<td>std::string ds("20020125");<br>
|
||||
date d(from_undelimited_string(ds))</td></tr>
|
||||
|
||||
</table>
|
||||
<p>
|
||||
|
||||
<h2><a name="constructfromclock">Construction From Clock</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>day_clock::local_day()</td>
|
||||
<td>Get the local day based on the time zone settings of the computer.</td>
|
||||
<td>date d(day_clock::local_day())</td></tr>
|
||||
<tr><td>day_clock::universal_day()</td>
|
||||
<td>Get the UTC day.</td>
|
||||
<td>date d(day_clock::universal_day())</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<h2><a name="accessors">Accessors</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>greg_year <font class="func">year</font>() const</td>
|
||||
<td>Get the year part of the date.</td>
|
||||
<td>date d(2002,Jan,10); d.year() --> 2002;</td></tr>
|
||||
<tr><td>greg_month <font class="func">month</font>() const</td>
|
||||
<td>Get the month part of the date.</td>
|
||||
<td>date d(2002,Jan,10); d.month() --> 1;</td></tr>
|
||||
<tr><td>greg_day <font class="func">day</font>() const</td>
|
||||
<td>Get the day part of the date.</td>
|
||||
<td>date d(2002,Jan,10); d.day() --> 10;</td></tr>
|
||||
<tr><td>greg_ymd <font class="func">year_month_day</font>() const</td>
|
||||
<td>Return a year_month_day struct. More efficient when all 3 parts of the date are needed.</td>
|
||||
<td>date d(2002,Jan,10);
|
||||
<br>date::ymd_type ymd = d.year_month_day();
|
||||
<br>ymd.year --> 2002, ymd.month --> 1, ymd.day --> 10</td></tr>
|
||||
<tr><td>greg_day_of_week <font class="func">day_of_week</font>() const</td>
|
||||
<td>Get the day of the week (eg: Sunday, Monday, etc.</td>
|
||||
<td>date d(2002,Jan,10); d.day() --> Thursday;</td></tr>
|
||||
<tr><td>bool <font class="func">is_infinity</font>() const</td>
|
||||
<td>Returns true if date is either positive or negative infinity</td>
|
||||
<td>date d(pos_infin); d.is_infinity() --> true;</td></tr>
|
||||
<tr><td>bool <font class="func">is_neg_infinity</font>() const</td>
|
||||
<td>Returns true if date is negative infinity</td>
|
||||
<td>date d(neg_infin); d.is_neg_infinity() --> true;</td></tr>
|
||||
<tr><td>bool <font class="func">is_pos_infinity</font>() const</td>
|
||||
<td>Returns true if date is positive infinity</td>
|
||||
<td>date d(neg_infin); d.is_pos_infinity() --> true;</td></tr>
|
||||
<tr><td>bool <font class="func">is_not_a_date</font>() const</td>
|
||||
<td>Returns true if value is not a date</td>
|
||||
<td>date d(not_a_date_time); d.is_not_a_date() --> true;</td></tr>
|
||||
<tr><td>long <font class="func">modjulian_day</font>() const</td>
|
||||
<td>Returns the modified julian day for the date.</td>
|
||||
<td></td></tr>
|
||||
<tr><td>long <font class="func">julian_day</font>() const</td>
|
||||
<td>Returns the julian day for the date.</td>
|
||||
<td></td></tr>
|
||||
<tr><td>int <font class="func">week_number</font>() const</td>
|
||||
<td>Returns the ISO 8601 week number for the date.</td>
|
||||
<td></td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<h2><a name="conversiontostring">Conversion To String</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>std::string <font class="func">to_simple_string</font>(date d)</td>
|
||||
<td>To YYYY-mmm-DD string where mmm 3 char month name.</td>
|
||||
<td>2002-Jan-01</td></tr>
|
||||
<tr><td>std::string <font class="func">to_iso_string</font>(date d)</td>
|
||||
<td>To YYYYMMDD where all components are integers.</td>
|
||||
<td>20020131</td></tr>
|
||||
<tr><td>std::string <font class="func">to_iso_extended_string</font>(date d)</td>
|
||||
<td>To YYYY-MM-DD where all components are integers.</td>
|
||||
<td>2002-01-31</td></tr>
|
||||
|
||||
</table>
|
||||
<p>
|
||||
|
||||
|
||||
<h2><a name="operators">Operators</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>operator<<</td>
|
||||
<td>Stream output operator</td>
|
||||
<td>date d(2002,Jan,1)<br>
|
||||
std::cout << d << std::endl;</td></tr>
|
||||
<tr><td>operator==, operator!=,<br> operator>, operator<
|
||||
<br> operator>=, operator<=</td>
|
||||
<td>A full complement of comparison operators</td>
|
||||
<td>d1 == d2, etc</td></tr>
|
||||
<tr><td>date operator+(date_duration) const</td>
|
||||
<td>Return a date adding a day offset</td>
|
||||
<td>date d(2002,Jan,1);
|
||||
<br>date_duration dd(1);
|
||||
<br>date d2 = d + dd;</td></tr>
|
||||
<tr><td>date operator-(date_duration) const</td>
|
||||
<td>Return a date by adding a day offset </td>
|
||||
<td>date d(2002,Jan,1);
|
||||
<br>date_duration dd(1);
|
||||
<br>date d2 = d - dd;</td></tr>
|
||||
<tr><td>date_duration operator-(date) const</td>
|
||||
<td>Return a date duration by subtracting two dates</td>
|
||||
<td>date d1(2002,Jan,1);
|
||||
<br>date d2(2002,Jan,2);
|
||||
<br>date_duration dd = d2-d1;</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Sun Jan 19 16:01:22 MST 2003
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>gregorian::date_duration Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>gregorian::date_duration</h1>
|
||||
<hr>
|
||||
<p>
|
||||
<p>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">Date Documentation</font>
|
||||
<p>
|
||||
<a href="class_date_duration.html#header">Header</a> --
|
||||
<a href="class_date_duration.html#construct">Construction</a> --
|
||||
<a href="class_date_duration.html#accessors">Accessors</a> --
|
||||
<a href="class_date_duration.html#operators">Operators</a>
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
The class boost::gregorian::date_duration is a simple day count used for arithmetic with <a href="class_date.html">gregorian::date</a>. A duration can be either positive or negative.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
|
||||
or
|
||||
#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
|
||||
</pre>
|
||||
<p>
|
||||
|
||||
<h2><a name="construct">Construction</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>date_duration(long)</td>
|
||||
<td>Create a duration count.</td>
|
||||
<td>date_duration dd(3); //3 days</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<h2><a name="accessors">Accessors</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>long <font class="func">days</font>() const</td>
|
||||
<td>Get the day count.</td>
|
||||
<td>date_duration dd(3); dd.days() --> 3</td></tr>
|
||||
<tr><td>bool <font class="func">is_negative</font>() const</td>
|
||||
<td>True if number of days is less than zero..</td>
|
||||
<td>date_duration dd(-1); dd.is_negative() --> true</td></tr>
|
||||
<tr><td>static date_duration <font class="func">unit</font>()</td>
|
||||
<td>Return smallest possible unit of duration type.</td>
|
||||
<td>date_duration::unit() --> date_duration(1)</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<h2><a name="operators">Operators</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>operator==, operator!=,<br>
|
||||
operator>, operator< <br>
|
||||
operator>=, operator<=</td>
|
||||
<td>A full complement of comparison operators</td>
|
||||
<td>dd1 == dd2, etc</td></tr>
|
||||
<tr><td>date_duration operator+(date_duration) const</td>
|
||||
<td>Add date durations.</td>
|
||||
<td>date_duration dd1(3);
|
||||
<br>date_duration dd2(5);
|
||||
<br>date_duration dd3 = dd1 + dd2;</td></tr>
|
||||
<tr><td>date_duration operator-(date_duration) const</td>
|
||||
<td>Subtract durations.</td>
|
||||
<td>date_duration dd1(3);
|
||||
<br>date_duration dd2(5);
|
||||
<br>date_duration dd3 = dd1 - dd2;</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Wed Aug 21 15:12:43 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>gregorian::date_period Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
<h1>gregorian::date_period</h1>
|
||||
<p> </p>
|
||||
<hr>
|
||||
<p>
|
||||
<p>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">Date Period Documentation</font>
|
||||
<p>
|
||||
<a href="class_date_period.html#header">Header</a> --
|
||||
<a href="class_date_period.html#construct">Construction</a> --
|
||||
<a href="class_date_period.html#accessors">Accessors</a> --
|
||||
<a href="class_date_period.html#conversiontostring">Conversion To String</a> --
|
||||
<a href="class_date_period.html#operators">Operators</a> --
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
The class boost::gregorian::date_period provides direct representation
|
||||
for ranges between two dates. Periods provide the ability to simplify
|
||||
some types of caculations by simplifing the conditional logic of the
|
||||
program. For example, testing if a date is within an irregular
|
||||
schedule such as a weekend or holiday can be accomplished using
|
||||
collections of date periods. This is facilitated by several methods
|
||||
that allow evaluation if a date_period intersects with another date
|
||||
period, and to generate the period resulting from the intersection.
|
||||
The <a href="exp-period_calc.html">period calculation
|
||||
example</a> provides an example of this.
|
||||
|
||||
|
||||
<p>
|
||||
Date periods used in combination with infinity values have the abilty
|
||||
to represent complex concepts such as 'until further notice'.
|
||||
<p>
|
||||
<p>
|
||||
<p>
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
|
||||
or
|
||||
#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
<h2><a name="construct">Construction</a></h2>
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>date_period(date begin, date last)</td>
|
||||
<td>
|
||||
Create a period as [begin, last). If last is <= begin then
|
||||
the period will be defined as null.
|
||||
</td>
|
||||
<td>date_period dp(date(2002,Jan,10), date(2002,Jan,12));</td></tr>
|
||||
<tr><td>date_period(date start, date_duration len)</td>
|
||||
<td>
|
||||
Create a period as [begin, begin+len). If len is <= zero then
|
||||
the period will be defined as null.
|
||||
</td>
|
||||
<td>date_period dp(date(2002,Jan,10), date_duration(2));</td></tr>
|
||||
<tr><td>date_period(date_period rhs)</td>
|
||||
<td>Copy constructor</td>
|
||||
<td>date_period dp1(dp)</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
|
||||
<h2><a name="accessors">Accessors</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>date <font class="func">begin</font>() const</td>
|
||||
<td>Return first day of period.</td>
|
||||
<td>date_period dp(date(2002,Jan,1), date(2002,Jan,10));<br>
|
||||
dp.begin() --> 2002-Jan-01</td></tr>
|
||||
<tr><td>date <font class="func">last</font>() const</td>
|
||||
<td>Return last date in the period</td>
|
||||
<td>date_period dp(date(2002,Jan,1), date(2002,Jan,10));<br>
|
||||
dp.last() --> 2002-Jan-09</td></tr>
|
||||
<tr><td>date <font class="func">end</font>() const</td>
|
||||
<td>Return one past the last in period</td>
|
||||
<td>date_period dp(date(2002,Jan,1), date(2002,Jan,10));<br>
|
||||
dp.end() --> 2002-Jan-10</td></tr>
|
||||
<tr><td>date_duration <font class="func">length</font>() const</td>
|
||||
<td>Return the length of the date_period</td>
|
||||
<td>date_period dp(date(2002,Jan,1), date_duration(2));<br>
|
||||
dp.length() --> 2</td></tr>
|
||||
<tr><td>bool <font class="func">is_null</font>() const</td>
|
||||
<td>True if period is not well formed. eg: start less than end </td>
|
||||
<td>date_period dp(date(2002,Jan,10), date(2002,Jan,1));<br>
|
||||
dp.begin() --> true</td></tr>
|
||||
<tr><td>bool <font class="func">contains</font>(date) const</td>
|
||||
<td>True if date is within the period</td>
|
||||
<td>date_period dp(date(2002,Jan,1), date(2002,Jan,10));<br>
|
||||
dp.contains(date(2002,Jan,2)) --> true</td></tr>
|
||||
<tr><td>bool <font class="func">contains</font>(date_period) const</td>
|
||||
<td>True if date period is within the period</td>
|
||||
<td>date_period dp1(date(2002,Jan,1), date(2002,Jan,10));<br>
|
||||
date_period dp2(date(2002,Jan,2), date(2002,Jan,3));<br>
|
||||
dp1.contains(dp2) --> true<br>
|
||||
dp2.contains(dp1) --> false</td></tr>
|
||||
<tr><td>bool <font class="func">intersects</font>(date_period) const</td>
|
||||
<td>True if periods overlap</td>
|
||||
<td>date_period dp1(date(2002,Jan,1), date(2002,Jan,10));<br>
|
||||
date_period dp2(date(2002,Jan,2), date(2002,Jan,3));<br>
|
||||
dp2.intersects(dp1) --> true</td></tr>
|
||||
<tr><td>date_period <font class="func">intersection</font>(date_period) const</td>
|
||||
<td>Calculate the intersection of 2 periods. Null if no intersection.</td>
|
||||
<td>date_period dp1(date(2002,Jan,1), date(2002,Jan,10));<br>
|
||||
date_period dp2(date(2002,Jan,2), date(2002,Jan,3));<br>
|
||||
dp2.intersection(dp1) --> dp2</td></tr>
|
||||
<tr><td>date_period <font class="func">merge</font>(date_period) const</td>
|
||||
<td>Returns union of two periods. Null if no intersection.</td>
|
||||
<td>date_period dp1(date(2002,Jan,1), date(2002,Jan,10));<br>
|
||||
date_period dp2(date(2002,Jan,9), date(2002,Jan,31));<br>
|
||||
dp2.merge(dp1) --> 2002-Jan-01/2002-Jan-31</td></tr>
|
||||
<tr><td>date_period <font class="func">shift</font>(date_duration)</td>
|
||||
<td>Add duration to both start and end.</td>
|
||||
<td>date_period dp1(date(2002,Jan,1), date(2002,Jan,10));<br>
|
||||
dp1.shift(date_duration(1)); --> 2002-Jan-02/2002-Jan-11</td></tr>
|
||||
|
||||
</table>
|
||||
<p>
|
||||
<h2><a name="conversiontostring">Conversion To String</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>std::string <font class="func">to_simple_string</font>(date_period dp)</td>
|
||||
<td>To [YYYY-mmm-DD/YYYY-mmm-DD] string where mmm is 3 char month name.</td>
|
||||
<td>[2002-Jan-01/2002-Jan-31]</td></tr>
|
||||
|
||||
</table>
|
||||
<p>
|
||||
|
||||
|
||||
<h2><a name="operators">Operators</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>operator<<</td>
|
||||
<td>ostream operator for date_period. Uses facet to format time points. Typical output: [2002-Jan-01/2002-Jan-31].</td>
|
||||
<td>std::cout << std::endl;</td></tr>
|
||||
<tr><td>operator==, operator!=,<br> operator>, operator<
|
||||
<td>A full complement of comparison operators</td>
|
||||
<td>dp1 == dp2, etc</td></tr>
|
||||
<tr><td>operator<</td>
|
||||
<td>True if dp1.end() less than dp2.begin()</td>
|
||||
<td>dp1 < dp2, etc</td></tr>
|
||||
<tr><td>operator></td>
|
||||
<td>True if dp1.begin() greater than dp2.end()</td>
|
||||
<td>dp1 > dp2, etc</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Sat Nov 2 16:51:11 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Date I/O Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
<h1>Date Input/Output</h1>
|
||||
<p> </p>
|
||||
<hr>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<a href="#intro">Introduction</a> --
|
||||
<a href="#classoverview">Class Overview</a>
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
<p>
|
||||
The library provides for localized stream-based I/O of dates and times.
|
||||
Note that this support is not supported for all compilers. See the
|
||||
<a href="BuildInfo.html">build information</a> page for details.
|
||||
<p>
|
||||
<p>
|
||||
<a name="classoverview"><h2>Class Overview</h2></a>
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Class</b></td>
|
||||
<td><b>Construction Parameters</b></td>
|
||||
<td><b>Description</b></td></tr>
|
||||
<tr><td>date_iterator</td>
|
||||
<td></td>
|
||||
<td>Common base class for all day level iterators.</td></tr>
|
||||
<tr><td>day_iterator</td>
|
||||
<td>date start_date, int day_count=1</td>
|
||||
<td>Iterate day_count days at a time.</td></tr>
|
||||
<tr><td>week_iterator</td>
|
||||
<td>date start_date, int week_offset=1</td>
|
||||
<td>Iterate week_offset weeks at a time.</td></tr>
|
||||
<tr><td>month_iterator</td>
|
||||
<td>date start_date, int month_offset=1</td>
|
||||
<td>Iterate month_offset months. There are special rules for
|
||||
handling the end of the month. These are: if start date is last
|
||||
day of the month, always adjust to last day of the month.
|
||||
if date is beyond the end of the month (eg: jan 31 + 1 month)
|
||||
adjust back to end of month.
|
||||
</td></tr>
|
||||
<tr><td>year_iterator</td>
|
||||
<td>date start_date, int year_offset=1</td>
|
||||
<td>Iterate year_offset years</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<hr><address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Thu Sep 5 07:26:05 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>gregorian::gregorian_calendar Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>gregorian::gregorian_calendar</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<p>
|
||||
<p>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">Date Documentation</font>
|
||||
<p>
|
||||
<a href="class_gregorian_calendar.html#header">Header</a> --
|
||||
<a href="class_gregorian_calendar.html#functions">Functions</a>
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
The class boost::gregorian::gregorian_calendar implements the functions
|
||||
necessary to create the gregorian date system. It converts to
|
||||
the year-month-day form of a date to a day number representation
|
||||
and back.
|
||||
|
||||
<p>
|
||||
For most purposes this class is simply accessed by
|
||||
<a href="class_date.html">gregorian::date</a> and is not used directly
|
||||
by the user. However, there are useful functions that
|
||||
might be of use such as the <font class="func">end_of_month_day</font>
|
||||
function.
|
||||
<p>
|
||||
The <a href="exp-print_month.html">print month</a> example demonstrates this.
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
|
||||
or
|
||||
#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
|
||||
</pre>
|
||||
<p>
|
||||
|
||||
|
||||
<h2><a name="functions">Functions</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>static short <font class="func">day_of_week</font>(ymd_type)</td>
|
||||
<td>Return the day of the week (0==Sunday, 1==Monday, etc)</td>
|
||||
<td>See also gregorian::date day_of_week</td></tr>
|
||||
<tr><td>static date_int_type <font class="func">day_number</font>(ymd_type)</td>
|
||||
<td> Convert a ymd_type into a day number. The day number is an absolute number of days since the epoch start.</td>
|
||||
<td></td></tr>
|
||||
<tr><td>static short <font class="func">end_of_month_day</font>(year_type, month_type)</td>
|
||||
<td>Given a year and month determine the last day of the month.</td>
|
||||
<td></td></tr>
|
||||
<tr><td>static ymd_type <font class="func">from_day_number</font>(date_int_type)</td>
|
||||
<td> Convert a day number to a ymd struct. </td>
|
||||
<td></td></tr>
|
||||
<tr><td>static bool <font class="func">is_leap_year</font>(year_type)</td>
|
||||
<td>Returns true if specified year is a leap year.</td>
|
||||
<td>gregorian_calendar::is_leap_year(2000) --> true</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Thu Sep 5 06:05:54 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>posix_time::ptime Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>posix_time::ptime Documentation</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">ptime Documentation</font>
|
||||
<p>
|
||||
<a href="class_ptime.html#header">Header</a> --
|
||||
<a href="class_ptime.html#construct">Construction</a> --
|
||||
<a href="class_ptime.html#constructfromstring">Construct from String</a> --
|
||||
<a href="class_ptime.html#constructfromclock">Construct from Clock</a> --
|
||||
<a href="class_ptime.html#accessors">Accessors</a> --
|
||||
<a href="class_ptime.html#conversiontostring">Conversion To String</a> --
|
||||
<a href="class_ptime.html#operators">Operators</a>
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
The class boost::posix_time::ptime is the primary interface for time
|
||||
point manipulation. In general, the ptime class is immutable once
|
||||
constructed although it does allow assignment.
|
||||
|
||||
<p>
|
||||
Class ptime is dependent on <a href="class_date.html">gregorian::date</a>
|
||||
for the interface to the date portion of a time point.
|
||||
<p>
|
||||
Other techniques for creating times include <a href="time_iterators.html">time iterators</a>.
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
|
||||
or
|
||||
#include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types
|
||||
</pre>
|
||||
<p>
|
||||
<h2><a name="construct">Construction</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>ptime(date,time_duration)</td>
|
||||
<td>Construct from a date and offset
|
||||
</td>
|
||||
<td>ptime t1(date(2002,Jan,10), time_duration(1,2,3));<br>
|
||||
ptime t2(date(2002,Jan,10), hours(1)+nanosec(5));</td></tr>
|
||||
<tr><td>ptime(ptime)</td>
|
||||
<td>Copy constructor</td>
|
||||
<td>ptime t3(t1)</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<h2><a name="constructfromstring">Construction From String</a></h2>
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>ptime <font class="func">time_from_string</font>(const std::string&)</td>
|
||||
<td>From delimited string.</td>
|
||||
<td>std::string ts("2002-01-20 23:59:59.000");
|
||||
<br>
|
||||
ptime t(time_from_string(ts))</td></tr>
|
||||
<tr><td>ptime <font class="func">from_iso_string</font>(const std::string&)</td>
|
||||
<td>From non delimited iso form string.</td>
|
||||
<td>std::string ts("20020131T235959");
|
||||
<br>
|
||||
ptime t(from_iso_string(ts))</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
|
||||
<h2><a name="constructfromclock">Construction From Clock</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>static ptime second_clock::local_time();</td>
|
||||
<td>Get the local time, second level resolution, based on the time zone settings of the computer.</td>
|
||||
<td>ptime t(second_clock::local_time())</td></tr>
|
||||
<tr><td>static ptime second_clock::universal_time()</td>
|
||||
<td>Get the UTC time.</td>
|
||||
<td>ptime t(second_clock::universal_day())</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<h2><a name="accessors">Accessors</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>date <font class="func">date</font>() const</td>
|
||||
<td>Get the date part of a time.</td>
|
||||
<td>date d(2002,Jan,10);<br>
|
||||
ptime t(d, hour(1));<br>
|
||||
t.date() --> 2002-Jan-10;</td></tr>
|
||||
<tr><td>time_duration <font class="func">time_of_day</font>() const</td>
|
||||
<td>Get the time offset in the day.</td>
|
||||
<td>date d(2002,Jan,10);<br>
|
||||
ptime t(d, hour(1));<br>
|
||||
t.time_of_day() --> 01:00:00;</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<h2><a name="conversiontostring">Conversion To String</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>std::string <font class="func">to_simple_string</font>(ptime)</td>
|
||||
<td>To YYYY-mmm-DD HH:MM:SS.fffffffff string where mmm 3 char month name. Fractional seconds only included if non-zero.</td>
|
||||
<td>2002-Jan-01 10:00:01.123456789</td></tr>
|
||||
<tr><td>std::string <font class="func">to_iso_string</font>(ptime)</td>
|
||||
<td>Convert to form YYYYMMDDTHHMMSS,fffffffff where T is the date-time separator</td>
|
||||
<td>20020131T100001,123456789</td></tr>
|
||||
<tr><td>std::string <font class="func">to_iso_extended_string</font>(ptime)</td>
|
||||
<td>Convert to form YYYY-MM-DDTHH:MM:SS,fffffffff where T is the date-time separator</td>
|
||||
<td>2002-01-31T10:00:01,123456789</td></tr>
|
||||
|
||||
</table>
|
||||
<p>
|
||||
|
||||
|
||||
<h2><a name="operators">Operators</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>operator==, operator!=,<br> operator>, operator<
|
||||
<br> operator>=, operator<=</td>
|
||||
<td>A full complement of comparison operators</td>
|
||||
<td>t1 == t2, etc</td></tr>
|
||||
<tr><td>ptime <font class="func">operator+</font>(date_duration) const</td>
|
||||
<td>Return a ptime adding a day offset</td>
|
||||
<td>date d(2002,Jan,1);<br>
|
||||
ptime t(d,minutes(5));<br>
|
||||
date_duration dd(1); <br>
|
||||
ptime t2 = t + dd;</td></tr>
|
||||
<tr><td>ptime <font class="func">operator-</font>(date_duration) const</td>
|
||||
<td>Return a ptime subtracting a day offset</td>
|
||||
<td>date d(2002,Jan,1);<br>
|
||||
ptime t(d,minutes(5));<br>
|
||||
date_duration dd(1); <br>
|
||||
ptime t2 = t - dd;</td></tr>
|
||||
<tr><td>ptime <font class="func">operator+</font>(time_duration) const</td>
|
||||
<td>Return a ptime adding a time duration</td>
|
||||
<td>date d(2002,Jan,1);<br>
|
||||
ptime t(d,minutes(5));<br>
|
||||
ptime t2 = t + hours(1) + minutes(2);</td></tr>
|
||||
<tr><td>ptime <font class="func">operator-</font>(time_duration) const</td>
|
||||
<td>Return a ptime subtracting a time duration</td>
|
||||
<td>date d(2002,Jan,1);<br>
|
||||
ptime t(d,minutes(5));<br>
|
||||
ptime t2 = t - minutes(2);</td></tr>
|
||||
<tr><td>time_duration <font class="func">operator-</font>(ptime) const</td>
|
||||
<td>Take the difference between two times.</td>
|
||||
<td>date d(2002,Jan,1);<br>
|
||||
ptime t1(d,minutes(5));<br>
|
||||
ptime t2(d,seconds(5));<br>
|
||||
time_duration t3 = t2 - t1;//negative result</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Sun Oct 13 10:52:41 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>posix_time::time_duration Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>posix_time::time_duration</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<p>
|
||||
<p>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">Time Duration Documentation</font>
|
||||
<p>
|
||||
<a href="class_time_duration.html#header">Header</a> --
|
||||
<a href="class_time_duration.html#construct">Construction</a> --
|
||||
<a href="class_time_duration.html#countbasedconstruct">Count Based Construction</a> --
|
||||
<a href="class_time_duration.html#constructfromstring">Construct from String</a> --
|
||||
<a href="class_time_duration.html#accessors">Accessors</a> --
|
||||
<a href="class_time_duration.html#conversiontostring">Conversion To String</a> --
|
||||
<a href="class_time_duration.html#operators">Operators</a>
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
The class boost::posix_time::time_duration the base type reponsible for representing a length of time. A duration can be either positive or negative.
|
||||
<p>
|
||||
Several small helper classes that derive from a base time_duration, as
|
||||
shown below, to adjust for different resolutions. These classes can
|
||||
shorten code and make the intent clearer.
|
||||
|
||||
<p>
|
||||
<img align="middle" src="time_duration_inherit.png" alt="inherit">
|
||||
<p>
|
||||
As an example:
|
||||
<div class="fragment"><pre>
|
||||
|
||||
<font class="keyword">using namespace</font> boost::gregorian;
|
||||
<font class="keyword">using namespace</font> boost::posix_time;
|
||||
|
||||
time_duration td = hours(1) + seconds(10); <font class="comment">//01:00:01</font>
|
||||
td = hours(1) + nanosec(5); <font class="comment">//01:00:00.000000005</font>
|
||||
</pre></div>
|
||||
<p>
|
||||
Note that the existence of the higher resolution classes depends on
|
||||
the installation of the library. See
|
||||
<a href="BuildInfo.html">Build-Compiler Information</a> for more
|
||||
information.
|
||||
|
||||
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
|
||||
or
|
||||
#include "boost/date_time/posix_time/posix_time/posix_time_types.hpp" //no i/o just types
|
||||
</pre>
|
||||
<p>
|
||||
|
||||
<h2><a name="construct">Construction</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>time_duration(hours,minutes,seconds,fractional_seconds)</td>
|
||||
<td>Construct ad duration from the counts</td>
|
||||
<td>time_duration td(1,2,3,9); //1 hr 2 min 3 sec 9 nanoseconds</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
<h2><a name="countbasedconstruct">Construction By Count</a></h2>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>hours(long)</td>
|
||||
<td>Number of hours</td>
|
||||
<td>time_duration td = hours(3);</td></tr>
|
||||
<tr><td>minutes(long)</td>
|
||||
<td>Number of minutes</td>
|
||||
<td>time_duration td = minutes(3);</td></tr>
|
||||
<tr><td>seconds(long)</td>
|
||||
<td>Number of seconds</td>
|
||||
<td>time_duration td = seconds(3);</td></tr>
|
||||
<tr><td>millisec(long)</td>
|
||||
<td>Number of millisec</td>
|
||||
<td>time_duration td = millisec(3);</td></tr>
|
||||
<tr><td>nanosec(long)</td>
|
||||
<td>Number of nanosec</td>
|
||||
<td>time_duration td = nanosec(3);</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
<h2><a name="constructfromstring">Construction From String</a></h2>
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>time_duration <font class="func">duration_from_string</font>(const std::string&)</td>
|
||||
<td>From delimited string.</td>
|
||||
<td>std::string ts("23:59:59.000");
|
||||
<br>
|
||||
time_duraton td(duration_from_string(ts))</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
|
||||
<h2><a name="accessors">Accessors</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>long <font class="func">hours</font>() const</td>
|
||||
<td>Get the number of hours.</td>
|
||||
<td>time_duration td(1,2,3); td.hours() --> 1</td></tr>
|
||||
<tr><td>long <font class="func">minutes</font>() const</td>
|
||||
<td>Get the number of minutes normalized.</td>
|
||||
<td>time_duration td(1,2,3); td.minutes() --> 2</td></tr>
|
||||
<tr><td>long <font class="func">seconds</font>() const</td>
|
||||
<td>Get the number of seconds.</td>
|
||||
<td>time_duration td(1,2,3); td.seconds() --> 3</td></tr>
|
||||
<tr><td>long <font class="func">fractional_seconds</font>() const</td>
|
||||
<td>Get the number of fractional seconds.</td>
|
||||
<td>time_duration td(1,2,3, 1000); td.fractional_seconds() --> 1000</td></tr>
|
||||
<tr><td>bool <font class="func">is_negative</font>() const</td>
|
||||
<td>True if duration is negative.</td>
|
||||
<td>time_duration td(-1,0,0); td.is_negative() --> true</td></tr>
|
||||
<tr><td>time_duration <font class="func">invert_sign</font>() const</td>
|
||||
<td>Generate a new duration with the sign inverted/</td>
|
||||
<td>time_duration td(-1,0,0); td.invert_sign() --> 01:00:00</td></tr>
|
||||
<tr><td>static boost::date_time::time_resolutions <font class="func">resolution</font>()</td>
|
||||
<td>Describes the resolution capability of the time_duration class.</td>
|
||||
<td>time_duration::resolution() --> nano</td></tr>
|
||||
<tr><td>boost::int64_t <font class="func">ticks</font>()</td>
|
||||
<td>Return the raw count of the duration type.</td>
|
||||
<td>time_duration td(0,0,0, 1000); td.ticks() --> 1000</td></tr>
|
||||
<tr><td>static time_duration <font class="func">unit</font>()</td>
|
||||
<td>Return smallest possible unit of duration type (1 nanosecond).</td>
|
||||
<td>time_duration::unit() --> time_duration(0,0,0,1)</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<h2><a name="conversiontostring">Conversion To String</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>std::string <font class="func">to_simple_string</font>(time_duration)</td>
|
||||
<td>To HH:MM:SS.fffffffff were fff is fractional seconds that are only included if non-zero.</td>
|
||||
<td>10:00:01.123456789</td></tr>
|
||||
<tr><td>std::string <font class="func">to_iso_string</font>(time_duration)</td>
|
||||
<td>Convert to form HHMMSS,fffffffff.</td>
|
||||
<td>100001,123456789</td></tr>
|
||||
|
||||
</table>
|
||||
<p>
|
||||
|
||||
<h2><a name="operators">Operators</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>operator==, operator!=,<br>
|
||||
operator>, operator< <br>
|
||||
operator>=, operator<=</td>
|
||||
<td>A full complement of comparison operators</td>
|
||||
<td>dd1 == dd2, etc</td></tr>
|
||||
<tr><td>time_duration operator+(time_duration) const</td>
|
||||
<td>Add durations.</td>
|
||||
<td>time_duration td1(hours(1)+minutes(2));
|
||||
<br>time_duration td2(seconds(10));
|
||||
<br>time_duration td3 = td1 + td2;</td></tr>
|
||||
<tr><td>time_duration operator-(time_duration) const</td>
|
||||
<td>Subtract durations.</td>
|
||||
<td>time_duration td1(hours(1)+nanosec(2)); <br>
|
||||
time_duration td2 = td1 - minutes(1);</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Thu Feb 13 09:19:15 MST 2003
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>posix_time::time_period Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>posix_time::time_period</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<p>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">Time Period Documentation</font>
|
||||
<p>
|
||||
<a href="#header">Header</a> --
|
||||
<a href="#construct">Construction</a> --
|
||||
<a href="#accessors">Accessors</a> --
|
||||
<a href="#conversiontostring">Conversion To String</a> --
|
||||
<a href="#operators">Operators</a> --
|
||||
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
The class boost::posix_time::time_period provides direct representation for ranges between two times. Periods provide the ability to simplify some types of calculations by simplifing the conditional logic of the program.
|
||||
|
||||
<p>
|
||||
The <a href="exp-time_periods.html">time periods example</a> provides an example of using time periods.
|
||||
<p>
|
||||
<p>
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
|
||||
or
|
||||
#include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
<h2><a name="construct">Construction</a></h2>
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>time_period(ptime begin, ptime last)</td>
|
||||
<td>
|
||||
Create a period as [begin, last). If last is <= begin then
|
||||
the period will be defined as null.
|
||||
</td>
|
||||
<td>date d(2002,Jan,01);<br>
|
||||
ptime t(d, seconds(10)); //10 sec after midnight<br>
|
||||
time_period tp(t, hours(3));</td></tr>
|
||||
<tr><td>time_period(ptime start, ptime end)</td>
|
||||
<td>
|
||||
Create a period as [begin, begin+len). If len is <= zero then
|
||||
the period will be defined as null.
|
||||
</td>
|
||||
<td>date d(2002,Jan,01);<br>
|
||||
ptime t1(d, seconds(10)); //10 sec after midnight<br>
|
||||
ptime t2(d, hours(10)); //10 hours after midnight<br>
|
||||
time_period tp(t1, t2);</td></tr>
|
||||
<tr><td>time_period(time_period rhs)</td>
|
||||
<td>Copy constructor</td>
|
||||
<td>time_period tp1(tp)</td></tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
|
||||
<h2><a name="accessors">Accessors</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>ptime <font class="func">begin</font>() const</td>
|
||||
<td>Return first time of period.</td>
|
||||
<td>date d(2002,Jan,01);<br>
|
||||
ptime t1(d, seconds(10)); //10 sec after midnight<br>
|
||||
ptime t2(d, hours(10)); //10 hours after midnight<br>
|
||||
time_period tp(t1, t2);
|
||||
tp.begin() --> 2002-Jan-01 00:00:10 </td></tr>
|
||||
<tr><td>ptime <font class="func">last</font>() const</td>
|
||||
<td>Return last time in the period</td>
|
||||
<td>date d(2002,Jan,01);<br>
|
||||
ptime t1(d, seconds(10)); //10 sec after midnight<br>
|
||||
ptime t2(d, hours(10)); //10 hours after midnight<br>
|
||||
time_period tp(t1, t2);
|
||||
tp.last() --> 2002-Jan-01 09:59:59.999999999 </td></tr>
|
||||
<tr><td>ptime <font class="func">end</font>() const</td>
|
||||
<td>Return one past the last in period</td>
|
||||
<td>date d(2002,Jan,01);<br>
|
||||
ptime t1(d, seconds(10)); //10 sec after midnight<br>
|
||||
ptime t2(d, hours(10)); //10 hours after midnight<br>
|
||||
time_period tp(t1, t2);
|
||||
tp.last() --> 2002-Jan-01 10:00:00 </td></tr>
|
||||
<tr><td>time_duration <font class="func">length</font>() const</td>
|
||||
<td>Return the length of the time period.</td>
|
||||
<td>date d(2002,Jan,01);<br>
|
||||
ptime t1(d); //midnight<br>
|
||||
time_period tp(t1, hours(1));<br>
|
||||
tp.length() --> 1 hour </td></tr>
|
||||
<tr><td>bool <font class="func">is_null</font>() const</td>
|
||||
<td>True if period is not well formed. eg: start less than end </td>
|
||||
<td></td></tr>
|
||||
<tr><td>bool <font class="func">contains</font>(ptime) const</td>
|
||||
<td>True if ptime is within the period</td>
|
||||
<td>date d(2002,Jan,01);<br>
|
||||
ptime t1(d, seconds(10)); //10 sec after midnight<br>
|
||||
ptime t2(d, hours(10)); //10 hours after midnight<br>
|
||||
ptime t3(d, hours(2)); //2 hours after midnight<br>
|
||||
time_period tp(t1, t2);
|
||||
tp.contains(t3) --> true </td></tr>
|
||||
<tr><td>bool <font class="func">contains</font>(time_period) const</td>
|
||||
<td>True if period is within the period</td>
|
||||
<td>time_period tp1(ptime(d,hours(1)), ptime(d,hours(12)));<br>
|
||||
time_period tp2(ptime(d,hours(2)), ptime(d,hours(4)));<br>
|
||||
tp1.contains(tp2) --> true<br>
|
||||
tp2.contains(tp1) --> false</td></tr>
|
||||
<tr><td>bool <font class="func">intersects</font>(time_period) const</td>
|
||||
<td>True if periods overlap</td>
|
||||
<td>time_period tp1(ptime(d,hours(1)), ptime(d,hours(12)));<br>
|
||||
time_period tp2(ptime(d,hours(2)), ptime(d,hours(4)));<br>
|
||||
tp2.intersects(tp1) --> true</td></tr>
|
||||
<tr><td>time_period <font class="func">intersection</font>(time_period) const</td>
|
||||
<td>Calculate the intersection of 2 periods. Null if no intersection.</td>
|
||||
<td></td></tr>
|
||||
<tr><td>time_period <font class="func">merge</font>(time_period) const</td>
|
||||
<td>Returns union of two periods. Null if no intersection.</td>
|
||||
<td></td></tr>
|
||||
<tr><td>time_period <font class="func">shift</font>(date_duration)</td>
|
||||
<td>Add duration to both start and end.</td>
|
||||
<td></td></tr>
|
||||
|
||||
</table>
|
||||
<p>
|
||||
<h2><a name="conversiontostring">Conversion To String</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>std::string <font class="func">to_simple_string</font>(time_period dp)</td>
|
||||
<td>To [YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff] string where mmm is 3 char month name.</td>
|
||||
<td>[2002-Jan-01 01:25:10.000000001/2002-Jan-31 01:25:10.123456789]</td></tr>
|
||||
|
||||
</table>
|
||||
<p>
|
||||
|
||||
|
||||
<h2><a name="operators">Operators</a></h2>
|
||||
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Syntax</b></td><td><b>Description</b></td><td><b>Example</b></td></tr>
|
||||
<tr><td>operator<<</td>
|
||||
<td>Output streaming operator for time duration. Uses facet to output
|
||||
[date time_of_day/date time_of_day]. The default is format is
|
||||
[YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff] string where
|
||||
mmm is 3 char month name.
|
||||
</td>
|
||||
<td>[2002-Jan-01 01:25:10.000000001/2002-Jan-31 01:25:10.123456789]</td></tr>
|
||||
<tr><td>operator==, operator!=
|
||||
<td>Equality operators. Periods are equal if
|
||||
p1.begin == p2.begin && p1.last == p2.last</td>
|
||||
<td>if (tp1 == tp2) {...</td></tr>
|
||||
<tr><td>operator<</td>
|
||||
<td>Ordering with no overlap. True if tp1.end() less than tp2.begin()</td>
|
||||
<td>if (tp1 < tp2) {...</td></tr>
|
||||
<tr><td>operator></td>
|
||||
<td>Ordering with no overlap. True if tp1.begin() greater than tp2.end()</td>
|
||||
<td>if (tp1 > tp2) {... etc</td></tr>
|
||||
<tr><td>operator<=, operator>=</td>
|
||||
<td>Defined in terms of the other operators.</td>
|
||||
<td> </tr>
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Sat Nov 2 16:01:32 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Date Generators / Algorithms</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>Date Generators / Algorithms</h1>
|
||||
<p> </p>
|
||||
<hr>
|
||||
<p>
|
||||
<p>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">Date Generators / Algorithms</font>
|
||||
<p>
|
||||
<a href="date_algorithms.html#header">Header</a> --
|
||||
<a href="date_algorithms.html#classoverview">Class Overview</a>
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
<p>
|
||||
Date algorithms or generators are tools for generating other dates or schedules of dates. A generator function starts with some part of a date such as a month and day and is supplied another part to then generate a concrete date. This allows the programmer to represent concepts such as "The first Sunday in February" and then create a concrete set of dates when provided with one or more years.
|
||||
<p>
|
||||
<div class="fragment"><pre> <font class="keyword">using</font> <font class="keyword">namespace </font>boost::gregorian;
|
||||
<font class="keyword">typedef</font> boost::date_time::nth_kday_of_month<date></a> nkday;
|
||||
nkday ldgen(nkday::first, Monday, Sep)); <font class="comment">//US labor day</font>
|
||||
date labor_day = ldgen.get_date(2002); <font class="comment">//Calculate labor day for 2002</font>
|
||||
</pre></div>
|
||||
<p>
|
||||
The <a href="exp-print_holidays.html">print holidays example</a> shows a detailed usage example.
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/date_generators.hpp"
|
||||
</pre>
|
||||
|
||||
|
||||
<p>
|
||||
<h2><a name="classoverview">Class Overview</a></h2>
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Class</b></td>
|
||||
<td><b>Construction Parameters</b></td>
|
||||
<td><b>get_date Parameter</b></td>
|
||||
<td><b>Description</b></td>
|
||||
<td><b>Example</b></td></tr>
|
||||
<tr><td><font class="el">first_kday_after</font></td>
|
||||
<td><font class="el">greg_day_of_week</font> day_of_week</td>
|
||||
<td><font class="el">date</font> start_day</td>
|
||||
<td>Calculate something like First Sunday after Jan 1,2002</td>
|
||||
<td>first_kday_after fkaf(Monday);<br>date d = fkaf.get_date(date(2002,Jan,1));<font class="comment">//2002-Jan-07</font></td></tr>
|
||||
<tr><td><font class="el">first_kday_before</font></td>
|
||||
<td><font class="el">greg_day_of_week</font> day_of_week</td>
|
||||
<td><font class="el">date</font> start_day</td>
|
||||
<td>Calculate something like First Monday before Feb 1,2002</td>
|
||||
<td>first_kday_before fkbf(Monday);<br>date d = fkbf.get_date(date(2002,Feb,1));<font class="comment">//2002-Jan-28</font></td></tr>
|
||||
<tr><td><font class="el">last_kday_of_month</font></td>
|
||||
<td><font class="el">greg_day_of_week</font> day_of_week<br><font class="el">greg_month</font> month</td>
|
||||
<td><font class="el">greg_year</font> year</td>
|
||||
<td>Calculate something like last Monday of January</td>
|
||||
<td>last_kday_of_month lkm(Monday,Jan);<br>date d = lkm.get_date(2002);<font class="comment">//2002-Jan-28</font></td></tr>
|
||||
<tr><td><font class="el">first_kday_of_month</font></td>
|
||||
<td><font class="el">greg_day_of_week</font> day_of_week<br><font class="el">greg_month</font> month</td>
|
||||
<td><font class="el">greg_year</font> year</td>
|
||||
<td>Calculate something like first Monday of January</td>
|
||||
<td>first_kday_of_month fkm(Monday,Jan);<br>date d = fkm.get_date(2002);<font class="comment">//2002-Jan-07</font></td></tr>
|
||||
<tr><td><font class="el">partial_date</font></td>
|
||||
<td><font class="el">greg_day</font> day_of_month<br>
|
||||
<font class="el">greg_month</font> month</td>
|
||||
<td><font class="el">greg_year</font> year</td>
|
||||
<td>Generates a date by applying the year to the given month and day.</td>
|
||||
<td>partial_date pd(1,Jan);<br>date d = pd.get_date(2002);<font class="comment">//2002-Jan-01</font></td></tr>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Fri Nov 29 19:40:48 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>gregorian::date iterators Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
<h1>gregorian::date iterators</h1>
|
||||
<p> </p>
|
||||
<hr>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">Date Generators / Algorithms</font>
|
||||
<p>
|
||||
<a href="#intro">Introduction</a> --
|
||||
<a href="#header">Header</a> --
|
||||
<a href="#classoverview">Class Overview</a>
|
||||
<p>
|
||||
<p>
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
Date iterators provide a standard mechanism for iteration through dates.
|
||||
Date iterators are a model of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>
|
||||
and can be used to populate collections with dates and other date generation
|
||||
tasks. For example, the <a href="exp-print_month.html">print month</a> example iterates through all the days in a month and prints them.
|
||||
<p>
|
||||
All of the iterators here derive from boost::gregorian::date_iterator.
|
||||
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
|
||||
or
|
||||
#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
|
||||
</pre>
|
||||
<p>
|
||||
<h2><a name="classoverview">Class Overview</a></h2>
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Class</b></td>
|
||||
<td><b>Construction Parameters</b></td>
|
||||
<td><b>Description</b></td></tr>
|
||||
<tr><td>date_iterator</td>
|
||||
<td></td>
|
||||
<td>Common base class for all day level iterators.</td></tr>
|
||||
<tr><td>day_iterator</td>
|
||||
<td>date start_date, int day_count=1</td>
|
||||
<td>Iterate day_count days at a time.</td></tr>
|
||||
<tr><td>week_iterator</td>
|
||||
<td>date start_date, int week_offset=1</td>
|
||||
<td>Iterate week_offset weeks at a time.</td></tr>
|
||||
<tr><td>month_iterator</td>
|
||||
<td>date start_date, int month_offset=1</td>
|
||||
<td>Iterate month_offset months. There are special rules for
|
||||
handling the end of the month. These are: if start date is last
|
||||
day of the month, always adjust to last day of the month.
|
||||
if date is beyond the end of the month (eg: jan 31 + 1 month)
|
||||
adjust back to end of month.
|
||||
</td></tr>
|
||||
<tr><td>year_iterator</td>
|
||||
<td>date start_date, int year_offset=1</td>
|
||||
<td>Iterate year_offset years</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<hr><address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Thu Sep 5 06:06:41 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
H1 { text-align: center; color: lightcoral; }
|
||||
H2 { margin-top: 0; margin-bottom: 0; color: slateblue; }
|
||||
.bold { font-weight: bold; }
|
||||
.el { text-decoration: none; font-weight: bold; color: lightslateblue }
|
||||
.func { text-decoration: none; font-weight: bold; color: lightslateblue }
|
||||
|
||||
/* table stuff */
|
||||
.row_title {font-weight: bold; background-color: #6699CC; text-align: left;}
|
||||
.content {background-color: #B0E2FF; text-align: left;}
|
||||
.centered {text-align: center;}
|
||||
.nowrap {white-space: nowrap;}
|
||||
|
||||
A.qindex { color: seagreen }
|
||||
A.qindexRef {}
|
||||
A.el { text-decoration: none; font-weight: bold; color: lightslateblue }
|
||||
A.elRef { font-weight: bold; color: red}
|
||||
A.code { text-decoration: none; font-weight: normal; color: darkblue; }
|
||||
A.codeRef { font-weight: normal; }
|
||||
DL.el { margin-left: -1cm }
|
||||
DIV.fragment { width: 100%; border: none; background-color: #eeeeee; }
|
||||
DIV.ah { background-color: black; margin-bottom: 3; margin-top: 3 }
|
||||
/*TD.md { background-color: #f2f2ff }*/
|
||||
/* md == member documentation */
|
||||
TD.md { background-color: lightblue; }
|
||||
DIV.groupHeader { margin-left: 16; margin-top: 12; margin-bottom: 6; font-weight: bold }
|
||||
DIV.groupText { margin-left: 16; font-style: italic; font-size: smaller }
|
||||
FONT.keyword { color: green }
|
||||
FONT.keywordtype { color: green }
|
||||
FONT.keywordflow { color: darkviolet }
|
||||
FONT.comment { color: slateblue }
|
||||
FONT.preprocessor { color: #806020 }
|
||||
FONT.stringliteral { color: #002080 }
|
||||
FONT.charliteral { color: #008080 }
|
||||
@@ -1,73 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Example Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body bgcolor="#ffffff">
|
||||
<!-- Generated by Doxygen 1.2.17 -->
|
||||
<hr><h1>dates_as_strings.cpp</h1> Various parsing and output of strings.
|
||||
<p>
|
||||
<div class="fragment"><pre><font class="comment">/*</font>
|
||||
<font class="comment">The following is a simple example that shows conversion of dates to and </font>
|
||||
<font class="comment">from a std::string.</font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">Expected output:</font>
|
||||
<font class="comment">2001-Oct-09</font>
|
||||
<font class="comment">2001-10-09</font>
|
||||
<font class="comment">Tuesday October 9, 2001</font>
|
||||
<font class="comment">An expected exception is next: </font>
|
||||
<font class="comment"> Exception: Month number is out of range 1..12</font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">*/</font>
|
||||
|
||||
<font class="preprocessor">#include "boost/date_time/gregorian/gregorian.hpp"</font>
|
||||
<font class="preprocessor">#include "boost/date_time/date_parsing.hpp"</font>
|
||||
<font class="preprocessor">#include <iostream></font>
|
||||
<font class="preprocessor">#include <string></font>
|
||||
|
||||
|
||||
|
||||
<font class="keywordtype">int</font>
|
||||
main()
|
||||
{
|
||||
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::gregorian;
|
||||
|
||||
try {
|
||||
<font class="comment">// The following date is in ISO 8601 extended format (CCYY-MM-DD)</font>
|
||||
std::string s(<font class="stringliteral">"2001-10-9"</font>); <font class="comment">//2001-October-05</font>
|
||||
date d(from_string(s));
|
||||
std::cout << to_simple_string(d) << std::endl;
|
||||
|
||||
<font class="comment">//Read ISO Standard(CCYYMMDD) and output ISO Extended</font>
|
||||
std::string ud(<font class="stringliteral">"20011009"</font>); <font class="comment">//2001-Oct-09</font>
|
||||
date d1(from_undelimited_string(ud));
|
||||
std::cout << to_iso_extended_string(d1) << std::endl;
|
||||
|
||||
<font class="comment">//Output the parts of the date - Tuesday October 9, 2001</font>
|
||||
date::ymd_type ymd = d1.year_month_day();
|
||||
greg_weekday wd = d1.day_of_week();
|
||||
std::cout << wd.as_long_string() << <font class="stringliteral">" "</font>
|
||||
<< ymd.month.as_long_string() << <font class="stringliteral">" "</font>
|
||||
<< ymd.day << <font class="stringliteral">", "</font> << ymd.year
|
||||
<< std::endl;
|
||||
|
||||
|
||||
<font class="comment">//Let's send in month 25 by accident and create an exception</font>
|
||||
std::string bad_date(<font class="stringliteral">"20012509"</font>); <font class="comment">//2001-??-09</font>
|
||||
std::cout << <font class="stringliteral">"An expected exception is next: "</font> << std::endl;
|
||||
date wont_construct(from_undelimited_string(bad_date));
|
||||
<font class="comment">//use wont_construct so compiler doesn't complain, but you wont get here!</font>
|
||||
std::cout << <font class="stringliteral">"oh oh, you should reach this line: "</font>
|
||||
<< to_iso_string(wont_construct) << std::endl;
|
||||
}
|
||||
<font class="keywordflow">catch</font>(std::exception& e) {
|
||||
std::cout << <font class="stringliteral">" Exception: "</font> << e.what() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
<font class="keywordflow">return</font> 0;
|
||||
}
|
||||
</pre></div><hr><address><small>
|
||||
Generated Wed Aug 21 16:54:33 2002 by Doxygen for CrystalClear Software © 2000-2002</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,48 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Example Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body bgcolor="#ffffff">
|
||||
<!-- Generated by Doxygen 1.2.17 -->
|
||||
<hr><h1>days_alive.cpp</h1> Calculate the number of days you have been living using durations and dates.
|
||||
<p>
|
||||
<div class="fragment"><pre>
|
||||
<font class="preprocessor">#include "boost/date_time/gregorian/gregorian.hpp"</font>
|
||||
<font class="preprocessor">#include "boost/date_time/date_parsing.hpp"</font>
|
||||
<font class="preprocessor">#include <iostream></font>
|
||||
|
||||
<font class="keywordtype">int</font>
|
||||
main()
|
||||
{
|
||||
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::gregorian;
|
||||
std::string s;
|
||||
std::cout << "Enter birth day YYYY-MM-DD (eg: 2002-02-01): ";
|
||||
std::cin >> s;
|
||||
try {
|
||||
date birthday(boost::date_time::parse_date<date>(s));
|
||||
<font class="comment">//date birthday(2002,Jan,1);</font>
|
||||
date today = day_clock::local_day();
|
||||
date_duration days_alive = today - birthday;
|
||||
date_duration one_day(1);
|
||||
<font class="keywordflow">if</font> (days_alive == one_day) {
|
||||
std::cout << <font class="stringliteral">"Born yesterday, very funny"</font> << std::endl;
|
||||
}
|
||||
<font class="keywordflow">else</font> <font class="keywordflow">if</font> (days_alive < date_duration(0)) {
|
||||
std::cout << <font class="stringliteral">"Not born yet, hmm: "</font> << days_alive.days()
|
||||
<< <font class="stringliteral">" days"</font> <<std::endl;
|
||||
}
|
||||
<font class="keywordflow">else</font> {
|
||||
std::cout << <font class="stringliteral">"Days alive: "</font> << days_alive.days() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
<font class="keywordflow">catch</font>(...) {
|
||||
std::cout << <font class="stringliteral">"Bad date entered: "</font> << s << std::endl;
|
||||
}
|
||||
<font class="keywordflow">return</font> 0;
|
||||
};
|
||||
</pre></div><hr><address><small>
|
||||
Generated Wed Aug 21 16:54:33 2002 by Doxygen for CrystalClear Software © 2000-2002</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,30 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Example Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body bgcolor="#ffffff">
|
||||
<!-- Generated by Doxygen 1.2.17 -->
|
||||
<hr><h1>days_till_new_year.cpp</h1> Calculate the number of days till new years
|
||||
<p>
|
||||
<div class="fragment"><pre><font class="comment">// This example displays the amount of time until new year's in days</font>
|
||||
|
||||
<font class="preprocessor">#include "boost/date_time/gregorian/gregorian.hpp"</font>
|
||||
<font class="preprocessor">#include <iostream></font>
|
||||
|
||||
<font class="keywordtype">int</font>
|
||||
main()
|
||||
{
|
||||
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::gregorian;
|
||||
|
||||
date::ymd_type today = day_clock::local_day_ymd();
|
||||
date new_years_day(today.year + 1,1,1);
|
||||
date_duration dd = new_years_day - date(today);
|
||||
|
||||
std::cout << "Days till new year: " << dd.days() << std::endl;
|
||||
return 0;
|
||||
};
|
||||
</pre></div><hr><address><small>
|
||||
Generated Wed Aug 21 16:54:33 2002 by Doxygen for CrystalClear Software © 2000-2002</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,96 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Example Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body bgcolor="#ffffff">
|
||||
<!-- Generated by Doxygen 1.2.17 -->
|
||||
<hr><h1>local_utc_conversion.cpp</h1> Demonstrate utc to local and local to utc calculations including dst.
|
||||
<p>
|
||||
<div class="fragment"><pre><font class="comment">//Demonstrate conversions between a local time and utc</font>
|
||||
<font class="comment">/* Output:</font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">UTC <--> New York while DST is NOT active (5 hours)</font>
|
||||
<font class="comment">2001-Dec-31 19:00:00 in New York is 2002-Jan-01 00:00:00 UTC time </font>
|
||||
<font class="comment">2002-Jan-01 00:00:00 UTC is 2001-Dec-31 19:00:00 New York time </font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">UTC <--> New York while DST is active (4 hours)</font>
|
||||
<font class="comment">2002-May-31 20:00:00 in New York is 2002-Jun-01 00:00:00 UTC time </font>
|
||||
<font class="comment">2002-Jun-01 00:00:00 UTC is 2002-May-31 20:00:00 New York time </font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">UTC <--> Arizona (7 hours)</font>
|
||||
<font class="comment">2002-May-31 17:00:00 in Arizona is 2002-Jun-01 00:00:00 UTC time </font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">*/</font>
|
||||
|
||||
|
||||
<font class="preprocessor">#include "boost/date_time/posix_time/posix_time.hpp"</font>
|
||||
<font class="preprocessor">#include "boost/date_time/local_time_adjustor.hpp"</font>
|
||||
<font class="preprocessor">#include "boost/date_time/c_local_time_adjustor.hpp"</font>
|
||||
<font class="preprocessor">#include <iostream></font>
|
||||
|
||||
<font class="keywordtype">int</font>
|
||||
main()
|
||||
{
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::posix_time;
|
||||
using namespace boost::gregorian;
|
||||
|
||||
<font class="comment">//This local adjustor depends on the machine TZ settings-- highly dangerous!</font>
|
||||
typedef boost::date_time::c_local_adjustor<ptime> local_adj;
|
||||
ptime t10(date(2002,Jan,1), hours(7));
|
||||
ptime t11 = local_adj::utc_to_local(t10);
|
||||
std::cout << "UTC <--> Zone base on TZ setting" << std::endl;
|
||||
std::cout << to_simple_string(t11) << " in your TZ is "
|
||||
<< to_simple_string(t10) << " UTC time "
|
||||
<< std::endl;
|
||||
time_duration td = t11 - t10;
|
||||
std::cout << "A difference of: "
|
||||
<< to_simple_string(td) << std::endl;
|
||||
|
||||
|
||||
<font class="comment">//eastern timezone is utc-5</font>
|
||||
typedef boost::date_time::local_adjustor<ptime, -5, us_dst> us_eastern;
|
||||
|
||||
ptime t1(date(2001,Dec,31), hours(19)); <font class="comment">//5 hours b/f midnight NY time</font>
|
||||
|
||||
std::cout << "\nUTC <--> New York while DST is NOT active (5 hours)"
|
||||
<< std::endl;
|
||||
ptime t2 = us_eastern::local_to_utc(t1);
|
||||
std::cout << to_simple_string(t1) << " in New York is "
|
||||
<< to_simple_string(t2) << " UTC time "
|
||||
<< std::endl;
|
||||
|
||||
ptime t3 = us_eastern::utc_to_local(t2);<font class="comment">//back should be the same</font>
|
||||
std::cout << to_simple_string(t2) << " UTC is "
|
||||
<< to_simple_string(t3) << " New York time "
|
||||
<< "\n\n";
|
||||
|
||||
ptime t4(date(2002,May,31), hours(20)); <font class="comment">//4 hours b/f midnight NY time</font>
|
||||
std::cout << "UTC <--> New York while DST is active (4 hours)" << std::endl;
|
||||
ptime t5 = us_eastern::local_to_utc(t4);
|
||||
std::cout << to_simple_string(t4) << " in New York is "
|
||||
<< to_simple_string(t5) << " UTC time "
|
||||
<< std::endl;
|
||||
|
||||
ptime t6 = us_eastern::utc_to_local(t5);<font class="comment">//back should be the same</font>
|
||||
std::cout << to_simple_string(t5) << " UTC is "
|
||||
<< to_simple_string(t6) << " New York time "
|
||||
<< "\n" << std::endl;
|
||||
|
||||
|
||||
<font class="comment">//Arizona timezone is utc-7 with no dst</font>
|
||||
typedef boost::date_time::local_adjustor<ptime, -7, no_dst> us_arizona;
|
||||
|
||||
ptime t7(date(2002,May,31), hours(17));
|
||||
std::cout << "UTC <--> Arizona (7 hours)" << std::endl;
|
||||
ptime t8 = us_arizona::local_to_utc(t7);
|
||||
std::cout << to_simple_string(t7) << " in Arizona is "
|
||||
<< to_simple_string(t8) << " UTC time "
|
||||
<< std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
</pre></div><hr><address><small>
|
||||
Generated Wed Aug 21 16:54:33 2002 by Doxygen for CrystalClear Software © 2000-2002</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,90 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Example Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body bgcolor="#ffffff">
|
||||
<!-- Generated by Doxygen 1.2.17 -->
|
||||
<hr><h1>period_calc.cpp</h1> Calculates if a date is in an 'irregular' collection of periods using period calculation functions.
|
||||
<p>
|
||||
<div class="fragment"><pre><font class="comment">/*</font>
|
||||
<font class="comment">This example demonstrates a simple use of periods for the calculation</font>
|
||||
<font class="comment">of date information.</font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">The example calculates if a given date is a weekend or holiday</font>
|
||||
<font class="comment">given an exclusion set. That is, each weekend or holiday is</font>
|
||||
<font class="comment">entered into the set as a time interval. Then if a given date</font>
|
||||
<font class="comment">is contained within any of the intervals it is considered to</font>
|
||||
<font class="comment">be within the exclusion set and hence is a offtime.</font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">Output:</font>
|
||||
<font class="comment">Number Excluded Periods: 5</font>
|
||||
<font class="comment">20020202/20020203</font>
|
||||
<font class="comment">20020209/20020210</font>
|
||||
<font class="comment">20020212/20020212</font>
|
||||
<font class="comment">20020216/20020217</font>
|
||||
<font class="comment">In Exclusion Period: 20020216 --> 20020216/20020217</font>
|
||||
<font class="comment">20020223/20020224</font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">*/</font>
|
||||
|
||||
|
||||
<font class="preprocessor">#include "boost/date_time/gregorian/gregorian.hpp"</font>
|
||||
<font class="preprocessor">#include <set></font>
|
||||
<font class="preprocessor">#include <algorithm></font>
|
||||
<font class="preprocessor">#include <iostream></font>
|
||||
|
||||
<font class="keyword">typedef</font> std::set<boost::gregorian::date_period> date_period_set;
|
||||
|
||||
<font class="comment">//Simple population of the exclusion set</font>
|
||||
date_period_set
|
||||
generateExclusion()
|
||||
{
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::gregorian;
|
||||
date_period periods_array[] =
|
||||
{ date_period(date(2002,Feb,2), date(2002,Feb,4)),<font class="comment">//weekend of 2nd-3rd</font>
|
||||
date_period(date(2002,Feb,9), date(2002,Feb,11)),
|
||||
date_period(date(2002,Feb,16), date(2002,Feb,18)),
|
||||
date_period(date(2002,Feb,23), date(2002,Feb,25)),
|
||||
date_period(date(2002,Feb,12), date(2002,Feb,13))<font class="comment">//a random holiday 2-12</font>
|
||||
};
|
||||
<font class="keyword">const</font> <font class="keywordtype">int</font> num_periods = <font class="keyword">sizeof</font>(periods_array)/<font class="keyword">sizeof</font>(date_period);
|
||||
|
||||
date_period_set ps;
|
||||
<font class="comment">//insert the periods in the set</font>
|
||||
std::insert_iterator<date_period_set> itr(ps, ps.begin());
|
||||
std::copy(periods_array, periods_array+num_periods, itr );
|
||||
<font class="keywordflow">return</font> ps;
|
||||
|
||||
}
|
||||
|
||||
|
||||
<font class="keywordtype">int</font> main()
|
||||
{
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::gregorian;
|
||||
|
||||
date_period_set ps = generateExclusion();
|
||||
std::cout << "Number Excluded Periods: " << ps.size() << std::endl;
|
||||
|
||||
date d(2002,Feb,16);
|
||||
date_period_set::const_iterator i = ps.begin();
|
||||
<font class="comment">//print the periods, check for containment</font>
|
||||
for (;i != ps.end(); i++) {
|
||||
std::cout << to_iso_string(*i) << std::endl;
|
||||
<font class="comment">//if date is in exclusion period then print it</font>
|
||||
if (i->contains(d)) {
|
||||
std::cout << "In Exclusion Period: "
|
||||
<< to_iso_string(d) << " --> " << to_iso_string(*i)
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</pre></div><hr><address><small>
|
||||
Generated Wed Aug 21 16:54:33 2002 by Doxygen for CrystalClear Software © 2000-2002</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,110 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example Documentation</title><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body bgcolor="#ffffff"> <!-- Generated by Doxygen 1.2.17 -->
|
||||
<hr>
|
||||
<h1>print_holidays.cpp</h1>
|
||||
This is an example of using functors to define a holiday schedule
|
||||
<p></p>
|
||||
<div class="fragment" id="DIV1"><pre><font class="comment">/*generate a set of dates using a collections of date generators</font>
|
||||
<font class="comment">Output looks like:</font>
|
||||
<font class="comment">Enter Year: 2002</font>
|
||||
<font class="comment">2002-Jan-01 [Tue]</font>
|
||||
<font class="comment">2002-Jan-21 [Mon]</font>
|
||||
<font class="comment">2002-Feb-12 [Tue]</font>
|
||||
<font class="comment">2002-Jul-04 [Thu]</font>
|
||||
<font class="comment">2002-Sep-02 [Mon]</font>
|
||||
<font class="comment">2002-Nov-28 [Thu]</font>
|
||||
<font class="comment">2002-Dec-25 [Wed]</font>
|
||||
<font class="comment">Number Holidays: 7</font>
|
||||
<font class="comment">*/</font>
|
||||
|
||||
|
||||
<font class="preprocessor">#include "boost/date_time/gregorian/gregorian.hpp"</font>
|
||||
<font class="preprocessor">#include <algorithm></font>
|
||||
<font class="preprocessor">#include <functional></font>
|
||||
<font class="preprocessor">#include <vector></font>
|
||||
<font class="preprocessor">#include <iostream></font>
|
||||
<font class="preprocessor">#include <set></font>
|
||||
|
||||
|
||||
<font class="keywordtype">void</font>
|
||||
print_date(boost::gregorian::date d)
|
||||
{
|
||||
std::cout << d << <font class="stringliteral">" ["</font> << d.day_of_week() << <font class="stringliteral">"]\n"</font>;
|
||||
}
|
||||
|
||||
|
||||
<font class="keywordtype">int</font>
|
||||
main() {
|
||||
|
||||
std::cout << <font class="stringliteral">"Enter Year: "</font>;
|
||||
<font class="keywordtype">int</font> year;
|
||||
std::cin >> year;
|
||||
|
||||
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::gregorian;
|
||||
|
||||
<font class="comment">//define a collection of holidays fixed by month and day</font>
|
||||
std::vector<partial_date> holidays;
|
||||
holidays.push_back(partial_date(1, Jan)); <font class="comment">//Western New Year</font>
|
||||
holidays.push_back(partial_date(4, Jul)); <font class="comment">//US Independence Day</font>
|
||||
holidays.push_back(partial_date(25, Dec));<font class="comment">//Christmas day</font>
|
||||
|
||||
|
||||
<font class="comment">//define a shorthand for the nkday function object</font>
|
||||
typedef boost::date_time::nth_kday_of_month<date> nkday;
|
||||
<font class="comment">//define a collection of nth kday holidays</font>
|
||||
std::vector<nkday> more_holidays;
|
||||
more_holidays.push_back(nkday(nkday::first, Monday, Sep)); <font class="comment">//US labor day</font>
|
||||
more_holidays.push_back(nkday(nkday::third, Monday, Jan)); <font class="comment">//MLK Day</font>
|
||||
more_holidays.push_back(nkday(nkday::second, Tuesday, Feb)); <font class="comment">//Pres day</font>
|
||||
more_holidays.push_back(nkday(nkday::fourth, Thursday, Nov)); <font class="comment">//Thanksgiving</font>
|
||||
|
||||
typedef std::set<date> date_set;
|
||||
date_set all_holidays;
|
||||
|
||||
#if (defined(BOOST_MSVC) && (_MSC_VER <= 1200)) <font class="comment">// 1200 == VC++ 6.0</font>
|
||||
std::cout << "Sorry, this example temporarily disabled on VC 6.\n"
|
||||
<< "The std::transform isn't accepted by the compiler\n"
|
||||
<< "So if you hack up the example without std::transform\n"
|
||||
<< "it should work\n"
|
||||
<< std::endl;
|
||||
|
||||
#else
|
||||
|
||||
<font class="comment">//generate a set of concrete dates from the 'partial_date' holidays</font>
|
||||
<font class="comment">//by calling the get_date functions</font>
|
||||
std::transform(holidays.begin(), holidays.end(),
|
||||
std::insert_iterator<date_set>(all_holidays, all_holidays.begin()),
|
||||
std::bind2nd(std::mem_fun_ref(&partial_date::get_date),
|
||||
year));
|
||||
|
||||
<font class="comment">//Now add in the 'floating' holidays </font>
|
||||
std::transform(more_holidays.begin(), more_holidays.end(),
|
||||
std::insert_iterator<date_set>(all_holidays, all_holidays.begin()),
|
||||
std::bind2nd(std::mem_fun_ref(&nkday::get_date),
|
||||
year));
|
||||
|
||||
|
||||
|
||||
<font class="comment">//print the holidays to the screen</font>
|
||||
std::for_each(all_holidays.begin(), all_holidays.end(), print_date);
|
||||
std::cout << "Number Holidays: " << all_holidays.size() << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
<hr>
|
||||
<address><small> Generated Wed Aug 21 16:54:33 2002 by Doxygen for CrystalClear
|
||||
Software © 2000-2002</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Example Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body bgcolor="#ffffff">
|
||||
<!-- Generated by Doxygen 1.2.17 -->
|
||||
<hr><h1>print_hours.cpp</h1> Demonstrate time iteration, clock retrieval, and simple calculation.
|
||||
<p>
|
||||
<div class="fragment"><pre><font class="comment">//Print the remaining hours of the day</font>
|
||||
<font class="comment">//Uses the clock to get the local time </font>
|
||||
<font class="comment">//Use an iterator to iterate over the remaining hours</font>
|
||||
<font class="comment">//Retrieve the date part from a time</font>
|
||||
<font class="comment">/* Expected Output something like:</font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">2002-Mar-08 16:30:59</font>
|
||||
<font class="comment">2002-Mar-08 17:30:59</font>
|
||||
<font class="comment">2002-Mar-08 18:30:59</font>
|
||||
<font class="comment">2002-Mar-08 19:30:59</font>
|
||||
<font class="comment">2002-Mar-08 20:30:59</font>
|
||||
<font class="comment">2002-Mar-08 21:30:59</font>
|
||||
<font class="comment">2002-Mar-08 22:30:59</font>
|
||||
<font class="comment">2002-Mar-08 23:30:59</font>
|
||||
<font class="comment">Time left till midnight: 07:29:01</font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">*/</font>
|
||||
|
||||
|
||||
<font class="preprocessor">#include "boost/date_time/posix_time/posix_time.hpp"</font>
|
||||
<font class="preprocessor">#include <iostream></font>
|
||||
|
||||
|
||||
<font class="keywordtype">int</font>
|
||||
main()
|
||||
{
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::posix_time;
|
||||
using namespace boost::gregorian;
|
||||
|
||||
<font class="comment">//get the current time from the clock -- one second resolution</font>
|
||||
ptime now = second_clock::local_time();
|
||||
<font class="comment">//Get the date part out of the time</font>
|
||||
date today = now.date();
|
||||
date tommorrow = today + date_duration(1);
|
||||
ptime tommorrow_start(tommorrow); <font class="comment">//midnight </font>
|
||||
|
||||
<font class="comment">//iterator adds by one hour</font>
|
||||
time_iterator titr(now,hours(1));
|
||||
for (; titr < tommorrow_start; ++titr) {
|
||||
std::cout << to_simple_string(*titr) << std::endl;
|
||||
}
|
||||
|
||||
time_duration remaining = tommorrow_start - now;
|
||||
std::cout << "Time left till midnight: "
|
||||
<< to_simple_string(remaining) << std::endl;
|
||||
return 0;
|
||||
}
|
||||
</pre></div><hr><address><small>
|
||||
Generated Thu Sep 5 05:52:10 2002 by Doxygen for CrystalClear Software © 2000-2002</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,70 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Example Documentation</title><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body bgcolor="#ffffff"> <!-- Generated by Doxygen 1.2.17 -->
|
||||
<hr>
|
||||
<h1>print_month.cpp</h1>
|
||||
Simple utility to print out days of the month with the days of a month.
|
||||
Demontstrates date iteration (date_time::date_itr).
|
||||
<p></p>
|
||||
<div class="fragment" id="DIV1"><pre><font class="comment">/*</font>
|
||||
<font class="comment">This example prints all the dates in a month. It demonstrates</font>
|
||||
<font class="comment">the use of iterators as well as functions of the gregorian_calendar</font>
|
||||
<font class="comment"></font>
|
||||
<font class="comment">Output:</font>
|
||||
<font class="comment">Enter Year: 2002</font>
|
||||
<font class="comment">Enter Month(1..12): 2</font>
|
||||
<font class="comment">2002-Feb-01 [Fri]</font>
|
||||
<font class="comment">2002-Feb-02 [Sat]</font>
|
||||
<font class="comment">2002-Feb-03 [Sun]</font>
|
||||
<font class="comment">2002-Feb-04 [Mon]</font>
|
||||
<font class="comment">2002-Feb-05 [Tue]</font>
|
||||
<font class="comment">2002-Feb-06 [Wed]</font>
|
||||
<font class="comment">2002-Feb-07 [Thu]</font>
|
||||
<font class="comment">*/</font>
|
||||
|
||||
<font class="preprocessor">#include "boost/date_time/gregorian/gregorian.hpp"</font>
|
||||
<font class="preprocessor">#include <iostream></font>
|
||||
|
||||
<font class="keywordtype">int</font>
|
||||
main()
|
||||
{
|
||||
std::cout << <font class="stringliteral">"Enter Year: "</font>;
|
||||
<font class="keywordtype">int</font> year, month;
|
||||
std::cin >> year;
|
||||
std::cout << <font class="stringliteral">"Enter Month(1..12): "</font>;
|
||||
std::cin >> month;
|
||||
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::gregorian;
|
||||
try {
|
||||
<font class="comment">//Use the calendar to get the last day of the month</font>
|
||||
<font class="keywordtype">int</font> eom_day = gregorian_calendar::end_of_month_day(year,month);
|
||||
date endOfMonth(year,month,eom_day);
|
||||
|
||||
<font class="comment">//construct an iterator starting with first day of the month</font>
|
||||
day_iterator ditr(date(year,month,1));
|
||||
<font class="comment">//loop thru the days and print each one</font>
|
||||
<font class="keywordflow">for</font> (; ditr <= endOfMonth; ++ditr) {
|
||||
std::cout << *ditr << <font class="stringliteral">" ["</font>
|
||||
<< ditr->day_of_week() << <font class="stringliteral">"]"</font>
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
<font class="keywordflow">catch</font>(std::exception& e) {
|
||||
|
||||
std::cout << <font class="stringliteral">"Error bad date, check your entry: \n"</font>
|
||||
<< <font class="stringliteral">" Details: "</font> << e.what() << std::endl;
|
||||
}
|
||||
<font class="keywordflow">return</font> 0;
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
<hr>
|
||||
<address><small> Generated Wed Aug 21 16:54:33 2002 by Doxygen for CrystalClear
|
||||
Software © 2000-2002</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Example Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body bgcolor="#ffffff">
|
||||
<!-- Generated by Doxygen 1.2.17 -->
|
||||
<hr><h1>time_math.cpp</h1> Various types of calculations with times and time durations.
|
||||
<p>
|
||||
<div class="fragment"><pre><font class="comment">//Some simple examples of constructing and calculating with times</font>
|
||||
<font class="comment">//Output:</font>
|
||||
<font class="comment">//2002-Feb-01 00:00:00 - 2002-Feb-01 05:04:02.001000000 = -5:04:02.001000000</font>
|
||||
|
||||
<font class="preprocessor">#include "boost/date_time/posix_time/posix_time.hpp"</font>
|
||||
<font class="preprocessor">#include <iostream></font>
|
||||
|
||||
<font class="keywordtype">int</font>
|
||||
main()
|
||||
{
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::posix_time;
|
||||
using namespace boost::gregorian;
|
||||
|
||||
date d(2002,Feb,1); <font class="comment">//an arbitrary date</font>
|
||||
<font class="comment">//construct a time by adding up some durations durations</font>
|
||||
ptime t1(d, hours(5)+minutes(4)+seconds(2)+millisec(1));
|
||||
<font class="comment">//construct a new time by subtracting some times</font>
|
||||
ptime t2 = t1 - hours(5)- minutes(4)- seconds(2)- millisec(1);
|
||||
<font class="comment">//construct a duration by taking the difference between times</font>
|
||||
time_duration td = t2 - t1;
|
||||
|
||||
std::cout << to_simple_string(t2) << " - "
|
||||
<< to_simple_string(t1) << " = "
|
||||
<< to_simple_string(td) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
</pre></div><hr><address><small>
|
||||
Generated Wed Aug 21 16:54:33 2002 by Doxygen for CrystalClear Software © 2000-2002</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,62 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Example Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body bgcolor="#ffffff">
|
||||
<!-- Generated by Doxygen 1.2.17 -->
|
||||
<hr><h1>time_periods.cpp</h1> Demonstrate some simple uses of time periods.
|
||||
<p>
|
||||
<div class="fragment"><pre><font class="comment">//Some simple examples of constructing and calculating with times</font>
|
||||
<font class="comment">//Returns:</font>
|
||||
<font class="comment">//[2002-Feb-01 00:00:00/2002-Feb-01 23:59:59.999999999] contains 2002-Feb-01 03:00:05</font>
|
||||
<font class="comment">//[2002-Feb-01 00:00:00/2002-Feb-01 23:59:59.999999999] intersected with</font>
|
||||
<font class="comment">//[2002-Feb-01 00:00:00/2002-Feb-01 03:00:04.999999999] is </font>
|
||||
<font class="comment">//[2002-Feb-01 00:00:00/2002-Feb-01 03:00:04.999999999]</font>
|
||||
|
||||
|
||||
<font class="preprocessor">#include "boost/date_time/posix_time/posix_time.hpp"</font>
|
||||
<font class="preprocessor">#include <iostream></font>
|
||||
|
||||
<font class="keyword">using</font> <font class="keyword">namespace </font>boost::posix_time;
|
||||
using namespace boost::gregorian;
|
||||
|
||||
<font class="comment">//Create a simple period class to contain all the times in a day</font>
|
||||
class day_period : <font class="keyword">public</font> time_period
|
||||
{
|
||||
<font class="keyword">public</font>:
|
||||
day_period(date d) : time_period(ptime(d),<font class="comment">//midnight</font>
|
||||
ptime(d,hours(24)))
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
<font class="keywordtype">int</font>
|
||||
main()
|
||||
{
|
||||
|
||||
date d(2002,Feb,1); <font class="comment">//an arbitrary date</font>
|
||||
<font class="comment">//a period that represents a day </font>
|
||||
day_period dp(d);
|
||||
ptime t(d, hours(3)+seconds(5)); <font class="comment">//an arbitray time on that day</font>
|
||||
<font class="keywordflow">if</font> (dp.contains(t)) {
|
||||
std::cout << to_simple_string(dp) << <font class="stringliteral">" contains "</font>
|
||||
<< to_simple_string(t) << std::endl;
|
||||
}
|
||||
<font class="comment">//a period that represents part of the day</font>
|
||||
time_period part_of_day(ptime(d, hours(0)), t);
|
||||
<font class="comment">//intersect the 2 periods and print the results</font>
|
||||
<font class="keywordflow">if</font> (part_of_day.intersects(dp)) {
|
||||
time_period result = part_of_day.intersection(dp);
|
||||
std::cout << to_simple_string(dp) << <font class="stringliteral">" intersected with\n"</font>
|
||||
<< to_simple_string(part_of_day) << <font class="stringliteral">" is \n"</font>
|
||||
<< to_simple_string(result) << std::endl;
|
||||
}
|
||||
|
||||
|
||||
<font class="keywordflow">return</font> 0;
|
||||
}
|
||||
|
||||
</pre></div><hr><address><small>
|
||||
Generated Thu Sep 5 05:52:10 2002 by Doxygen for CrystalClear Software © 2000-2002</small></address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,90 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Gregorian Date System Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
<p>
|
||||
<h1>Gregorian Date System Documentation</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<a href="index.html">Overall Index</a>
|
||||
<p>
|
||||
<a href="#intro">Introduction</a> --
|
||||
<a href="#usage">Usage Examples</a><p>
|
||||
<font class="bold">Temporal Types</font>
|
||||
<p>
|
||||
<a href="class_date.html">Class date</a> --
|
||||
<a href="class_date_duration.html">Class date_duration</a> --
|
||||
<a href="class_date_period.html">Class date_period</a>
|
||||
<p>
|
||||
<font class="bold">Other Topics</font>
|
||||
<p>
|
||||
<a href="date_iterators.html">Date Iterators</a> --
|
||||
<a href="date_algorithms.html">Date Generators / Algorithms</a> --
|
||||
<a href="class_gregorian_calendar.html">Class gregorian_calendar</a> --
|
||||
<a href="class_date.html#constructfromclock">Class day_clock</a>
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
The gregorian date system provides a date programming system based the
|
||||
Gregorian Calendar. The first introduction of the Gregorian calendar was
|
||||
in 1582 to fix an error in the Julian Calendar. However, many local
|
||||
jurisdications did not adopt this change until much later. Thus there
|
||||
is potential confusion with historical dates.
|
||||
<p>
|
||||
The implemented calendar is a "propleptic Gregorian calendar" which extends
|
||||
dates back prior to the Gregorian Calendar's first adoption in in 1582.
|
||||
The current implementation supports dates in the range
|
||||
1400-Jan-01 to 10000-Jan-01. Many references will represent dates
|
||||
prior to 1582 using the Julian Calendar, so caution is in order if
|
||||
accurate calculations are required on historic
|
||||
dates.
|
||||
See <A href="http://emr.cs.iit.edu/home/reingold/calendar-book/second-edition/">Calendrical Calculations</A> by Reingold & Dershowitz for more details.
|
||||
Date information from Calendrical Calculations has been used to cross-test
|
||||
the correctness of the Gregorian calendar implementation.
|
||||
<p>
|
||||
All types for the gregorian system are found in namespace boost::gregorian.
|
||||
The library supports a convience header <font class="el">boost/date_time/gregorian/gregorian_types.hpp</font> that will include all the classes of the
|
||||
library with no input/output dependency.
|
||||
Another header <font class="el">boost/date_time/gregorian/gregorian.hpp</font> will include the types and the input/output code.
|
||||
<p>
|
||||
The class <a href="class_date.html">boost::gregorian::date</a> is the primary
|
||||
temporal type for users. If you are interested in learning about writing
|
||||
programs do specialized date calculations such as finding the
|
||||
"first sunday in april" see the
|
||||
<a href="date_algorithms.html">date generators and algorithms page</a>.
|
||||
|
||||
|
||||
<p>
|
||||
<h2><a name="usage">Usage Examples</a></h2>
|
||||
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3><tr><td><b>Example</b></td><td><b>Description</b> </td></tr>
|
||||
<tr><td><a href="exp-days_alive.html">Days Alive</a> <a href="exp-days_till_new_year.html">Days Till New Year</a></td><td>Simple date arithmetic. Retrieve current day from clock. </td></tr>
|
||||
<tr><td><a href="exp-dates_as_strings.html">Dates as strings</a></td><td>Simple parsing and formmatting of dates from/to strings </td></tr>
|
||||
<tr><td><a href="exp-period_calc.html">Date Period Calculations</a></td><td>See if a date is in a set of date periods (eg: is it a holiday/weekend) </td></tr>
|
||||
<tr><td><a href="exp-print_month.html">Print a month</a></td><td>Small utility program which prints out all the days in a month from command line. Need to know if 1999-Jan-1 was a Friday or a Saturday? This program shows how to do it. </td></tr>
|
||||
<tr><td><a href="exp-print_holidays.html">Print Holidays</a></td><td>Uses date generators to convert abstract specification into concrete set of dates. </td></table>
|
||||
|
||||
<p>
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Sun Feb 9 06:52:31 MST 2003
|
||||
<!-- hhmts end -->
|
||||
by Jeff Garland © 2000-2002
|
||||
</small></address>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+9
-219
@@ -1,223 +1,13 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Boost Date-Time Library Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=../../../doc/html/date_time.html">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>Boost Date-Time Library Documentation</h1>
|
||||
<p>
|
||||
<h3 align="center">Version 1.01</h3>
|
||||
<hr>
|
||||
|
||||
<h2><a name="contents">Contents</a></h2>
|
||||
<p>
|
||||
<font class="bold">Overview</font><br><br>
|
||||
|
||||
<p>
|
||||
<a href="#intro">Introduction</a> --
|
||||
<a href="#motivation">Motivation</a> --
|
||||
<a href="#usage">Usage Examples</a> --
|
||||
<a href="#domain">Domain Concepts</a> --
|
||||
<a href="#design">Design and Extensions</a> --
|
||||
<a href="#acknowledge">Acknowledgements</a> --
|
||||
<a href="#more">More Info</a>
|
||||
<p>
|
||||
<a href="BuildInfo.html">Build-Compiler Information</a> --
|
||||
<a href="Changes.html">Change History</a> --
|
||||
<a href="#test">Tests</a> --
|
||||
<a href="license.html">License</a> --
|
||||
<a href="BasicTerms.html">Basic Terminology Reference</a> --
|
||||
<a href="References.html">References</a>
|
||||
|
||||
<p>
|
||||
<font class="bold">Date Programming</font><br><br>
|
||||
<a href="gregorian.html">Gregorian Date System</a><br>
|
||||
<ul>
|
||||
<li><a href="class_date.html">Class date</a>
|
||||
<li><a href="class_date_duration.html">Class date_duration</a>
|
||||
<li><a href="class_date_period.html">Class date_period</a>
|
||||
<li><a href="date_iterators.html">Date Iterators</a>
|
||||
<li><a href="date_algorithms.html">Date Generators / Algorithms</a>
|
||||
<li><a href="class_gregorian_calendar.html">Class gregorian_calendar</a>
|
||||
<li><a href="class_date.html#constructfromclock">Class day_clock</a>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<font class="bold">Time Programming</font><br><br>
|
||||
<a href="posix_time.html">Posix Time System</a><br>
|
||||
|
||||
<ul>
|
||||
<li><a href="class_ptime.html">Class ptime</a>
|
||||
<li><a href="class_time_duration.html">Class time_duration</a>
|
||||
<li><a href="class_time_period.html">Class time_period</a>
|
||||
<li><a href="time_iterators.html">Time Iterators</a>
|
||||
<li><a href="local_time_adjust.html">UTC / Local Time Adjustments</a>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
A set of date-time libraries based on generic programming concepts.
|
||||
<p>
|
||||
<h2><a name="motivation">Motivation</a></h2>
|
||||
|
||||
<p>
|
||||
The motivation for this library comes from working with and helping build several date-time libraries on several projects. Date-time libraries provide fundamental infrastructure for most development projects. However, most of them have limitations in their ability to calculate, format, convert, or perform some other functionality. For example, most libraries do not correctly handle leap seconds, provide concepts such as infinity, or provide the ability to use high resolution or network time sources. These libraries also tend to be rigid in their representation of dates and times. Thus customized policies for a project or subproject are not possible.
|
||||
<p>
|
||||
Programming with dates and times should be almost as simple and natural as programming with strings and integers. Applications with lots of temporal logic can be radically simplified by having a robust set of operators and calculation capabilities. Classes should provide the ability to compare dates and times, add lengths or time durations, retrieve dates and times from clocks, and work naturally with date and time intervals.
|
||||
<p>
|
||||
<h2><a name="usage">Usage Examples</a></h2>
|
||||
|
||||
<p>
|
||||
The following shows examples of the sorts of code that can be written using the gregorian date system. See <a href="gregorian.html">Date Programming</a> for more details.
|
||||
<p>
|
||||
<div class="fragment"><pre> <font class="keyword">using</font> <font class="keyword">namespace </font>boost::gregorian;
|
||||
date weekstart(2002,Feb,1);
|
||||
date weekend (2002,Feb,7);
|
||||
date_duration fiveDays(5);
|
||||
date d3 = d1 + fiveDays;
|
||||
date today = day_clock::local_day();
|
||||
<font class="keywordflow">if</font> (d3 >= today) {} <font class="comment">//date comparison operators</font>
|
||||
|
||||
date_period thisWeek(d1,d2);
|
||||
<font class="keywordflow">if</font> (thisWeek.contains(today)) {}<font class="comment">//do something</font>
|
||||
|
||||
<font class="comment">//iterate and print the week</font>
|
||||
day_iterator itr(weekstart);
|
||||
<font class="keywordflow">for</font> (; itr <= weekend; ++itr) {
|
||||
std::cout << to_iso_extended_string(*itr) << std::endl;
|
||||
} </pre></div>
|
||||
|
||||
And some time examples using the posix_time system. See <a href="posix_time.html">Time Programming</a> for more details.
|
||||
|
||||
<div class="fragment"><pre> <font class="keyword">using</font> <font class="keyword">namespace </font>boost::posix_time;
|
||||
date d(2002,Feb,1); <font class="comment">//an arbitrary date</font>
|
||||
ptime t1(d, hours(5)+nanosec(100));<font class="comment">//date + time of day offset</font>
|
||||
ptime t2 = t1 - minutes(4)+seconds(2);
|
||||
ptime now = second_clock::local_time(); <font class="comment">//use the clock</font>
|
||||
<font class="comment">//Get the date part out of the time</font>
|
||||
date today = now.date();
|
||||
date tommorrow = today + date_duration(1);
|
||||
ptime tommorrow_start(tommorrow); <font class="comment">//midnight </font>
|
||||
|
||||
<font class="comment">//starting at current time iterator adds by one hour</font>
|
||||
time_iterator titr(now,hours(1));
|
||||
<font class="keywordflow">for</font> (; titr < tommorrow_start; ++titr) {
|
||||
std::cout << to_simple_string(*titr) << std::endl;
|
||||
}</pre></div>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<h2><a name="domain">Domain Concepts</a></h2>
|
||||
<p>
|
||||
The date time domain is rich in terminology and problems. The following is a brief introduction to the concepts you will find reflected in the library.
|
||||
<p>
|
||||
|
||||
The library supports 3 basic temporal types:
|
||||
<UL>
|
||||
<li> <font class="bold">Time Point</font> -- Specifier for a location in the time continuum.
|
||||
<li> <font class="bold">Time Duration</font> -- A length of time unattached to any point on the time continuum.
|
||||
<li> <font class="bold">Time Interval</font> -- A duration of time attached to a specific point in the time continuum. Also known as a time period.
|
||||
</UL>
|
||||
|
||||
Each of these temporal types has a <font class="bold">Resolution</font> which is defined by the smallest representable duration. A <font class="bold">Time system</font> provides all these categories of temporal types as well as the rules for labeling and calculating with time points. <font class="bold">Calendar Systems</font> are simply time systems with a maximum resolution of one day. The <font class="bold">Gregorian</font> system is the most widely used calendar system today (the ISO system is basically a derivative of this). However, there are many other calendar systems as well. <font class="bold">UTC (Coordinated Universal Time)</font> is a widely used civil time system. UTC is adjusted for earth rotation at longitude 0 by the use of leap seconds (This is not predictable, only as necessary). Most <font class="bold">local time</font> systems are based on UTC but are also adjusted for earth rotation so that daylight hours are similar everywhere. In addition, some local times include <font class="bold">daylight savings time (DST)</font> adjustments to shift the daylight hours during the summer.
|
||||
|
||||
<p>
|
||||
A <font class="bold">Clock Device</font> is software component (tied to some hardware) that provides the current date or time with respect to a time system. A clock can measure the current time to a known resolution which may be higher or lower than a particular time representation.
|
||||
|
||||
<p>
|
||||
The library provides support for calculating with dates and times. However, time calculations are not quite the same as calculating with integers. If you are serious about the accuracy of your time calculations need to read about <a href="Tradeoffs.html">Stability, Predictability, and Approximations</a>.
|
||||
<p>
|
||||
Additional reference materials can be found in the following:
|
||||
|
||||
<ul>
|
||||
<li><a href="BasicTerms.html">Basic Terminology</a>
|
||||
<li><a href="Calculations.html">Calculations</a>
|
||||
<li><a href="Tradeoffs.html">Stability, Predictability, and Approximations</a>
|
||||
<li><a href="References.html">References</a>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<h2><a name="test">Tests</a></h2>
|
||||
|
||||
<p>
|
||||
The library provides a large number of tests in the
|
||||
<pre>
|
||||
libs/date_time/test
|
||||
libs/date_time/test/gregorian
|
||||
libs/date_time/test/posix_time
|
||||
</pre>
|
||||
<p>
|
||||
directories. Building and executing these tests assures that the installation is correct and that the library is functioning correctly. In addition, these tests facilitate the porting to new compilers. Finally, the tests provide examples of many functions not explicitly described in the usage examples.
|
||||
<p>
|
||||
|
||||
<h2><a name="design">Design and Extensions</a></h2>
|
||||
<p>
|
||||
A large part of the genesis of this library has been the observation that
|
||||
few date-time libraries are built in a fashion that allows customization
|
||||
and extension. A typical example, the calendar logic is built directly
|
||||
into the date class. Or the clock retrieval functions are built directly
|
||||
into the time class. These design decisions usually make it impossible to
|
||||
extend or change the library behavior. At a more fundamental level,
|
||||
there are usually assumptions about the resolution of time representation
|
||||
or the gregorian calendar.
|
||||
<p>
|
||||
Often times, the result is that a project must settle for a less
|
||||
than complete library because of a requirement for high resolution
|
||||
time representation or other assumptions that do not match the
|
||||
implementation of the library. This is extremely unfortunate because
|
||||
development of a library of this sort is far from a trivial task.
|
||||
<p>
|
||||
While the design is far from perfect the current design is far
|
||||
more flexible than any date-time library the author is aware of. It
|
||||
is expected that the various aspects of extensibility will be better
|
||||
documented in future versions. Information about the design goals
|
||||
of the library is <a href="DesignGoals.html">summarized here.</a>
|
||||
<p>
|
||||
|
||||
<h2><a name="acknowledge">Acknowledgements</a></h2>
|
||||
|
||||
<p>
|
||||
Many people have contributed to the development of this library.
|
||||
In particular Hugo Duncan and Joel de Guzman for help with porting to
|
||||
various compilers. For initial development of concepts and
|
||||
design Corwin Joy and Michael Kenniston deserve special thanks.
|
||||
Also extra thanks to Michael for writing up the theory and tradeoffs
|
||||
part of the documentation. Dave Zumbro for initial inspiration
|
||||
and sage thoughts. Many thanks
|
||||
to boost reviewers and users including:
|
||||
William Seymour, Kjell Elster, Beman Dawes, Gary Powell,
|
||||
Andrew Maclean, William Kempf, Peter Dimov, Chris Little,
|
||||
David Moore, Darin Adler, Gennadiy Rozental, Joachim Achtzehnter,
|
||||
Paul Bristow, Jan Langer, Mark Rodgers, Glen Knowles, Matthew Denman,
|
||||
and George Heintzelman.
|
||||
|
||||
<p>
|
||||
<h2><a name="more">More Info</a></h2>
|
||||
|
||||
<p>
|
||||
The design of the library is currently being evolved using Wiki and email discussions. You can find more information at:
|
||||
<p>
|
||||
<ul>
|
||||
<li><a href="http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?GDTL">Boost Wiki GDTL Start Page</a>
|
||||
<li><a href="http://www.crystalclearsoftware.com/libraries/gdtl/gdtl_ref_guide/index.html">Full Doxygen Reference Manual</a></ul>
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Sun Jan 19 15:49:46 MST 2003
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="../../../doc/html/date_time.html">../../../doc/html/date_time.html</a>
|
||||
<p>© Copyright CrystalClear Software, Inc 2003-2006</p>
|
||||
<p> Use, modification, and distribution are subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
|
||||
www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Boost Date-Time Library Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>Boost Date-Time Library License</h1>
|
||||
<p>
|
||||
<hr>
|
||||
<p>
|
||||
<p>
|
||||
The following is the overall license for the boost date_time
|
||||
library. This notice is found in all source files related to
|
||||
the library.
|
||||
<p>
|
||||
|
||||
Copyright © 2002 CrystalClear Software, Inc.<br>
|
||||
<br>
|
||||
Permission to use, copy, modify, distribute and sell this software
|
||||
and its documentation for any purpose is hereby granted without fee,
|
||||
provided that the above copyright notice appear in all copies and
|
||||
that both that copyright notice and this permission notice appear
|
||||
in supporting documentation. CrystalClear Software makes no
|
||||
representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without express or implied warranty.
|
||||
|
||||
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Sun Oct 13 10:32:24 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>posix_time::local time adjust Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>Local Time Adjustment</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<p>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">Local Time Adjustment</font>
|
||||
<p>
|
||||
<a href="#header">Header</a> --
|
||||
<a href="#classoverview">Class Overview</a> --
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
<p>
|
||||
A frequent problem in time representation is the conversion between
|
||||
various local time systems. In general this is accomplished by
|
||||
using a reference time system. The reference time system is typically
|
||||
UTC.
|
||||
<p>
|
||||
Since the posix_time system does no internal time adjustment it
|
||||
can be used to represent both local times and UTC times. However,
|
||||
the user is currently left to handle conversions and time zone
|
||||
knowledge explicitly.
|
||||
<p>
|
||||
The library offers two different ways to perform UTC to local conversions.
|
||||
The first is using the time zone settings of the computer. This is
|
||||
a useful solution for converting a UTC time for a user machine. This
|
||||
approach depends on the ctime API and will provide incorrect results
|
||||
if the environment is set incorrectly.
|
||||
The other approach allows conversion from any zone to UTC and back
|
||||
independent of the settings of the time zone settings of the
|
||||
computer. The <a href="exp-local_utc_conversion.html">local utc conversion example</a>
|
||||
demonstrates both of these techniques.
|
||||
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
|
||||
or
|
||||
#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types
|
||||
</pre>
|
||||
<p>
|
||||
|
||||
<h2><a name="classoverview">Class Overview</a></h2>
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Class</b></td>
|
||||
<td><b>Description</b></td>
|
||||
<td><b>Example</b></td></tr>
|
||||
<tr><td>date_time::c_local_adjustor<ptime>::<font class="el">utc_to_local</font>(ptime)</td>
|
||||
<td>Calculate local machine time from a UTC time based on time zone settings and the C API.</td>
|
||||
<td>
|
||||
typedef boost::date_time::c_local_adjustor<ptime> local_adj;<br>
|
||||
ptime t10(date(2002,Jan,1), hours(7)); <br>
|
||||
ptime t11 = local_adj::utc_to_local(t10);<br>
|
||||
</td></tr>
|
||||
<tr><td>date_time::local_adjustor<ptime, utc_offset, dst_rules>::<font class="el">utc_to_local</font>(ptime)</td>
|
||||
<td>Calculate local machine time from a UTC time based daylight savings rules and utc offset</td>
|
||||
<td><a href="exp-local_utc_conversion.html">example</a>
|
||||
</td></tr>
|
||||
<tr><td>date_time::local_adjustor<ptime, utc_offset, dst_rules>::<font class="el">local_to_utc</font>(ptime)</td>
|
||||
<td>Calculate UTC time based on daylight savings rules and utc offset.</td>
|
||||
<td><a href="exp-local_utc_conversion.html">example</a>
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>
|
||||
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Thu Sep 5 07:34:28 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>Posix Time System Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>Posix Time System Documentation</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<p>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a>
|
||||
<p>
|
||||
<font class="bold">Temporal Types</font>
|
||||
<p>
|
||||
<a href="class_ptime.html">Class ptime</a> --
|
||||
<a href="class_time_duration.html">Class time_duration</a> --
|
||||
<a href="class_time_period.html">Class time_period</a>
|
||||
<p>
|
||||
<font class="bold">Other Topics</font>
|
||||
<p>
|
||||
<a href="time_iterators.html">Time Iterators</a> --
|
||||
<a href="local_time_adjust.html">UTC / Local Time Adjustments</a>
|
||||
|
||||
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
<p>
|
||||
Defines a non-adjusted time system with nano-second resolution and
|
||||
stable calculation properties. This time system uses the Gregorian
|
||||
calendar to implement the date portion of the time representation.
|
||||
|
||||
<p>
|
||||
<h2><a name="usage">Usage Examples</a></h2>
|
||||
|
||||
<table border=1 cellspacing=3 cellpadding=3><tr><td><b>Example</b></td><td><b>Description</b> </td></tr>
|
||||
<tr><td><a href="exp-time_math.html">Time Math</a></td><td>A few simple calculations using ptime and time_durations. </td></tr>
|
||||
<tr><td><a href="exp-print_hours.html">Print Hours</a></td><td>Retrieve time from clock, use a time_iterator. </td></tr>
|
||||
<tr><td><a href="exp-local_utc_conversion.html">Local to UTC Conversion</a></td><td>Demonstrates a couple different ways to convert a local to UTC time including daylight savings rules. </td></tr>
|
||||
<tr><td><a href="exp-time_periods.html">Time periods</a></td><td>Some simple examples of intersection and display of time periods. </td></table>
|
||||
|
||||
|
||||
<hr>
|
||||
<address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Thu Sep 5 06:19:36 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by Jeff Garland © 2000-2002
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 5.1 KiB |
@@ -1,78 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>posix_time::time iterators Documentation</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="../../../index.htm">
|
||||
<img align="left" src="../../../c++boost.gif" alt="C++ Boost">
|
||||
</a>
|
||||
|
||||
<h1>posix_time::time iterators</h1>
|
||||
<p> <p>
|
||||
<hr>
|
||||
<a href="index.html">Overall Index</a> --
|
||||
<a href="gregorian.html">Gregorian Index</a> --
|
||||
<a href="posix_time.html">Posix Time Index</a>
|
||||
<p>
|
||||
<font class="bold">Time Iterators</font>
|
||||
<p>
|
||||
<a href="#intro">Introduction</a> --
|
||||
<a href="#header">Header</a> --
|
||||
<a href="#classoverview">Class Overview</a>
|
||||
|
||||
<p>
|
||||
<h2><a name="intro">Introduction</a></h2>
|
||||
|
||||
<p>
|
||||
Time iterators provide a standard mechanism for iteration through times. Time iterators are a model of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> and can be used to populate collections with times. The following example
|
||||
iterates using a 15 minute interation interval.
|
||||
<p>
|
||||
<div class="fragment"><pre>
|
||||
|
||||
<font class="keyword">using namespace</font> boost::gregorian;
|
||||
<font class="keyword">using namespace</font> boost::posix_time;
|
||||
date d(2000,Jan,20);
|
||||
ptime start(d);<font class="comment">//2000-Jan-20 00:00:00</font>
|
||||
time_iterator titr(start,minutes(15)); <font class="comment">//iterate on 15 minute intervals</font>
|
||||
<font class="comment">//produces 00:00:00, 00:15:00, 00:30:00, 00:45:00</font>
|
||||
<font class="keyword">for</font> (; titr < ptime(d,hour(1)); ++titr) {
|
||||
std::cout << to_simple_string(*titr) << std::endl;
|
||||
}
|
||||
</pre></div>
|
||||
<p>
|
||||
The <a href="exp-print_hours.html">print hours</a>
|
||||
example iterates through the remainder of the day incrementing by an hour.
|
||||
|
||||
<p>
|
||||
<h2><a name="header">Header</a></h2>
|
||||
<pre>
|
||||
#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
|
||||
or
|
||||
#include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types
|
||||
</pre>
|
||||
<p>
|
||||
<h2><a name="classoverview">Class Overview</a></h2>
|
||||
<p>
|
||||
<table border=1 cellspacing=3 cellpadding=3>
|
||||
<tr><td><b>Class</b></td>
|
||||
<td><b>Construction Parameters</b></td>
|
||||
<td><b>Description</b></td></tr>
|
||||
<tr><td>time_iterator</td>
|
||||
<td>ptime start_time, time_duration increment</td>
|
||||
<td>Iterate incrementing by the specified duration.</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<hr><address><small>
|
||||
<!-- hhmts start -->
|
||||
Last modified: Thu Sep 5 07:23:04 MST 2002
|
||||
<!-- hhmts end -->
|
||||
by <a href="mailto:jeff@crystalclearsoftware.com">Jeff Garland</a> © 2000-2002
|
||||
</small></address>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+35
-71
@@ -1,83 +1,47 @@
|
||||
subproject libs/date_time/example ;
|
||||
project : requirements <library>/boost/date_time//boost_date_time ;
|
||||
|
||||
exe dates_as_strings : <lib>../build/boost_date_time
|
||||
gregorian/dates_as_strings.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
exe dates_as_strings : gregorian/dates_as_strings.cpp ;
|
||||
exe days_alive : gregorian/days_alive.cpp ;
|
||||
exe days_till_new_year : gregorian/days_till_new_year.cpp ;
|
||||
|
||||
exe days_alive : <lib>../build/boost_date_time
|
||||
gregorian/days_alive.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
exe days_between_new_years : gregorian/days_between_new_years.cpp ;
|
||||
exe find_last_day_of_months : gregorian/find_last_day_of_months.cpp ;
|
||||
|
||||
exe month_add : gregorian/month_add.cpp ;
|
||||
|
||||
exe localization : gregorian/localization.cpp ;
|
||||
exe print_holidays : gregorian/print_holidays.cpp ;
|
||||
exe print_month : gregorian/print_month.cpp ;
|
||||
exe period_calc : gregorian/period_calc.cpp ;
|
||||
|
||||
exe days_since_year_start : gregorian/days_since_year_start.cpp ;
|
||||
|
||||
|
||||
exe local_utc_conversion : posix_time/local_utc_conversion.cpp
|
||||
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
|
||||
;
|
||||
|
||||
exe days_till_new_year : <lib>../build/boost_date_time
|
||||
gregorian/days_till_new_year.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
exe print_hours : posix_time/print_hours.cpp
|
||||
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
|
||||
;
|
||||
|
||||
exe end_of_month_day : <lib>../build/boost_date_time
|
||||
gregorian/end_of_month_day.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
exe time_math : posix_time/time_math.cpp
|
||||
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
|
||||
;
|
||||
|
||||
exe month_add : <lib>../build/boost_date_time
|
||||
gregorian/month_add.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
exe time_periods : posix_time/time_periods.cpp
|
||||
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
|
||||
;
|
||||
|
||||
exe localization : <lib>../build/boost_date_time
|
||||
gregorian/localization.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
exe simple_time_zone : local_time/simple_time_zone.cpp ;
|
||||
exe calc_rules : local_time/calc_rules.cpp ;
|
||||
exe seconds_since_epoch : local_time/seconds_since_epoch.cpp ;
|
||||
exe flight : local_time/flight.cpp ;
|
||||
exe io_tutorial : tutorial/io_tutorial.cpp ;
|
||||
|
||||
exe print_holidays : <lib>../build/boost_date_time
|
||||
gregorian/print_holidays.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
exe print_month : <lib>../build/boost_date_time
|
||||
gregorian/print_month.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
exe period_calc : <lib>../build/boost_date_time
|
||||
gregorian/period_calc.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
exe days_since_year_start : <lib>../build/boost_date_time
|
||||
gregorian/days_since_year_start.cpp
|
||||
: <include>$(BOOST_ROOT)
|
||||
;
|
||||
|
||||
exe local_utc_conversion : <lib>../build/boost_date_time
|
||||
posix_time/local_utc_conversion.cpp
|
||||
: <include>$(BOOST_ROOT) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
|
||||
;
|
||||
|
||||
exe print_hours : <lib>../build/boost_date_time
|
||||
posix_time/print_hours.cpp
|
||||
: <include>$(BOOST_ROOT) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
|
||||
;
|
||||
|
||||
exe time_math : <lib>../build/boost_date_time
|
||||
posix_time/time_math.cpp
|
||||
: <include>$(BOOST_ROOT) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
|
||||
;
|
||||
|
||||
exe time_periods : <lib>../build/boost_date_time
|
||||
posix_time/time_periods.cpp
|
||||
: <include>$(BOOST_ROOT) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
|
||||
;
|
||||
|
||||
# Copyright (c) 2002
|
||||
# Copyright (c) 2002-2005
|
||||
# CrystalClear Software, Inc.
|
||||
#
|
||||
# Permission to use, copy, modify, distribute and sell this software
|
||||
# and its documentation for any purpose is hereby granted without fee,
|
||||
# provided that the above copyright notice appear in all copies and
|
||||
# that both that copyright notice and this permission notice appear
|
||||
# in supporting documentation. CrystalClear Software makes no
|
||||
# representations about the suitability of this software for any
|
||||
# purpose. It is provided "as is" without express or implied warranty.
|
||||
# Subject to the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
# Copyright (c) 2002-2006 CrystalClear Software, Inc.
|
||||
# Use, modification and distribution is subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
|
||||
project
|
||||
: requirements <library>../../build/boost_date_time
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include "boost/date_time/gregorian/greg_serialize.hpp"
|
||||
#include "boost/serialization/set.hpp"
|
||||
#include "boost/serialization/list.hpp"
|
||||
#include "boost/archive/text_oarchive.hpp"
|
||||
#include "boost/archive/text_iarchive.hpp"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
using namespace boost::gregorian;
|
||||
typedef std::set<date> date_set;
|
||||
typedef std::list<date> date_list;
|
||||
|
||||
void print(std::ostream& os, const date_set& ds)
|
||||
{
|
||||
os << "******** Date Set *********" << std::endl;
|
||||
date_set::const_iterator itr = ds.begin();
|
||||
while (itr != ds.end())
|
||||
{
|
||||
os << (*itr) << " ";
|
||||
itr++;
|
||||
}
|
||||
os << "\n***************************" << std::endl;
|
||||
}
|
||||
|
||||
class foo {
|
||||
public:
|
||||
foo(date d = date(not_a_date_time),
|
||||
int i = 0) :
|
||||
my_date(d),
|
||||
my_int(i)
|
||||
{}
|
||||
void insert_date(date d)
|
||||
{
|
||||
my_dates.push_back(d);
|
||||
}
|
||||
void print(std::ostream& os) const
|
||||
{
|
||||
os << "foo= my_date is: " << my_date
|
||||
<< " my_int is: " << my_int;
|
||||
date_list::const_iterator i = my_dates.begin();
|
||||
os << " Important dates: ";
|
||||
while (i != my_dates.end()) {
|
||||
os << (*i) << " ";
|
||||
i++;
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
|
||||
// is a type of input archive the & operator is defined similar to >>.
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int version)
|
||||
{
|
||||
ar & my_date;
|
||||
ar & my_int;
|
||||
ar & my_dates;
|
||||
}
|
||||
|
||||
date my_date;
|
||||
int my_int;
|
||||
date_list my_dates;
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
try {
|
||||
date d(2004, Apr, 5);
|
||||
std::cout << "Date: " << to_iso_string(d) << std::endl;
|
||||
std::cout << "Date: " << d << std::endl;
|
||||
std::ofstream ofs("date_demo.txt");
|
||||
boost::archive::text_oarchive oa(ofs);
|
||||
oa << d;
|
||||
|
||||
std::cout << "Construct a foo" << std::endl;
|
||||
foo f(d, 1);
|
||||
f.insert_date(d+days(1));
|
||||
f.insert_date(d+days(2));
|
||||
f.insert_date(d+days(3));
|
||||
f.print(std::cout);
|
||||
oa << f;
|
||||
|
||||
date_set dates;
|
||||
dates.insert(date(2004, Apr,1));
|
||||
dates.insert(date(2004, Apr,10));
|
||||
dates.insert(date(2004, Apr,15));
|
||||
print(std::cout, dates);
|
||||
|
||||
oa << dates;
|
||||
ofs.close();
|
||||
|
||||
std::cout << "Now do the input streaming" << std::endl;
|
||||
date d2(not_a_date_time);
|
||||
std::ifstream ifs("date_demo.txt");
|
||||
boost::archive::text_iarchive ia(ifs);
|
||||
ia >> d2;
|
||||
|
||||
std::cout << "New date is: " << d2 << std::endl;
|
||||
|
||||
foo f2;
|
||||
ia >> f2;
|
||||
f2.print(std::cout);
|
||||
|
||||
date_set dates2;
|
||||
ia >> dates2; //exception here
|
||||
print(std::cout, dates2);
|
||||
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
std::cout << "Caught Exception: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
/*
|
||||
The following is a simple example that shows conversion of dates to and
|
||||
from a std::string.
|
||||
|
||||
Expected output:
|
||||
2001-Oct-09
|
||||
2001-10-09
|
||||
Tuesday October 9, 2001
|
||||
An expected exception is next:
|
||||
Exception: Month number is out of range 1..12
|
||||
|
||||
*/
|
||||
/* The following is a simple example that shows conversion of dates
|
||||
* to and from a std::string.
|
||||
*
|
||||
* Expected output:
|
||||
* 2001-Oct-09
|
||||
* 2001-10-09
|
||||
* Tuesday October 9, 2001
|
||||
* An expected exception is next:
|
||||
* Exception: Month number is out of range 1..12
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include "boost/date_time/date_parsing.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
@@ -26,11 +21,11 @@ main()
|
||||
|
||||
try {
|
||||
// The following date is in ISO 8601 extended format (CCYY-MM-DD)
|
||||
std::string s("2001-10-9"); //2001-October-05
|
||||
date d(from_string(s));
|
||||
std::string s("2001-10-9"); //2001-October-09
|
||||
date d(from_simple_string(s));
|
||||
std::cout << to_simple_string(d) << std::endl;
|
||||
|
||||
//Read ISO Standard(CCYYMMDD) and output ISO Extended
|
||||
//Read ISO 8601 Standard(CCYYMMDD) and output ISO 8601 Extended
|
||||
std::string ud("20011009"); //2001-Oct-09
|
||||
date d1(from_undelimited_string(ud));
|
||||
std::cout << to_iso_extended_string(d1) << std::endl;
|
||||
@@ -43,13 +38,12 @@ main()
|
||||
<< ymd.day << ", " << ymd.year
|
||||
<< std::endl;
|
||||
|
||||
|
||||
//Let's send in month 25 by accident and create an exception
|
||||
std::string bad_date("20012509"); //2001-??-09
|
||||
std::cout << "An expected exception is next: " << std::endl;
|
||||
date wont_construct(from_undelimited_string(bad_date));
|
||||
//use wont_construct so compiler doesn't complain, but you wont get here!
|
||||
std::cout << "oh oh, you should reach this line: "
|
||||
std::cout << "oh oh, you shouldn't reach this line: "
|
||||
<< to_iso_string(wont_construct) << std::endl;
|
||||
}
|
||||
catch(std::exception& e) {
|
||||
@@ -59,3 +53,11 @@ main()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
/* Short example that calculates the number of days since user was born.
|
||||
* Demonstrates comparisons of durations, use of the day_clock,
|
||||
* and parsing a date from a string.
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include "boost/date_time/date_parsing.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
@@ -12,15 +15,14 @@ main()
|
||||
std::cout << "Enter birth day YYYY-MM-DD (eg: 2002-02-01): ";
|
||||
std::cin >> s;
|
||||
try {
|
||||
date birthday(boost::date_time::parse_date<date>(s));
|
||||
//date birthday(2002,Jan,1);
|
||||
date birthday(from_simple_string(s));
|
||||
date today = day_clock::local_day();
|
||||
date_duration days_alive = today - birthday;
|
||||
date_duration one_day(1);
|
||||
days days_alive = today - birthday;
|
||||
days one_day(1);
|
||||
if (days_alive == one_day) {
|
||||
std::cout << "Born yesterday, very funny" << std::endl;
|
||||
}
|
||||
else if (days_alive < date_duration(0)) {
|
||||
else if (days_alive < days(0)) {
|
||||
std::cout << "Not born yet, hmm: " << days_alive.days()
|
||||
<< " days" <<std::endl;
|
||||
}
|
||||
@@ -33,4 +35,13 @@ main()
|
||||
std::cout << "Bad date entered: " << s << std::endl;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/* Provides a simple example of using a date_generator, and simple
|
||||
* mathematical operatorations, to calculate the days since
|
||||
* New Years day of this year, and days until next New Years day.
|
||||
*
|
||||
* Expected results:
|
||||
* Adding together both durations will produce 365 (366 in a leap year).
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
|
||||
using namespace boost::gregorian;
|
||||
|
||||
date today = day_clock::local_day();
|
||||
partial_date new_years_day(1,Jan);
|
||||
//Subtract two dates to get a duration
|
||||
days days_since_year_start = today - new_years_day.get_date(today.year());
|
||||
std::cout << "Days since Jan 1: " << days_since_year_start.days()
|
||||
<< std::endl;
|
||||
|
||||
days days_until_year_start = new_years_day.get_date(today.year()+1) - today;
|
||||
std::cout << "Days until next Jan 1: " << days_until_year_start.days()
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include <iostream>
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main()
|
||||
@@ -14,4 +14,12 @@ main()
|
||||
std::cout << "Days since Jan 1: " << days_since_year_start.days()
|
||||
<< std::endl;
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// This example displays the amount of time until new year's in days
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
|
||||
using namespace boost::gregorian;
|
||||
|
||||
date::ymd_type today = day_clock::local_day_ymd();
|
||||
date new_years_day(today.year + 1,1,1);
|
||||
date_duration dd = new_years_day - date(today);
|
||||
|
||||
std::cout << "Days till new year: " << dd.days() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/* Simple program that uses the gregorian calendar to find the last
|
||||
* day of the month and then display the last day of every month left
|
||||
* in the year.
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::gregorian;
|
||||
|
||||
std::cout << " Enter Year(ex: 2002): ";
|
||||
int year, month;
|
||||
std::cin >> year;
|
||||
std::cout << " Enter Month(1..12): ";
|
||||
std::cin >> month;
|
||||
try {
|
||||
int day = gregorian_calendar::end_of_month_day(year,month);
|
||||
date end_of_month(year,month,day);
|
||||
|
||||
//Iterate thru by months --
|
||||
month_iterator mitr(end_of_month,1);
|
||||
date start_of_next_year(year+1, Jan, 1);
|
||||
//loop thru the days and print each one
|
||||
while (mitr < start_of_next_year){
|
||||
std::cout << to_simple_string(*mitr) << std::endl;
|
||||
++mitr;
|
||||
}
|
||||
|
||||
}
|
||||
catch(...) {
|
||||
std::cout << "Invalid Date Entered" << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/* Simple program that finds the last day of the given month,
|
||||
* then displays the last day of every month left in the given year.
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::gregorian;
|
||||
|
||||
greg_year year(1400);
|
||||
greg_month month(1);
|
||||
|
||||
// get a month and a year from the user
|
||||
try {
|
||||
greg_year::value_type y;
|
||||
greg_month::value_type m;
|
||||
std::cout << " Enter Year(ex: 2002): ";
|
||||
std::cin >> y;
|
||||
year = greg_year(y);
|
||||
std::cout << " Enter Month(1..12): ";
|
||||
std::cin >> m;
|
||||
month = greg_month(m);
|
||||
}
|
||||
catch(const bad_year& by) {
|
||||
std::cout << "Invalid Year Entered: " << by.what() << '\n'
|
||||
<< "Using minimum values for month and year." << std::endl;
|
||||
}
|
||||
catch(const bad_month& bm) {
|
||||
std::cout << "Invalid Month Entered" << bm.what() << '\n'
|
||||
<< "Using minimum value for month. " << std::endl;
|
||||
}
|
||||
|
||||
date start_of_next_year(year+1, Jan, 1);
|
||||
date d(year, month, 1);
|
||||
|
||||
// add another month to d until we enter the next year.
|
||||
while (d < start_of_next_year){
|
||||
std::cout << to_simple_string(d.end_of_month()) << std::endl;
|
||||
d += months(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copyright 2001-2005: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
@@ -1,112 +1,100 @@
|
||||
/*
|
||||
The following shows the creation of a facet for the output of
|
||||
dates in German (please forgive me for any errors in my German --
|
||||
I'm not a native speaker).
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/* The following shows the creation of a facet for the output of
|
||||
* dates in German (please forgive me for any errors in my German --
|
||||
* I'm not a native speaker).
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
//Define a series of char arrays for short and long name strings to be
|
||||
//associated with date output.
|
||||
const char* const de_short_month_names[]={"Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez", "NAM"};
|
||||
|
||||
const char* const de_long_month_names[]={"Januar","Februar","Marz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember","NichtDerMonat"};
|
||||
const char* const de_special_value_names[]={"NichtDatumzeit","-unbegrenztheit", "+unbegrenztheit"};
|
||||
|
||||
const char* const de_long_weekday_names[]={"Sonntag", "Montag", "Dienstag","Mittwoch", "Donnerstag", "Freitag", "Samstag"};
|
||||
|
||||
const char* const de_short_weekday_names[]={"Son", "Mon", "Die","Mit", "Don", "Fre", "Sam"};
|
||||
|
||||
const char* const us_short_month_names[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec", "NAD"};
|
||||
|
||||
const char* const us_long_month_names[]={"January","February","March","April","May","June","July","August","September","October","November","December","Not-A-Date"};
|
||||
const char* const us_special_value_names[]={"Not-A-Date","-infinity", "+infinity"};
|
||||
|
||||
const char* const us_long_weekday_names[]={"Sunday", "Monday", "Tuesday","Wenesday", "Thursday", "Friday", "Saturday"};
|
||||
|
||||
const char* const us_short_weekday_names[]={"Sun", "Mon", "Tue","Wed", "Thu", "Fri", "Sat"};
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
/* Define a series of char arrays for short and long name strings
|
||||
* to be associated with German date output (US names will be
|
||||
* retrieved from the locale). */
|
||||
const char* const de_short_month_names[] =
|
||||
{
|
||||
"Jan", "Feb", "Mar", "Apr", "Mai", "Jun",
|
||||
"Jul", "Aug", "Sep", "Okt", "Nov", "Dez", "NAM"
|
||||
};
|
||||
const char* const de_long_month_names[] =
|
||||
{
|
||||
"Januar", "Februar", "Marz", "April", "Mai",
|
||||
"Juni", "Juli", "August", "September", "Oktober",
|
||||
"November", "Dezember", "NichtDerMonat"
|
||||
};
|
||||
const char* const de_long_weekday_names[] =
|
||||
{
|
||||
"Sonntag", "Montag", "Dienstag", "Mittwoch",
|
||||
"Donnerstag", "Freitag", "Samstag"
|
||||
};
|
||||
const char* const de_short_weekday_names[] =
|
||||
{
|
||||
"Son", "Mon", "Die","Mit", "Don", "Fre", "Sam"
|
||||
};
|
||||
|
||||
#ifndef BOOST_DATE_TIME_NO_LOCALE
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::gregorian;
|
||||
typedef boost::date_time::all_date_names_put<greg_facet_config> date_facet;
|
||||
|
||||
//create a new local
|
||||
std::locale default_locale;
|
||||
std::locale german_dates1(default_locale,
|
||||
new date_facet(de_short_month_names,
|
||||
de_long_month_names,
|
||||
de_special_value_names,
|
||||
de_short_weekday_names,
|
||||
de_long_weekday_names,
|
||||
'.',
|
||||
boost::date_time::ymd_order_dmy,
|
||||
boost::date_time::month_as_integer));
|
||||
|
||||
|
||||
// create some gregorian objects to output
|
||||
date d1(2002, Oct, 1);
|
||||
std::cout.imbue(german_dates1);
|
||||
greg_month m = d1.month();
|
||||
greg_weekday wd = d1.day_of_week();
|
||||
|
||||
// create a facet and a locale for German dates
|
||||
date_facet* german_facet = new date_facet();
|
||||
std::cout.imbue(std::locale(std::locale::classic(), german_facet));
|
||||
|
||||
// create the German name collections
|
||||
date_facet::input_collection_type short_months, long_months,
|
||||
short_weekdays, long_weekdays;
|
||||
std::copy(&de_short_month_names[0], &de_short_month_names[11],
|
||||
std::back_inserter(short_months));
|
||||
std::copy(&de_long_month_names[0], &de_long_month_names[11],
|
||||
std::back_inserter(long_months));
|
||||
std::copy(&de_short_weekday_names[0], &de_short_weekday_names[6],
|
||||
std::back_inserter(short_weekdays));
|
||||
std::copy(&de_long_weekday_names[0], &de_long_weekday_names[6],
|
||||
std::back_inserter(long_weekdays));
|
||||
|
||||
// replace the default names with ours
|
||||
// NOTE: date_generators and special_values were not replaced as
|
||||
// they are not used in this example
|
||||
german_facet->short_month_names(short_months);
|
||||
german_facet->long_month_names(long_months);
|
||||
german_facet->short_weekday_names(short_weekdays);
|
||||
german_facet->long_weekday_names(long_weekdays);
|
||||
|
||||
// output the date in German using short month names
|
||||
german_facet->format("%d.%m.%Y");
|
||||
std::cout << d1 << std::endl; //01.10.2002
|
||||
|
||||
std::locale german_dates2(default_locale,
|
||||
new date_facet(de_short_month_names,
|
||||
de_long_month_names,
|
||||
de_special_value_names,
|
||||
de_short_weekday_names,
|
||||
de_long_weekday_names,
|
||||
'.',
|
||||
boost::date_time::ymd_order_dmy,
|
||||
boost::date_time::month_as_long_string));
|
||||
|
||||
std::cout.imbue(german_dates2);
|
||||
greg_month m = d1.month();
|
||||
german_facet->month_format("%B");
|
||||
std::cout << m << std::endl; //Oktober
|
||||
|
||||
greg_weekday wd = d1.day_of_week();
|
||||
german_facet->weekday_format("%A");
|
||||
std::cout << wd << std::endl; //Dienstag
|
||||
|
||||
|
||||
//Numeric date format with US month/day/year ordering
|
||||
std::locale usa_dates1(default_locale,
|
||||
new date_facet(us_short_month_names,
|
||||
us_long_month_names,
|
||||
us_special_value_names,
|
||||
us_short_weekday_names,
|
||||
us_long_weekday_names,
|
||||
'/',
|
||||
boost::date_time::ymd_order_us,
|
||||
boost::date_time::month_as_integer));
|
||||
|
||||
std::cout.imbue(usa_dates1);
|
||||
std::cout << d1 << std::endl; // 10/01/2002
|
||||
//English names, iso order (year-month-day), '-' separator
|
||||
std::locale usa_dates2(default_locale,
|
||||
new date_facet(us_short_month_names,
|
||||
us_long_month_names,
|
||||
us_special_value_names,
|
||||
us_short_weekday_names,
|
||||
us_long_weekday_names,
|
||||
'-',
|
||||
boost::date_time::ymd_order_iso,
|
||||
boost::date_time::month_as_short_string));
|
||||
// Output the same gregorian objects using US names
|
||||
date_facet* us_facet = new date_facet();
|
||||
std::cout.imbue(std::locale(std::locale::classic(), us_facet));
|
||||
|
||||
std::cout.imbue(usa_dates2);
|
||||
us_facet->format("%m/%d/%Y");
|
||||
std::cout << d1 << std::endl; // 10/01/2002
|
||||
|
||||
// English names, ISO 8601 order (year-month-day), '-' separator
|
||||
us_facet->format("%Y-%b-%d");
|
||||
std::cout << d1 << std::endl; // 2002-Oct-01
|
||||
|
||||
|
||||
#else
|
||||
std::cout << "Sorry, localization is not supported by this compiler/library"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* Copyright 2001-2005: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/* Simple program that uses the gregorian calendar to progress by exactly
|
||||
* one month, regardless of how many days are in that month.
|
||||
*
|
||||
* This method can be used as an alternative to iterators
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
|
||||
using namespace boost::gregorian;
|
||||
|
||||
date d = day_clock::local_day();
|
||||
date d2 = d + months(1);
|
||||
date d3 = d - months(1);
|
||||
std::cout << "Today is: " << to_simple_string(d) << ".\n"
|
||||
<< "One month from today will be: " << to_simple_string(d2) << ".\n"
|
||||
<< "One month ago was: " << to_simple_string(d3)
|
||||
<< std::endl;
|
||||
std::cout << "******** Warning read this ***********************\n";
|
||||
std::cout << "Be aware that adding a month is not exactly like regular numeric math.\n"
|
||||
<< "Addition/Subtraction of months will 'snap to the end' of a month that\n"
|
||||
<< "is shorter than the current month. For example consider "
|
||||
<< "Jan 31, 2004 + (1 month)\n";
|
||||
date d4(2004, Jan, 31);
|
||||
date d5 = d4 + months(1);
|
||||
std::cout << "Result is: " << to_simple_string(d5)
|
||||
<< std::endl;
|
||||
|
||||
std::cout << "\nSo what does this mean? It means the result of adding months is order\n"
|
||||
<< "dependent, non-commutative, and may create problems for applications.\n"
|
||||
<< "Consider: \n"
|
||||
<< "Jan 30, 2004 + (1 month) + (1 month) != Jan 30, 2004 + (2 months)\n"
|
||||
<< "Why not? Because Jan 30, 2004 + 1 month is Feb 29 + 1 month is Mar 31st.\n"
|
||||
<< "while Jan 30, 2004 + 2 months is Mar 30th.\n"
|
||||
<< "All of this clears up as long as all the starting dates before the 28th of\n"
|
||||
<< "the month -- then all the behavior follows classical mathematical rules.\n";
|
||||
|
||||
date d6(2004, Jan, 30);
|
||||
date d7 = d6 + months(1) + months(1);
|
||||
date d8 = d6 + months(2);
|
||||
std::cout << "2004-01-30 + (1 month) + (1 month) is: " << to_simple_string(d7) << ".\n"
|
||||
<< "2004-01-30 + (2 months) is: " << to_simple_string(d8)
|
||||
<< std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copyright 2001-2005: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
@@ -76,3 +76,11 @@ int main()
|
||||
|
||||
|
||||
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
/*generate a set of dates using a collections of date generators
|
||||
Output looks like:
|
||||
Enter Year: 2002
|
||||
2002-Jan-01 [Tue]
|
||||
2002-Jan-21 [Mon]
|
||||
2002-Feb-12 [Tue]
|
||||
2002-Jul-04 [Thu]
|
||||
2002-Sep-02 [Mon]
|
||||
2002-Nov-28 [Thu]
|
||||
2002-Dec-25 [Wed]
|
||||
Number Holidays: 7
|
||||
*/
|
||||
|
||||
/* Generate a set of dates using a collection of date generators
|
||||
* Output looks like:
|
||||
* Enter Year: 2002
|
||||
* 2002-Jan-01 [Tue]
|
||||
* 2002-Jan-21 [Mon]
|
||||
* 2002-Feb-12 [Tue]
|
||||
* 2002-Jul-04 [Thu]
|
||||
* 2002-Sep-02 [Mon]
|
||||
* 2002-Nov-28 [Thu]
|
||||
* 2002-Dec-25 [Wed]
|
||||
* Number Holidays: 7
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include <algorithm>
|
||||
@@ -19,73 +18,66 @@ Number Holidays: 7
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
|
||||
|
||||
void
|
||||
print_date(boost::gregorian::date d)
|
||||
{
|
||||
using namespace boost::gregorian;
|
||||
#if defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
std::cout << to_simple_string(d) << " [" << d.day_of_week() << "]\n";
|
||||
#else
|
||||
std::cout << d << " [" << d.day_of_week() << "]\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main() {
|
||||
|
||||
std::cout << "Enter Year: ";
|
||||
int year;
|
||||
std::cin >> year;
|
||||
|
||||
|
||||
using namespace boost::gregorian;
|
||||
|
||||
std::cout << "Enter Year: ";
|
||||
greg_year::value_type year;
|
||||
std::cin >> year;
|
||||
|
||||
//define a collection of holidays fixed by month and day
|
||||
std::vector<partial_date> holidays;
|
||||
holidays.push_back(partial_date(1,Jan)); //Western New Year
|
||||
holidays.push_back(partial_date(4,Jul)); //US Independence Day
|
||||
holidays.push_back(partial_date(25, Dec));//Christmas day
|
||||
std::vector<year_based_generator*> holidays;
|
||||
holidays.push_back(new partial_date(1,Jan)); //Western New Year
|
||||
holidays.push_back(new partial_date(4,Jul)); //US Independence Day
|
||||
holidays.push_back(new partial_date(25, Dec));//Christmas day
|
||||
|
||||
|
||||
//define a shorthand for the nkday function object
|
||||
typedef boost::date_time::nth_kday_of_month<date> nkday;
|
||||
//define a collection of nth kday holidays
|
||||
std::vector<nkday> more_holidays;
|
||||
more_holidays.push_back(nkday(nkday::first, Monday, Sep)); //US labor day
|
||||
more_holidays.push_back(nkday(nkday::third, Monday, Jan)); //MLK Day
|
||||
more_holidays.push_back(nkday(nkday::second, Tuesday, Feb)); //Pres day
|
||||
more_holidays.push_back(nkday(nkday::fourth, Thursday, Nov)); //Thanksgiving
|
||||
//define a shorthand for the nth_day_of_the_week_in_month function object
|
||||
typedef nth_day_of_the_week_in_month nth_dow;
|
||||
|
||||
//US labor day
|
||||
holidays.push_back(new nth_dow(nth_dow::first, Monday, Sep));
|
||||
//MLK Day
|
||||
holidays.push_back(new nth_dow(nth_dow::third, Monday, Jan));
|
||||
//Pres day
|
||||
holidays.push_back(new nth_dow(nth_dow::second, Tuesday, Feb));
|
||||
//Thanksgiving
|
||||
holidays.push_back(new nth_dow(nth_dow::fourth, Thursday, Nov));
|
||||
|
||||
typedef std::set<date> date_set;
|
||||
date_set all_holidays;
|
||||
|
||||
#if (defined(BOOST_MSVC) && (_MSC_VER <= 1200)) // 1200 == VC++ 6.0
|
||||
std::cout << "Sorry, this example temporarily disabled on VC 6.\n"
|
||||
<< "The std::transform isn't accepted by the compiler\n"
|
||||
<< "So if you hack up the example without std::transform\n"
|
||||
<< "it should work\n"
|
||||
<< std::endl;
|
||||
|
||||
#else
|
||||
|
||||
//generate a set of concrete dates from the 'partial_date' holidays
|
||||
//by calling the get_date functions
|
||||
std::transform(holidays.begin(), holidays.end(),
|
||||
std::insert_iterator<date_set>(all_holidays, all_holidays.begin()),
|
||||
std::bind2nd(std::mem_fun_ref(&partial_date::get_date),
|
||||
year));
|
||||
|
||||
//Now add in the 'floating' holidays
|
||||
std::transform(more_holidays.begin(), more_holidays.end(),
|
||||
std::insert_iterator<date_set>(all_holidays, all_holidays.begin()),
|
||||
std::bind2nd(std::mem_fun_ref(&nkday::get_date),
|
||||
year));
|
||||
|
||||
|
||||
for(std::vector<year_based_generator*>::iterator it = holidays.begin();
|
||||
it != holidays.end(); ++it)
|
||||
{
|
||||
all_holidays.insert((*it)->get_date(year));
|
||||
}
|
||||
|
||||
//print the holidays to the screen
|
||||
std::for_each(all_holidays.begin(), all_holidays.end(), print_date);
|
||||
std::cout << "Number Holidays: " << all_holidays.size() << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
/*
|
||||
This example prints all the dates in a month. It demonstrates
|
||||
the use of iterators as well as functions of the gregorian_calendar
|
||||
|
||||
Output:
|
||||
Enter Year: 2002
|
||||
Enter Month(1..12): 2
|
||||
2002-Feb-01 [Fri]
|
||||
2002-Feb-02 [Sat]
|
||||
2002-Feb-03 [Sun]
|
||||
2002-Feb-04 [Mon]
|
||||
2002-Feb-05 [Tue]
|
||||
2002-Feb-06 [Wed]
|
||||
2002-Feb-07 [Thu]
|
||||
*/
|
||||
/* This example prints all the dates in a month. It demonstrates
|
||||
* the use of iterators as well as functions of the gregorian_calendar
|
||||
*
|
||||
* Output:
|
||||
* Enter Year: 2002
|
||||
* Enter Month(1..12): 2
|
||||
* 2002-Feb-01 [Fri]
|
||||
* 2002-Feb-02 [Sat]
|
||||
* 2002-Feb-03 [Sun]
|
||||
* 2002-Feb-04 [Mon]
|
||||
* 2002-Feb-05 [Tue]
|
||||
* 2002-Feb-06 [Wed]
|
||||
* 2002-Feb-07 [Thu]
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include <iostream>
|
||||
@@ -20,24 +19,31 @@ Enter Month(1..12): 2
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost::gregorian;
|
||||
|
||||
std::cout << "Enter Year: ";
|
||||
int year, month;
|
||||
greg_year::value_type year;
|
||||
greg_month::value_type month;
|
||||
std::cin >> year;
|
||||
std::cout << "Enter Month(1..12): ";
|
||||
std::cin >> month;
|
||||
|
||||
using namespace boost::gregorian;
|
||||
try {
|
||||
//Use the calendar to get the last day of the month
|
||||
int eom_day = gregorian_calendar::end_of_month_day(year,month);
|
||||
greg_day::value_type eom_day = gregorian_calendar::end_of_month_day(year,month);
|
||||
date endOfMonth(year,month,eom_day);
|
||||
|
||||
//construct an iterator starting with firt day of the month
|
||||
day_iterator ditr(date(year,month,1));
|
||||
//loop thru the days and print each one
|
||||
for (; ditr <= endOfMonth; ++ditr) {
|
||||
#if defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
std::cout << to_simple_string(*ditr) << " ["
|
||||
#else
|
||||
std::cout << *ditr << " ["
|
||||
<< ditr->day_of_week() << "]"
|
||||
#endif
|
||||
<< ditr->day_of_week() << " week: "
|
||||
<< ditr->week_number() << "]"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
@@ -48,3 +54,11 @@ main()
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/* A simple example for creating various dst_calc_rule instances
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include "boost/date_time/local_time/local_time.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace local_time;
|
||||
using namespace gregorian;
|
||||
|
||||
/***** create the necessary date_generator objects *****/
|
||||
// starting generators
|
||||
first_day_of_the_week_in_month fd_start(Sunday, May);
|
||||
last_day_of_the_week_in_month ld_start(Sunday, May);
|
||||
nth_day_of_the_week_in_month nkd_start(nth_day_of_the_week_in_month::third,
|
||||
Sunday, May);
|
||||
partial_date pd_start(1, May);
|
||||
// ending generators
|
||||
first_day_of_the_week_in_month fd_end(Sunday, Oct);
|
||||
last_day_of_the_week_in_month ld_end(Sunday, Oct);
|
||||
nth_day_of_the_week_in_month nkd_end(nth_day_of_the_week_in_month::third,
|
||||
Sunday, Oct);
|
||||
partial_date pd_end(31, Oct);
|
||||
|
||||
/***** create the various dst_calc_rule objects *****/
|
||||
dst_calc_rule_ptr pdr(new partial_date_dst_rule(pd_start, pd_end));
|
||||
dst_calc_rule_ptr flr(new first_last_dst_rule(fd_start, ld_end));
|
||||
dst_calc_rule_ptr llr(new last_last_dst_rule(ld_start, ld_end));
|
||||
dst_calc_rule_ptr nlr(new nth_last_dst_rule(nkd_start, ld_end));
|
||||
dst_calc_rule_ptr ndr(new nth_day_of_the_week_in_month_dst_rule(nkd_start, nkd_end));
|
||||
|
||||
std::cout << "Program run successfully" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copyright 2001-2005: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
|
||||
#include "boost/date_time/local_time/local_time.hpp"
|
||||
#include <iostream>
|
||||
|
||||
/* This example shows a program that calculates the arrival time of a plane
|
||||
* that flys from Phoenix to New York. During the flight New York shifts
|
||||
* into daylight savings time (Phoenix doesn't because Arizona doesn't use
|
||||
* DST).
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::gregorian;
|
||||
using namespace boost::local_time;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
|
||||
//setup some timezones for creating and adjusting local times
|
||||
//This user editable file can be found in libs/date_time/data.
|
||||
tz_database tz_db;
|
||||
try {
|
||||
tz_db.load_from_file("../../data/date_time_zonespec.csv");
|
||||
}catch(const data_not_accessible& dna) {
|
||||
std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}catch(const bad_field_count& bfc) {
|
||||
std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
time_zone_ptr nyc_tz = tz_db.time_zone_from_region("America/New_York");
|
||||
//Use a newly created time zone rule
|
||||
time_zone_ptr phx_tz(new posix_time_zone("MST-07:00:00"));
|
||||
|
||||
//local departure time in Phoenix is 11 pm on March 13 2010
|
||||
// (NY changes to DST on March 14 at 2 am)
|
||||
local_date_time phx_departure(date(2010, Mar, 13), hours(23),
|
||||
phx_tz,
|
||||
local_date_time::NOT_DATE_TIME_ON_ERROR);
|
||||
local_date_time nyc_departure = phx_departure.local_time_in(nyc_tz);
|
||||
|
||||
time_duration flight_length = hours(4) + minutes(30);
|
||||
local_date_time phx_arrival = phx_departure + flight_length;
|
||||
local_date_time nyc_arrival = phx_arrival.local_time_in(nyc_tz);
|
||||
|
||||
std::cout << "departure PHX time: " << phx_departure << std::endl;
|
||||
std::cout << "departure NYC time: " << nyc_departure << std::endl;
|
||||
std::cout << "arrival PHX time: " << phx_arrival << std::endl;
|
||||
std::cout << "arrival NYC time: " << nyc_arrival << std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Copyright 2005: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "boost/date_time/gregorian/gregorian.hpp"
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
#include "boost/date_time/local_time/local_time.hpp"
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
|
||||
int main() {
|
||||
using namespace boost::gregorian;
|
||||
using namespace boost::posix_time;
|
||||
using namespace boost::local_time;
|
||||
|
||||
tz_database tz_db;
|
||||
try {
|
||||
tz_db.load_from_file("../../data/date_time_zonespec.csv");
|
||||
}catch(data_not_accessible dna) {
|
||||
std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}catch(bad_field_count bfc) {
|
||||
std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
time_zone_ptr nyc = tz_db.time_zone_from_region("America/New_York");
|
||||
local_date_time ny_time(date(2004, Aug, 30), hours(10), nyc, true);
|
||||
|
||||
typedef boost::date_time::time_facet<local_date_time, char> ldt_facet;
|
||||
ldt_facet* timefacet = new ldt_facet("%Y-%b-%d %H:%M:%S""%F %Z");
|
||||
std::locale loc(std::locale::classic(), timefacet);
|
||||
|
||||
std::cout << ny_time << std::endl;
|
||||
// 2004-Aug-30 10:00:00 EDT
|
||||
std::cout.imbue(loc);
|
||||
std::cout << ny_time << std::endl;
|
||||
// 2004-Aug-30 10:00:00 Eastern Daylight Time
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Copyright 2004-2005: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
@@ -0,0 +1,65 @@
|
||||
/* This example demonstrates the use of the time zone database and
|
||||
* local time to calculate the number of seconds since the UTC
|
||||
* time_t epoch 1970-01-01 00:00:00. Note that the selected timezone
|
||||
* could be any timezone supported in the time zone database file which
|
||||
* can be modified and updated as needed by the user.
|
||||
*
|
||||
* To solve this problem the following steps are required:
|
||||
* 1) Get a timezone from the tz database for the local time
|
||||
* 2) Construct a local time using the timezone
|
||||
* 3) Construct a posix_time::ptime for the time_t epoch time
|
||||
* 4) Convert the local_time to utc and subtract the epoch time
|
||||
*
|
||||
*/
|
||||
|
||||
#include "boost/date_time/local_time/local_time.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::gregorian;
|
||||
using namespace boost::local_time;
|
||||
using namespace boost::posix_time;
|
||||
|
||||
tz_database tz_db;
|
||||
try {
|
||||
tz_db.load_from_file("../data/date_time_zonespec.csv");
|
||||
}catch(const data_not_accessible& dna) {
|
||||
std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}catch(const bad_field_count& bfc) {
|
||||
std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
time_zone_ptr nyc_tz = tz_db.time_zone_from_region("America/New_York");
|
||||
date in_date(2004,10,04);
|
||||
time_duration td(12,14,32);
|
||||
// construct with local time value
|
||||
// create not-a-date-time if invalid (eg: in dst transition)
|
||||
local_date_time nyc_time(in_date,
|
||||
td,
|
||||
nyc_tz,
|
||||
local_date_time::NOT_DATE_TIME_ON_ERROR);
|
||||
|
||||
std::cout << nyc_time << std::endl;
|
||||
|
||||
ptime time_t_epoch(date(1970,1,1));
|
||||
std::cout << time_t_epoch << std::endl;
|
||||
|
||||
// first convert nyc_time to utc via the utc_time()
|
||||
// call and subtract the ptime.
|
||||
time_duration diff = nyc_time.utc_time() - time_t_epoch;
|
||||
|
||||
//Expected 1096906472
|
||||
std::cout << "Seconds diff: " << diff.total_seconds() << std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Copyright 2005: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
@@ -0,0 +1,86 @@
|
||||
/* A simple example for using a custom_time_zone and a posix_time_zone.
|
||||
*/
|
||||
|
||||
#include "boost/date_time/local_time/local_time.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace local_time;
|
||||
using namespace gregorian;
|
||||
using posix_time::time_duration;
|
||||
|
||||
/***** custom_time_zone *****/
|
||||
|
||||
// create the dependent objects for a custom_time_zone
|
||||
time_zone_names tzn("Eastern Standard Time", "EST",
|
||||
"Eastern Daylight Time", "EDT");
|
||||
time_duration utc_offset(-5,0,0);
|
||||
dst_adjustment_offsets adj_offsets(time_duration(1,0,0),
|
||||
time_duration(2,0,0),
|
||||
time_duration(2,0,0));
|
||||
// rules for this zone are:
|
||||
// start on first Sunday of April at 2 am
|
||||
// end on last Sunday of October at 2 am
|
||||
// so we use a first_last_dst_rule
|
||||
first_day_of_the_week_in_month start_rule(Sunday, Apr);
|
||||
last_day_of_the_week_in_month end_rule(Sunday, Oct);
|
||||
shared_ptr<dst_calc_rule> nyc_rules(new first_last_dst_rule(start_rule,
|
||||
end_rule));
|
||||
// create more dependent objects for a non-dst custom_time_zone
|
||||
time_zone_names tzn2("Mountain Standard Time", "MST",
|
||||
"", ""); // no dst means empty dst strings
|
||||
time_duration utc_offset2(-7,0,0);
|
||||
dst_adjustment_offsets adj_offsets2(time_duration(0,0,0),
|
||||
time_duration(0,0,0),
|
||||
time_duration(0,0,0));
|
||||
// no dst means we need a null pointer to the rules
|
||||
shared_ptr<dst_calc_rule> phx_rules;
|
||||
|
||||
// create the custom_time_zones
|
||||
time_zone_ptr nyc_1(new custom_time_zone(tzn, utc_offset, adj_offsets, nyc_rules));
|
||||
time_zone_ptr phx_1(new custom_time_zone(tzn2, utc_offset2, adj_offsets2, phx_rules));
|
||||
|
||||
/***** posix_time_zone *****/
|
||||
|
||||
// create posix_time_zones that are the duplicates of the
|
||||
// custom_time_zones created above. See posix_time_zone documentation
|
||||
// for details on full zone names.
|
||||
std::string nyc_string, phx_string;
|
||||
nyc_string = "EST-05:00:00EDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00";
|
||||
// nyc_string = "EST-05EDT,M4.1.0,M10.5.0"; // shorter when defaults used
|
||||
phx_string = "MST-07"; // no-dst
|
||||
time_zone_ptr nyc_2(new posix_time_zone(nyc_string));
|
||||
time_zone_ptr phx_2(new posix_time_zone(phx_string));
|
||||
|
||||
|
||||
/***** show the sets are equal *****/
|
||||
|
||||
std::cout << "The first zone is in daylight savings from:\n "
|
||||
<< nyc_1->dst_local_start_time(2004) << " through "
|
||||
<< nyc_1->dst_local_end_time(2004) << std::endl;
|
||||
|
||||
std::cout << "The second zone is in daylight savings from:\n "
|
||||
<< nyc_2->dst_local_start_time(2004) << " through "
|
||||
<< nyc_2->dst_local_end_time(2004) << std::endl;
|
||||
|
||||
std::cout << "The third zone (no daylight savings):\n "
|
||||
<< phx_1->std_zone_abbrev() << " and "
|
||||
<< phx_1->base_utc_offset() << std::endl;
|
||||
|
||||
std::cout << "The fourth zone (no daylight savings):\n "
|
||||
<< phx_2->std_zone_abbrev() << " and "
|
||||
<< phx_2->base_utc_offset() << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copyright 2001-2005: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
# Copyright (c) 2002-2005 CrystalClear Software, Inc.
|
||||
# Use, modification and distribution is subject to the
|
||||
# Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
project
|
||||
: requirements <library>../../build/boost_date_time
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
//Demonstrate conversions between a local time and utc
|
||||
/* Output:
|
||||
|
||||
UTC <--> New York while DST is NOT active (5 hours)
|
||||
2001-Dec-31 19:00:00 in New York is 2002-Jan-01 00:00:00 UTC time
|
||||
2002-Jan-01 00:00:00 UTC is 2001-Dec-31 19:00:00 New York time
|
||||
|
||||
UTC <--> New York while DST is active (4 hours)
|
||||
2002-May-31 20:00:00 in New York is 2002-Jun-01 00:00:00 UTC time
|
||||
2002-Jun-01 00:00:00 UTC is 2002-May-31 20:00:00 New York time
|
||||
|
||||
UTC <--> Arizona (7 hours)
|
||||
2002-May-31 17:00:00 in Arizona is 2002-Jun-01 00:00:00 UTC time
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* Demonstrate conversions between a local time and utc
|
||||
* Output:
|
||||
*
|
||||
* UTC <--> New York while DST is NOT active (5 hours)
|
||||
* 2001-Dec-31 19:00:00 in New York is 2002-Jan-01 00:00:00 UTC time
|
||||
* 2002-Jan-01 00:00:00 UTC is 2001-Dec-31 19:00:00 New York time
|
||||
*
|
||||
* UTC <--> New York while DST is active (4 hours)
|
||||
* 2002-May-31 20:00:00 in New York is 2002-Jun-01 00:00:00 UTC time
|
||||
* 2002-Jun-01 00:00:00 UTC is 2002-May-31 20:00:00 New York time
|
||||
*
|
||||
* UTC <--> Arizona (7 hours)
|
||||
* 2002-May-31 17:00:00 in Arizona is 2002-Jun-01 00:00:00 UTC time
|
||||
*/
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
#include "boost/date_time/local_time_adjustor.hpp"
|
||||
@@ -83,3 +80,11 @@ main()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,26 +1,24 @@
|
||||
//Print the remaining hours of the day
|
||||
//Uses the clock to get the local time
|
||||
//Use an iterator to iterate over the remaining hours
|
||||
//Retrieve the date part from a time
|
||||
/* Expected Output something like:
|
||||
|
||||
2002-Mar-08 16:30:59
|
||||
2002-Mar-08 17:30:59
|
||||
2002-Mar-08 18:30:59
|
||||
2002-Mar-08 19:30:59
|
||||
2002-Mar-08 20:30:59
|
||||
2002-Mar-08 21:30:59
|
||||
2002-Mar-08 22:30:59
|
||||
2002-Mar-08 23:30:59
|
||||
Time left till midnight: 07:29:01
|
||||
|
||||
*/
|
||||
|
||||
/* Print the remaining hours of the day
|
||||
* Uses the clock to get the local time
|
||||
* Use an iterator to iterate over the remaining hours
|
||||
* Retrieve the date part from a time
|
||||
*
|
||||
* Expected Output something like:
|
||||
*
|
||||
* 2002-Mar-08 16:30:59
|
||||
* 2002-Mar-08 17:30:59
|
||||
* 2002-Mar-08 18:30:59
|
||||
* 2002-Mar-08 19:30:59
|
||||
* 2002-Mar-08 20:30:59
|
||||
* 2002-Mar-08 21:30:59
|
||||
* 2002-Mar-08 22:30:59
|
||||
* 2002-Mar-08 23:30:59
|
||||
* Time left till midnight: 07:29:01
|
||||
*/
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
@@ -31,17 +29,25 @@ main()
|
||||
ptime now = second_clock::local_time();
|
||||
//Get the date part out of the time
|
||||
date today = now.date();
|
||||
date tommorrow = today + date_duration(1);
|
||||
ptime tommorrow_start(tommorrow); //midnight
|
||||
date tomorrow = today + days(1);
|
||||
ptime tomorrow_start(tomorrow); //midnight
|
||||
|
||||
//iterator adds by one hour
|
||||
time_iterator titr(now,hours(1));
|
||||
for (; titr < tommorrow_start; ++titr) {
|
||||
for (; titr < tomorrow_start; ++titr) {
|
||||
std::cout << to_simple_string(*titr) << std::endl;
|
||||
}
|
||||
|
||||
time_duration remaining = tommorrow_start - now;
|
||||
time_duration remaining = tomorrow_start - now;
|
||||
std::cout << "Time left till midnight: "
|
||||
<< to_simple_string(remaining) << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//Some simple examples of constructing and calculating with times
|
||||
//Output:
|
||||
//2002-Feb-01 00:00:00 - 2002-Feb-01 05:04:02.001000000 = -5:04:02.001000000
|
||||
/* Some simple examples of constructing and calculating with times
|
||||
* Output:
|
||||
* 2002-Feb-01 00:00:00 - 2002-Feb-01 05:04:02.001000000 = -5:04:02.001000000
|
||||
*/
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
#include <iostream>
|
||||
@@ -12,10 +13,10 @@ main()
|
||||
using namespace boost::gregorian;
|
||||
|
||||
date d(2002,Feb,1); //an arbitrary date
|
||||
//construct a time by adding up some durations durations
|
||||
ptime t1(d, hours(5)+minutes(4)+seconds(2)+millisec(1));
|
||||
//construct a time by adding up some durations
|
||||
ptime t1(d, hours(5)+minutes(4)+seconds(2)+milliseconds(1));
|
||||
//construct a new time by subtracting some times
|
||||
ptime t2 = t1 - hours(5)- minutes(4)- seconds(2)- millisec(1);
|
||||
ptime t2 = t1 - hours(5)- minutes(4)- seconds(2)- milliseconds(1);
|
||||
//construct a duration by taking the difference between times
|
||||
time_duration td = t2 - t1;
|
||||
|
||||
@@ -26,3 +27,10 @@ main()
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//Some simple examples of constructing and calculating with times
|
||||
//Returns:
|
||||
//[2002-Feb-01 00:00:00/2002-Feb-01 23:59:59.999999999] contains 2002-Feb-01 03:00:05
|
||||
//[2002-Feb-01 00:00:00/2002-Feb-01 23:59:59.999999999] intersected with
|
||||
//[2002-Feb-01 00:00:00/2002-Feb-01 03:00:04.999999999] is
|
||||
//[2002-Feb-01 00:00:00/2002-Feb-01 03:00:04.999999999]
|
||||
|
||||
/* Some simple examples of constructing and calculating with times
|
||||
* Returns:
|
||||
* [2002-Feb-01 00:00:00/2002-Feb-01 23:59:59.999999999] contains 2002-Feb-01 03:00:05
|
||||
* [2002-Feb-01 00:00:00/2002-Feb-01 23:59:59.999999999] intersected with
|
||||
* [2002-Feb-01 00:00:00/2002-Feb-01 03:00:04.999999999] is
|
||||
* [2002-Feb-01 00:00:00/2002-Feb-01 03:00:04.999999999]
|
||||
*/
|
||||
|
||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
||||
#include <iostream>
|
||||
@@ -48,3 +48,11 @@ main()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Copyright 2001-2004: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
#include <iostream>
|
||||
#include <boost/date_time/local_time/local_time.hpp>
|
||||
|
||||
int main(){
|
||||
using namespace boost::gregorian;
|
||||
using namespace boost::posix_time;
|
||||
using namespace boost::local_time;
|
||||
using namespace std;
|
||||
|
||||
/****** basic use ******/
|
||||
date d(2004, Feb, 29);
|
||||
time_duration td(12,34,56,789);
|
||||
stringstream ss;
|
||||
ss << d << ' ' << td;
|
||||
ptime pt(not_a_date_time);
|
||||
cout << pt << endl; // "not-a-date-time"
|
||||
ss >> pt;
|
||||
cout << pt << endl; // "2004-Feb-29 12:34:56.000789"
|
||||
ss.str("");
|
||||
ss << pt << " EDT-05EDT,M4.1.0,M10.5.0";
|
||||
local_date_time ldt(not_a_date_time);
|
||||
ss >> ldt;
|
||||
cout << ldt << endl; // " 2004-Feb-29 12:34:56.000789 EDT"
|
||||
|
||||
|
||||
/****** format strings ******/
|
||||
local_time_facet* output_facet = new local_time_facet();
|
||||
local_time_input_facet* input_facet = new local_time_input_facet();
|
||||
ss.imbue(locale(locale::classic(), output_facet));
|
||||
ss.imbue(locale(ss.getloc(), input_facet));
|
||||
output_facet->format("%a %b %d, %H:%M %z");
|
||||
ss.str("");
|
||||
ss << ldt;
|
||||
cout << ss.str() << endl; // "Sun Feb 29, 12:34 EDT"
|
||||
|
||||
output_facet->format(local_time_facet::iso_time_format_specifier);
|
||||
ss.str("");
|
||||
ss << ldt;
|
||||
cout << ss.str() << endl; // "20040229T123456.000789-0500"
|
||||
output_facet->format(local_time_facet::iso_time_format_extended_specifier);
|
||||
ss.str("");
|
||||
ss << ldt;
|
||||
cout << ss.str() << endl; // "2004-02-29 12:34:56.000789-05:00"
|
||||
|
||||
// extra words in format
|
||||
string my_format("The extended ordinal time %Y-%jT%H:%M can also be represented as %A %B %d, %Y");
|
||||
output_facet->format(my_format.c_str());
|
||||
input_facet->format(my_format.c_str());
|
||||
ss.str("");
|
||||
ss << ldt;
|
||||
cout << ss.str() << endl;
|
||||
|
||||
// matching extra words in input
|
||||
ss.str("The extended ordinal time 2005-128T12:15 can also be represented as Sunday May 08, 2005");
|
||||
ss >> ldt;
|
||||
cout << ldt << endl; // cout is using default format "2005-May-08 12:15:00 UTC"
|
||||
|
||||
/****** content strings ******/
|
||||
// set up the collections of custom strings.
|
||||
// only the full names are altered for the sake of brevity
|
||||
string month_names[12] = { "january", "february", "march",
|
||||
"april", "may", "june",
|
||||
"july", "august", "september",
|
||||
"october", "november", "december" };
|
||||
vector<string> long_months(&month_names[0], &month_names[12]);
|
||||
string day_names[7] = { "sunday", "monday", "tuesday", "wednesday",
|
||||
"thursday", "friday", "saturday" };
|
||||
vector<string> long_days(&day_names[0], &day_names[7]);
|
||||
|
||||
// create date_facet and date_input_facet using all defaults
|
||||
date_facet* date_output = new date_facet();
|
||||
date_input_facet* date_input = new date_input_facet();
|
||||
ss.imbue(locale(ss.getloc(), date_output));
|
||||
ss.imbue(locale(ss.getloc(), date_input));
|
||||
|
||||
// replace names in the output facet
|
||||
date_output->long_month_names(long_months);
|
||||
date_output->long_weekday_names(long_days);
|
||||
|
||||
// replace names in the input facet
|
||||
date_input->long_month_names(long_months);
|
||||
date_input->long_weekday_names(long_days);
|
||||
|
||||
// customize month, weekday and date formats
|
||||
date_output->format("%Y-%B-%d");
|
||||
date_input->format("%Y-%B-%d");
|
||||
date_output->month_format("%B"); // full name
|
||||
date_input->month_format("%B"); // full name
|
||||
date_output->weekday_format("%A"); // full name
|
||||
date_input->weekday_format("%A"); // full name
|
||||
|
||||
ss.str("");
|
||||
ss << greg_month(3);
|
||||
cout << ss.str() << endl; // "march"
|
||||
ss.str("");
|
||||
ss << greg_weekday(3);
|
||||
cout << ss.str() << endl; // "tuesday"
|
||||
ss.str("");
|
||||
ss << date(2005,Jul,4);
|
||||
cout << ss.str() << endl; // "2005-july-04"
|
||||
|
||||
|
||||
/****** special values ******/
|
||||
// reset the formats to defaults
|
||||
output_facet->format(local_time_facet::default_time_format);
|
||||
input_facet->format(local_time_input_facet::default_time_input_format);
|
||||
|
||||
// create custom special_values parser and formatter objects
|
||||
// and add them to the facets
|
||||
string sv[5] = {"nadt","neg_inf", "pos_inf", "min_dt", "max_dt" };
|
||||
vector<string> sv_names(&sv[0], &sv[5]);
|
||||
special_values_parser sv_parser(sv_names.begin(), sv_names.end());
|
||||
special_values_formatter sv_formatter(sv_names.begin(), sv_names.end());
|
||||
output_facet->special_values_formatter(sv_formatter);
|
||||
input_facet->special_values_parser(sv_parser);
|
||||
|
||||
ss.str("");
|
||||
ldt = local_date_time(not_a_date_time);
|
||||
ss << ldt;
|
||||
cout << ss.str() << endl; // "nadt"
|
||||
|
||||
ss.str("min_dt");
|
||||
ss >> ldt;
|
||||
ss.str("");
|
||||
ss << ldt;
|
||||
cout << ss.str() << endl; // "1400-Jan-01 00:00:00 UTC"
|
||||
|
||||
/****** date/time periods ******/
|
||||
// reset all formats to defaults
|
||||
date_output->format(date_facet::default_date_format);
|
||||
date_input->format(date_facet::default_date_format);
|
||||
date_output->month_format("%b"); // abbrev
|
||||
date_input->month_format("%b"); // abbrev
|
||||
date_output->weekday_format("%a"); // abbrev
|
||||
date_input->weekday_format("%a"); // abbrev
|
||||
|
||||
// create our date_period
|
||||
date_period dp(date(2005,Mar,1), days(31)); // month of march
|
||||
|
||||
// custom period formatter and parser
|
||||
period_formatter per_formatter(period_formatter::AS_OPEN_RANGE,
|
||||
" to ", "from ", " exclusive", " inclusive" );
|
||||
period_parser per_parser(period_parser::AS_OPEN_RANGE,
|
||||
" to ", "from ", " exclusive" , " inclusive" );
|
||||
|
||||
// default output
|
||||
ss.str("");
|
||||
ss << dp;
|
||||
cout << ss.str() << endl; // "[2005-Mar-01/2005-Mar-31]"
|
||||
|
||||
// add out custom parser and formatter to the facets
|
||||
date_output->period_formatter(per_formatter);
|
||||
date_input->period_parser(per_parser);
|
||||
|
||||
// custom output
|
||||
ss.str("");
|
||||
ss << dp;
|
||||
cout << ss.str() << endl; // "from 2005-Feb-01 to 2005-Apr-01 exclusive"
|
||||
|
||||
|
||||
/****** date generators ******/
|
||||
// custom date_generator phrases
|
||||
string dg_phrases[9] = { "1st", "2nd", "3rd", "4th", "5th",
|
||||
"final", "prior to", "following", "in" };
|
||||
vector<string> phrases(&dg_phrases[0], &dg_phrases[9]);
|
||||
|
||||
// create our date_generator
|
||||
first_day_of_the_week_before d_gen(Monday);
|
||||
|
||||
// default output
|
||||
ss.str("");
|
||||
ss << d_gen;
|
||||
cout << ss.str() << endl; // "Mon before"
|
||||
|
||||
// add our custom strings to the date facets
|
||||
date_output->date_gen_phrase_strings(phrases);
|
||||
date_input->date_gen_element_strings(phrases);
|
||||
|
||||
// custom output
|
||||
ss.str("");
|
||||
ss << d_gen;
|
||||
cout << ss.str() << endl; // "Mon prior to"
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Copyright 2005: CrystalClear Software, Inc
|
||||
* http://www.crystalclearsoftware.com
|
||||
*
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef BOOST_DATE_TIME_ALL_HPP___
|
||||
#define BOOST_DATE_TIME_ALL_HPP___
|
||||
|
||||
/* Copyright (c) 2006 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
// See www.boost.org/libs/date_time for documentation.
|
||||
|
||||
//gregorian and posix time included by indirectly
|
||||
#include "boost/date_time/local_time/local_time.hpp"
|
||||
|
||||
#endif // BOOST_DATE_TIME_ALL_HPP___
|
||||
@@ -1,8 +1,12 @@
|
||||
#ifndef _DATE_TIME_ADJUST_FUNCTORS_HPP___
|
||||
#define _DATE_TIME_ADJUST_FUNCTORS_HPP___
|
||||
/* Copyright (c) 2001 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include "boost/date_time/date.hpp"
|
||||
@@ -10,19 +14,23 @@
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
|
||||
|
||||
//! Functor to iterate a fixed number of days
|
||||
template<class date_type>
|
||||
class day_functor
|
||||
class day_functor
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
day_functor(int f) : f_(f) {}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
duration_type get_offset(const date_type&) const
|
||||
{
|
||||
return duration_type(f_);
|
||||
}
|
||||
duration_type get_neg_offset(const date_type&) const
|
||||
{
|
||||
return duration_type(-f_);
|
||||
}
|
||||
private:
|
||||
int f_;
|
||||
};
|
||||
@@ -30,7 +38,7 @@ namespace date_time {
|
||||
|
||||
//! Provides calculation to find next nth month given a date
|
||||
/*! This adjustment function provides the logic for 'month-based'
|
||||
* advancement on a ymd based calendar. The policy it uses
|
||||
* advancement on a ymd based calendar. The policy it uses
|
||||
* to handle the non existant end of month days is to back
|
||||
* up to the last day of the month. Also, if the starting
|
||||
* date is the last day of a month, this functor will attempt
|
||||
@@ -38,7 +46,7 @@ namespace date_time {
|
||||
|
||||
*/
|
||||
template<class date_type>
|
||||
class month_functor
|
||||
class month_functor
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
@@ -47,7 +55,7 @@ namespace date_time {
|
||||
typedef typename cal_type::day_type day_type;
|
||||
|
||||
month_functor(int f) : f_(f), origDayOfMonth_(0) {}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
duration_type get_offset(const date_type& d) const
|
||||
{
|
||||
ymd_type ymd(d.year_month_day());
|
||||
if (origDayOfMonth_ == 0) {
|
||||
@@ -57,9 +65,10 @@ namespace date_time {
|
||||
origDayOfMonth_ = -1; //force the value to the end of month
|
||||
}
|
||||
}
|
||||
date_time::wrapping_int2<short,1,12> wi(ymd.month);
|
||||
unsigned long year = wi.add(f_); //calc the year wrap around
|
||||
year += ymd.year; //now add in the current year
|
||||
typedef date_time::wrapping_int2<short,1,12> wrap_int2;
|
||||
wrap_int2 wi(ymd.month);
|
||||
//calc the year wrap around, add() returns 0 or 1 if wrapped
|
||||
const typename ymd_type::year_type year(static_cast<typename ymd_type::year_type::value_type>(ymd.year + wi.add(f_)));
|
||||
// std::cout << "trace wi: " << wi.as_int() << std::endl;
|
||||
// std::cout << "trace year: " << year << std::endl;
|
||||
//find the last day for the new month
|
||||
@@ -74,6 +83,33 @@ namespace date_time {
|
||||
}
|
||||
return date_type(year, wi.as_int(), dayOfMonth) - d;
|
||||
}
|
||||
//! Returns a negative duration_type
|
||||
duration_type get_neg_offset(const date_type& d) const
|
||||
{
|
||||
ymd_type ymd(d.year_month_day());
|
||||
if (origDayOfMonth_ == 0) {
|
||||
origDayOfMonth_ = ymd.day;
|
||||
day_type endOfMonthDay(cal_type::end_of_month_day(ymd.year,ymd.month));
|
||||
if (endOfMonthDay == ymd.day) {
|
||||
origDayOfMonth_ = -1; //force the value to the end of month
|
||||
}
|
||||
}
|
||||
typedef date_time::wrapping_int2<short,1,12> wrap_int2;
|
||||
wrap_int2 wi(ymd.month);
|
||||
//calc the year wrap around, add() returns 0 or 1 if wrapped
|
||||
const typename ymd_type::year_type year(static_cast<typename ymd_type::year_type::value_type>(ymd.year + wi.subtract(f_)));
|
||||
//find the last day for the new month
|
||||
day_type resultingEndOfMonthDay(cal_type::end_of_month_day(year, wi.as_int()));
|
||||
//original was the end of month -- force to last day of month
|
||||
if (origDayOfMonth_ == -1) {
|
||||
return date_type(year, wi.as_int(), resultingEndOfMonthDay) - d;
|
||||
}
|
||||
day_type dayOfMonth = origDayOfMonth_;
|
||||
if (dayOfMonth > resultingEndOfMonthDay) {
|
||||
dayOfMonth = resultingEndOfMonthDay;
|
||||
}
|
||||
return date_type(year, wi.as_int(), dayOfMonth) - d;
|
||||
}
|
||||
private:
|
||||
int f_;
|
||||
mutable short origDayOfMonth_;
|
||||
@@ -82,54 +118,47 @@ namespace date_time {
|
||||
|
||||
//! Functor to iterate a over weeks
|
||||
template<class date_type>
|
||||
class week_functor
|
||||
class week_functor
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
typedef typename date_type::calendar_type calendar_type;
|
||||
week_functor(int f) : f_(f) {}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
duration_type get_offset(const date_type&) const
|
||||
{
|
||||
return duration_type(f_*calendar_type::days_in_week());
|
||||
return duration_type(f_*static_cast<int>(calendar_type::days_in_week()));
|
||||
}
|
||||
duration_type get_neg_offset(const date_type&) const
|
||||
{
|
||||
return duration_type(-f_*static_cast<int>(calendar_type::days_in_week()));
|
||||
}
|
||||
private:
|
||||
int f_;
|
||||
};
|
||||
|
||||
//! Functor to iterate by a year adjusting for leap years
|
||||
/*!
|
||||
*@throws bad_day if date value is invalid (eg: feb 29)
|
||||
*/
|
||||
template<class date_type>
|
||||
class year_functor
|
||||
class year_functor
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::year_type year_type;
|
||||
//typedef typename date_type::year_type year_type;
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
year_functor(int f) : f_(f) {}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
year_functor(int f) : _mf(f * 12) {}
|
||||
duration_type get_offset(const date_type& d) const
|
||||
{
|
||||
date_type new_date(d.year()+f_, d.month(), d.day());
|
||||
return new_date-d;
|
||||
return _mf.get_offset(d);
|
||||
}
|
||||
duration_type get_neg_offset(const date_type& d) const
|
||||
{
|
||||
return _mf.get_neg_offset(d);
|
||||
}
|
||||
private:
|
||||
int f_;
|
||||
month_functor<date_type> _mf;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} }//namespace date_time
|
||||
|
||||
/* Copyright (c) 2001
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
|
||||
#ifndef DATE_TIME_C_LOCAL_TIME_ADJUSTOR_HPP__
|
||||
#define DATE_TIME_C_LOCAL_TIME_ADJUSTOR_HPP__
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
/*! @file c_local_time_adjustor.hpp
|
||||
@@ -11,7 +14,10 @@
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
#include "boost/date_time/c_time.hpp"
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/c_time.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
@@ -21,8 +27,7 @@ namespace date_time {
|
||||
* machine are correct. This can be a very dangerous assumption.
|
||||
*/
|
||||
template<class time_type>
|
||||
class c_local_adjustor
|
||||
{
|
||||
class c_local_adjustor {
|
||||
public:
|
||||
typedef typename time_type::time_duration_type time_duration_type;
|
||||
typedef typename time_type::date_type date_type;
|
||||
@@ -33,20 +38,27 @@ namespace date_time {
|
||||
date_type time_t_start_day(1970,1,1);
|
||||
time_type time_t_start_time(time_t_start_day,time_duration_type(0,0,0));
|
||||
if (t < time_t_start_time) {
|
||||
throw std::out_of_range("Cannot convert dates prior to Jan 1, 1970");
|
||||
boost::throw_exception(std::out_of_range("Cannot convert dates prior to Jan 1, 1970"));
|
||||
BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return time_t_start_time); // should never reach
|
||||
}
|
||||
date_duration_type dd = t.date() - time_t_start_day;
|
||||
time_duration_type td = t.time_of_day();
|
||||
std::time_t t2 = dd.days()*86400 + td.hours()*3600 + td.minutes()*60 + td.seconds();
|
||||
std::tm* tms = std::localtime(&t2);
|
||||
date_type d(tms->tm_year + 1900,
|
||||
tms->tm_mon + 1,
|
||||
tms->tm_mday);
|
||||
time_duration_type td2(tms->tm_hour,
|
||||
tms->tm_min,
|
||||
tms->tm_sec,
|
||||
uint64_t t2 = static_cast<uint64_t>(dd.days())*86400 +
|
||||
static_cast<uint64_t>(td.hours())*3600 +
|
||||
static_cast<uint64_t>(td.minutes())*60 +
|
||||
td.seconds();
|
||||
// detect y2038 issue and throw instead of proceed with bad time
|
||||
std::time_t tv = boost::numeric_cast<std::time_t>(t2);
|
||||
std::tm tms, *tms_ptr;
|
||||
tms_ptr = c_time::localtime(&tv, &tms);
|
||||
date_type d(static_cast<unsigned short>(tms_ptr->tm_year + 1900),
|
||||
static_cast<unsigned short>(tms_ptr->tm_mon + 1),
|
||||
static_cast<unsigned short>(tms_ptr->tm_mday));
|
||||
time_duration_type td2(tms_ptr->tm_hour,
|
||||
tms_ptr->tm_min,
|
||||
tms_ptr->tm_sec,
|
||||
t.time_of_day().fractional_seconds());
|
||||
|
||||
|
||||
return time_type(d,td2);
|
||||
}
|
||||
};
|
||||
@@ -56,17 +68,5 @@ namespace date_time {
|
||||
} } //namespace date_time
|
||||
|
||||
|
||||
/* Copyright (c) 2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,39 +1,128 @@
|
||||
|
||||
#ifndef DATE_TIME_C_TIME_HPP___
|
||||
#define DATE_TIME_C_TIME_HPP___
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
|
||||
/*! @file c_time.hpp
|
||||
Provide workarounds related to the ctime header
|
||||
*/
|
||||
|
||||
#include "boost/date_time/compiler_config.hpp"
|
||||
#include <ctime>
|
||||
//Work around libraries that don't put time_t and time in namespace std
|
||||
#include <string> // to be able to convert from string literals to exceptions
|
||||
#include <stdexcept>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
|
||||
//Work around libraries that don't put time_t and time in namespace std
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std { using ::time_t; using ::time; using ::localtime;
|
||||
using ::tm; using ::gmtime; }
|
||||
#endif
|
||||
#endif // BOOST_NO_STDC_NAMESPACE
|
||||
|
||||
//The following is used to support high precision time clocks
|
||||
#ifdef BOOST_HAS_GETTIMEOFDAY
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
/* Copyright (c) 2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
#ifdef BOOST_HAS_FTIME
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
//! Provides a uniform interface to some 'ctime' functions
|
||||
/*! Provides a uniform interface to some ctime functions and
|
||||
* their '_r' counterparts. The '_r' functions require a pointer to a
|
||||
* user created std::tm struct whereas the regular functions use a
|
||||
* staticly created struct and return a pointer to that. These wrapper
|
||||
* functions require the user to create a std::tm struct and send in a
|
||||
* pointer to it. This struct may be used to store the resulting time.
|
||||
* The returned pointer may or may not point to this struct, however,
|
||||
* it will point to the result of the corresponding function.
|
||||
* All functions do proper checking of the C function results and throw
|
||||
* exceptions on error. Therefore the functions will never return NULL.
|
||||
*/
|
||||
struct c_time {
|
||||
public:
|
||||
#if defined(BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS)
|
||||
//! requires a pointer to a user created std::tm struct
|
||||
inline
|
||||
static std::tm* localtime(const std::time_t* t, std::tm* result)
|
||||
{
|
||||
// localtime_r() not in namespace std???
|
||||
#if defined(__VMS) && __INITIAL_POINTER_SIZE == 64
|
||||
std::tm tmp;
|
||||
if(!localtime_r(t,&tmp))
|
||||
result = 0;
|
||||
else
|
||||
*result = tmp;
|
||||
#else
|
||||
result = localtime_r(t, result);
|
||||
#endif
|
||||
if (!result)
|
||||
boost::throw_exception(std::runtime_error("could not convert calendar time to local time"));
|
||||
return result;
|
||||
}
|
||||
//! requires a pointer to a user created std::tm struct
|
||||
inline
|
||||
static std::tm* gmtime(const std::time_t* t, std::tm* result)
|
||||
{
|
||||
// gmtime_r() not in namespace std???
|
||||
#if defined(__VMS) && __INITIAL_POINTER_SIZE == 64
|
||||
std::tm tmp;
|
||||
if(!gmtime_r(t,&tmp))
|
||||
result = 0;
|
||||
else
|
||||
*result = tmp;
|
||||
#else
|
||||
result = gmtime_r(t, result);
|
||||
#endif
|
||||
if (!result)
|
||||
boost::throw_exception(std::runtime_error("could not convert calendar time to UTC time"));
|
||||
return result;
|
||||
}
|
||||
#else // BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS
|
||||
|
||||
#if defined(__clang__) // Clang has to be checked before MSVC
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#elif (defined(_MSC_VER) && (_MSC_VER >= 1400))
|
||||
#pragma warning(push) // preserve warning settings
|
||||
#pragma warning(disable : 4996) // disable depricated localtime/gmtime warning on vc8
|
||||
#endif
|
||||
//! requires a pointer to a user created std::tm struct
|
||||
inline
|
||||
static std::tm* localtime(const std::time_t* t, std::tm* result)
|
||||
{
|
||||
result = std::localtime(t);
|
||||
if (!result)
|
||||
boost::throw_exception(std::runtime_error("could not convert calendar time to local time"));
|
||||
return result;
|
||||
}
|
||||
//! requires a pointer to a user created std::tm struct
|
||||
inline
|
||||
static std::tm* gmtime(const std::time_t* t, std::tm* result)
|
||||
{
|
||||
result = std::gmtime(t);
|
||||
if (!result)
|
||||
boost::throw_exception(std::runtime_error("could not convert calendar time to UTC time"));
|
||||
return result;
|
||||
}
|
||||
#if defined(__clang__) // Clang has to be checked before MSVC
|
||||
#pragma clang diagnostic pop
|
||||
#elif (defined(_MSC_VER) && (_MSC_VER >= 1400))
|
||||
#pragma warning(pop) // restore warnings to previous state
|
||||
#endif
|
||||
|
||||
#endif // BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS
|
||||
};
|
||||
}} // namespaces
|
||||
|
||||
#endif // DATE_TIME_C_TIME_HPP___
|
||||
|
||||
@@ -1,41 +1,137 @@
|
||||
#ifndef DATE_TIME_COMPILER_CONFIG_HPP___
|
||||
#define DATE_TIME_COMPILER_CONFIG_HPP___
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
|
||||
* Subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
|
||||
// This file performs some local compiler configurations
|
||||
|
||||
#include "boost/date_time/locale_config.hpp" //set up locale configurations
|
||||
#include <boost/date_time/locale_config.hpp> //set up locale configurations
|
||||
|
||||
//Set up a configuration parameter for platforms that have
|
||||
//GetTimeOfDay
|
||||
#ifdef BOOST_HAS_GETTIMEOFDAY
|
||||
#define BOOST_DATE_TIME_HAS_GETTIMEOFDAY_HIGH_PRECISION_CLOCK
|
||||
#if defined(BOOST_HAS_GETTIMEOFDAY) || defined(BOOST_HAS_FTIME)
|
||||
#define BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
|
||||
#endif
|
||||
|
||||
// To Force no default constructors for date & ptime, un-comment following
|
||||
//#define DATE_TIME_NO_DEFAULT_CONSTRUCTOR
|
||||
|
||||
#if (defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) || (defined(__BORLANDC__)))
|
||||
// Include extensions to date_duration - comment out to remove this feature
|
||||
#define BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES
|
||||
|
||||
#if (defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) || BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) ) )
|
||||
#define BOOST_DATE_TIME_NO_MEMBER_INIT
|
||||
#endif
|
||||
|
||||
//Define INT64_C for some Metrowerks compilers
|
||||
#if (defined(__MWERKS__) && (!defined(INT64_C)))
|
||||
#define INT64_C(value) long long(value)
|
||||
// include these types before we try to re-define them
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
//Define INT64_C for compilers that don't have it
|
||||
#if (!defined(INT64_C))
|
||||
#define INT64_C(value) int64_t(value)
|
||||
#endif
|
||||
|
||||
|
||||
/* Copyright (c) 2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
/* Workaround for Borland iterator error. Error was "Cannot convert 'istream *' to 'wistream *' in function istream_iterator<>::istream_iterator() */
|
||||
#if defined(BOOST_BORLANDC) && defined(BOOST_BCB_WITH_RW_LIB)
|
||||
#define BOOST_DATE_TIME_NO_WISTREAM_ITERATOR
|
||||
#endif
|
||||
|
||||
|
||||
// Borland v5.64 does not have the following in std namespace; v5.5.1 does
|
||||
#if defined(BOOST_BORLANDC) && defined(BOOST_BCB_WITH_STLPORT)
|
||||
#include <locale>
|
||||
namespace std {
|
||||
using stlport::tolower;
|
||||
using stlport::ctype;
|
||||
using stlport::use_facet;
|
||||
}
|
||||
#endif
|
||||
|
||||
// workaround for errors associated with output for date classes
|
||||
// modifications and input streaming for time classes.
|
||||
// Compilers affected are:
|
||||
// gcc295, msvc (neither with STLPort), any borland
|
||||
//
|
||||
#if (((defined(__GNUC__) && (__GNUC__ < 3)) || \
|
||||
(defined(_MSC_VER) && (_MSC_VER < 1300)) ) && \
|
||||
!defined(_STLP_OWN_IOSTREAMS) ) || \
|
||||
BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) )
|
||||
#define BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS
|
||||
#endif
|
||||
|
||||
// The macro marks up places where compiler complains for missing return statement or
|
||||
// uninitialized variables after calling to boost::throw_exception.
|
||||
// BOOST_UNREACHABLE_RETURN doesn't work since even compilers that support
|
||||
// unreachable statements detection emit such warnings.
|
||||
#if defined(_MSC_VER)
|
||||
// Use special MSVC extension to markup unreachable code
|
||||
# define BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(x) __assume(false)
|
||||
#elif !defined(BOOST_NO_UNREACHABLE_RETURN_DETECTION)
|
||||
// Call to a non-returning function should suppress the warning
|
||||
# if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std {
|
||||
using ::abort;
|
||||
}
|
||||
# endif // defined(BOOST_NO_STDC_NAMESPACE)
|
||||
# define BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(x) std::abort()
|
||||
#else
|
||||
// For other poor compilers the specified expression is compiled. Usually, this would be a return statement.
|
||||
# define BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(x) x
|
||||
#endif
|
||||
|
||||
/* The following handles the definition of the necessary macros
|
||||
* for dll building on Win32 platforms.
|
||||
*
|
||||
* For code that will be placed in the date_time .dll,
|
||||
* it must be properly prefixed with BOOST_DATE_TIME_DECL.
|
||||
* The corresponding .cpp file must have BOOST_DATE_TIME_SOURCE
|
||||
* defined before including its header. For examples see:
|
||||
* greg_month.hpp & greg_month.cpp
|
||||
*
|
||||
*/
|
||||
|
||||
// we need to import/export our code only if the user has specifically
|
||||
// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
|
||||
// libraries to be dynamically linked, or BOOST_DATE_TIME_DYN_LINK
|
||||
// if they want just this one to be dynamically liked:
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
|
||||
// export if this is our own source, otherwise import:
|
||||
# ifdef BOOST_DATE_TIME_SOURCE
|
||||
# define BOOST_DATE_TIME_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define BOOST_DATE_TIME_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif // BOOST_DATE_TIME_SOURCE
|
||||
#endif // DYN_LINK
|
||||
//
|
||||
// if BOOST_WHATEVER_DECL isn't defined yet define it now:
|
||||
#ifndef BOOST_DATE_TIME_DECL
|
||||
# define BOOST_DATE_TIME_DECL
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BOOST_HAS_THREADS)
|
||||
# if defined(_MSC_VER) || defined(__MWERKS__) || defined(__MINGW32__) || defined(__BORLANDC__)
|
||||
//no reentrant posix functions (eg: localtime_r)
|
||||
# elif (!defined(__hpux) || (defined(__hpux) && defined(_REENTRANT)))
|
||||
# define BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_NULLPTR)
|
||||
# define BOOST_DATE_TIME_NULLPTR 0
|
||||
#else
|
||||
# define BOOST_DATE_TIME_NULLPTR nullptr
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
|
||||
#ifndef CONSTRAINED_VALUE_HPP___
|
||||
#define CONSTRAINED_VALUE_HPP___
|
||||
/* Copyright (c) 2000 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/is_base_of.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//! Namespace containing constrained_value template and types
|
||||
@@ -29,57 +39,83 @@ namespace CV {
|
||||
*
|
||||
*/
|
||||
template<class value_policies>
|
||||
class constrained_value {
|
||||
class BOOST_SYMBOL_VISIBLE constrained_value {
|
||||
public:
|
||||
typedef typename value_policies::value_type value_type;
|
||||
// typedef except_type exception_type;
|
||||
constrained_value(value_type value)
|
||||
BOOST_CXX14_CONSTEXPR constrained_value(value_type value) : value_((min)())
|
||||
{
|
||||
assign(value);
|
||||
};
|
||||
constrained_value& operator=(value_type v)
|
||||
{
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR constrained_value& operator=(value_type v)
|
||||
{
|
||||
assign(v);
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
//! Return the max allowed value (traits method)
|
||||
static value_type max() {return value_policies::max();};
|
||||
static BOOST_CONSTEXPR value_type
|
||||
max BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::max)();}
|
||||
|
||||
//! Return the min allowed value (traits method)
|
||||
static value_type min() {return value_policies::min();};
|
||||
static BOOST_CONSTEXPR value_type
|
||||
min BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::min)();}
|
||||
|
||||
//! Coerce into the representation type
|
||||
operator value_type() const {return value_;};
|
||||
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
|
||||
protected:
|
||||
value_type value_;
|
||||
private:
|
||||
void assign(value_type value)
|
||||
BOOST_CXX14_CONSTEXPR void assign(value_type value)
|
||||
{
|
||||
//adding 1 below gets rid of a compiler warning which occurs when the
|
||||
//min_value is 0 and the type is unsigned....
|
||||
if (value+1 < min()+1) {
|
||||
if (value+1 < (min)()+1) {
|
||||
value_policies::on_error(value_, value, min_violation);
|
||||
return;
|
||||
}
|
||||
if (value > max()) {
|
||||
if (value > (max)()) {
|
||||
value_policies::on_error(value_, value, max_violation);
|
||||
return;
|
||||
}
|
||||
value_ = value;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//! Template to shortcut the constrained_value policy creation process
|
||||
template<typename rep_type, rep_type min_value,
|
||||
rep_type max_value, class exception_type>
|
||||
class simple_exception_policy
|
||||
class BOOST_SYMBOL_VISIBLE simple_exception_policy
|
||||
{
|
||||
struct BOOST_SYMBOL_VISIBLE exception_wrapper : public exception_type
|
||||
{
|
||||
// In order to support throw_exception mechanism in the BOOST_NO_EXCEPTIONS mode,
|
||||
// we'll have to provide a way to acquire std::exception from the exception being thrown.
|
||||
// However, we cannot derive from it, since it would make it interceptable by this class,
|
||||
// which might not be what the user wanted.
|
||||
operator std::out_of_range () const
|
||||
{
|
||||
// TODO: Make the message more descriptive by using arguments to on_error
|
||||
return std::out_of_range("constrained value boundary has been violated");
|
||||
}
|
||||
};
|
||||
|
||||
typedef typename conditional<
|
||||
is_base_of< std::exception, exception_type >::value,
|
||||
exception_type,
|
||||
exception_wrapper
|
||||
>::type actual_exception_type;
|
||||
|
||||
public:
|
||||
typedef rep_type value_type;
|
||||
static rep_type min() { return min_value; };
|
||||
static rep_type max() { return max_value;};
|
||||
static BOOST_CONSTEXPR rep_type
|
||||
min BOOST_PREVENT_MACRO_SUBSTITUTION () { return min_value; }
|
||||
|
||||
static BOOST_CONSTEXPR rep_type
|
||||
max BOOST_PREVENT_MACRO_SUBSTITUTION () { return max_value; }
|
||||
|
||||
static void on_error(rep_type, rep_type, violation_enum)
|
||||
{
|
||||
throw exception_type();
|
||||
boost::throw_exception(actual_exception_type());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -88,16 +124,6 @@ namespace CV {
|
||||
} } //namespace CV
|
||||
|
||||
|
||||
/* Copyright (c) 2000-2002
|
||||
* CrystalClear Software, Inc.
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,40 +1,45 @@
|
||||
#ifndef DATE_TIME_DATE_HPP___
|
||||
#define DATE_TIME_DATE_HPP___
|
||||
/* Copyright (c) 2000 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include "boost/date_time/year_month_day.hpp"
|
||||
#include "boost/date_time/special_defs.hpp"
|
||||
#include "boost/operators.hpp"
|
||||
#include <boost/operators.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/year_month_day.hpp>
|
||||
#include <boost/date_time/special_defs.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
//!Representation of timepoint at the one day level resolution.
|
||||
/*!
|
||||
/*!
|
||||
The date template represents an interface shell for a date class
|
||||
that is based on a year-month-day system such as the gregorian
|
||||
or iso systems. It provides basic operations to enable calculation
|
||||
and comparisons.
|
||||
or ISO 8601 systems. It provides basic operations to enable calculation
|
||||
and comparisons.
|
||||
|
||||
<b>Theory</b>
|
||||
|
||||
This date representation fundamentally departs from the C tm struct
|
||||
This date representation fundamentally departs from the C tm struct
|
||||
approach. The goal for this type is to provide efficient date
|
||||
operations (add, subtract) and storage (minimize space to represent)
|
||||
in a concrete class. Thus, the date uses a count internally to
|
||||
represent a particular date. The calendar parameter defines
|
||||
represent a particular date. The calendar parameter defines
|
||||
the policies for converting the the year-month-day and internal
|
||||
counted form here. Applications that need to perform heavy
|
||||
formatting of the same date repeatedly will perform better
|
||||
by using the year-month-day representation.
|
||||
|
||||
|
||||
Internally the date uses a day number to represent the date.
|
||||
This is a monotonic time representation. This representation
|
||||
This is a monotonic time representation. This representation
|
||||
allows for fast comparison as well as simplifying
|
||||
the creation of writing numeric operations. Essentially, the
|
||||
the creation of writing numeric operations. Essentially, the
|
||||
internal day number is like adjusted julian day. The adjustment
|
||||
is determined by the Epoch date which is represented as day 1 of
|
||||
the calendar. Day 0 is reserved for negative infinity so that
|
||||
@@ -44,11 +49,11 @@ namespace date_time {
|
||||
day representations.
|
||||
*/
|
||||
|
||||
|
||||
template<class T, class calendar, class duration_type_>
|
||||
class date : private
|
||||
boost::less_than_comparable<T
|
||||
, boost::equality_comparable<T
|
||||
|
||||
template<class T, class calendar, class duration_type_>
|
||||
class BOOST_SYMBOL_VISIBLE date : private
|
||||
boost::less_than_comparable<T
|
||||
, boost::equality_comparable<T
|
||||
> >
|
||||
{
|
||||
public:
|
||||
@@ -63,115 +68,141 @@ namespace date_time {
|
||||
typedef typename calendar::date_rep_type date_rep_type;
|
||||
typedef typename calendar::date_int_type date_int_type;
|
||||
typedef typename calendar::day_of_week_type day_of_week_type;
|
||||
date(year_type year, month_type month, day_type day)
|
||||
: days_(calendar::day_number(ymd_type(year, month, day)))
|
||||
BOOST_CXX14_CONSTEXPR date(year_type y, month_type m, day_type d)
|
||||
: days_(calendar::day_number(ymd_type(y, m, d)))
|
||||
{}
|
||||
date(const ymd_type& ymd)
|
||||
BOOST_CXX14_CONSTEXPR date(const ymd_type& ymd)
|
||||
: days_(calendar::day_number(ymd))
|
||||
{}
|
||||
{}
|
||||
//let the compiler write copy, assignment, and destructor
|
||||
year_type year() const
|
||||
BOOST_CXX14_CONSTEXPR year_type year() const
|
||||
{
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
return ymd.year;
|
||||
}
|
||||
month_type month() const
|
||||
BOOST_CXX14_CONSTEXPR month_type month() const
|
||||
{
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
return ymd.month;
|
||||
}
|
||||
day_type day() const
|
||||
BOOST_CXX14_CONSTEXPR day_type day() const
|
||||
{
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
return ymd.day;
|
||||
}
|
||||
day_of_week_type day_of_week() const
|
||||
BOOST_CXX14_CONSTEXPR day_of_week_type day_of_week() const
|
||||
{
|
||||
ymd_type ymd = calendar::from_day_number(days_);
|
||||
return calendar::day_of_week(ymd);
|
||||
}
|
||||
ymd_type year_month_day() const
|
||||
BOOST_CXX14_CONSTEXPR ymd_type year_month_day() const
|
||||
{
|
||||
return calendar::from_day_number(days_);
|
||||
}
|
||||
bool operator<(const date_type& rhs) const
|
||||
BOOST_CONSTEXPR bool operator<(const date_type& rhs) const
|
||||
{
|
||||
return days_ < rhs.days_;
|
||||
}
|
||||
bool operator==(const date_type& rhs) const
|
||||
BOOST_CONSTEXPR bool operator==(const date_type& rhs) const
|
||||
{
|
||||
return days_ == rhs.days_;
|
||||
}
|
||||
//! check to see if date is a special value
|
||||
BOOST_CONSTEXPR bool is_special()const
|
||||
{
|
||||
return(is_not_a_date() || is_infinity());
|
||||
}
|
||||
//! check to see if date is not a value
|
||||
bool is_not_a_date() const
|
||||
BOOST_CONSTEXPR bool is_not_a_date() const
|
||||
{
|
||||
return traits_type::is_not_a_number(days_);
|
||||
}
|
||||
//! check to see if date is one of the infinity values
|
||||
bool is_infinity() const
|
||||
BOOST_CONSTEXPR bool is_infinity() const
|
||||
{
|
||||
return traits_type::is_inf(days_);
|
||||
}
|
||||
//! check to see if date is greater than all possible dates
|
||||
bool is_pos_infinity() const
|
||||
BOOST_CONSTEXPR bool is_pos_infinity() const
|
||||
{
|
||||
return traits_type::is_pos_infinity(days_);
|
||||
return traits_type::is_pos_inf(days_);
|
||||
}
|
||||
//! check to see if date is greater than all possible dates
|
||||
bool is_neg_infinity() const
|
||||
BOOST_CONSTEXPR bool is_neg_infinity() const
|
||||
{
|
||||
return traits_type::is_neg_infinity(days_);
|
||||
return traits_type::is_neg_inf(days_);
|
||||
}
|
||||
//! return as a special value or a not_special if a normal date
|
||||
special_values as_special() const
|
||||
BOOST_CXX14_CONSTEXPR special_values as_special() const
|
||||
{
|
||||
return traits_type::to_special(days_);
|
||||
}
|
||||
duration_type operator-(const date_type& d) const
|
||||
BOOST_CXX14_CONSTEXPR duration_type operator-(const date_type& d) const
|
||||
{
|
||||
date_rep_type val = date_rep_type(days_) - date_rep_type(d.days_);
|
||||
return duration_type(val.as_number());
|
||||
if (!this->is_special() && !d.is_special())
|
||||
{
|
||||
// The duration underlying type may be wider than the date underlying type.
|
||||
// Thus we calculate the difference in terms of two durations from some common fixed base date.
|
||||
typedef typename duration_type::duration_rep_type duration_rep_type;
|
||||
return duration_type(static_cast< duration_rep_type >(days_) - static_cast< duration_rep_type >(d.days_));
|
||||
}
|
||||
else
|
||||
{
|
||||
// In this case the difference will be a special value, too
|
||||
date_rep_type val = date_rep_type(days_) - date_rep_type(d.days_);
|
||||
return duration_type(val.as_special());
|
||||
}
|
||||
}
|
||||
|
||||
date_type operator-(const duration_type& dd) const
|
||||
|
||||
BOOST_CXX14_CONSTEXPR date_type operator-(const duration_type& dd) const
|
||||
{
|
||||
return date_type(date_rep_type(days_) - dd.days());
|
||||
if(dd.is_special())
|
||||
{
|
||||
return date_type(date_rep_type(days_) - dd.get_rep());
|
||||
}
|
||||
return date_type(date_rep_type(days_) - static_cast<date_int_type>(dd.days()));
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR date_type operator-=(const duration_type& dd)
|
||||
{
|
||||
*this = *this - dd;
|
||||
return date_type(days_);
|
||||
}
|
||||
BOOST_CONSTEXPR date_rep_type day_count() const
|
||||
{
|
||||
return days_;
|
||||
}
|
||||
date_rep_type day_count() const {return days_;};
|
||||
//allow internal access from operators
|
||||
date_type operator+(const duration_type& dd) const
|
||||
BOOST_CXX14_CONSTEXPR date_type operator+(const duration_type& dd) const
|
||||
{
|
||||
return date_type(date_rep_type(days_) + dd.days());
|
||||
if(dd.is_special())
|
||||
{
|
||||
return date_type(date_rep_type(days_) + dd.get_rep());
|
||||
}
|
||||
return date_type(date_rep_type(days_) + static_cast<date_int_type>(dd.days()));
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR date_type operator+=(const duration_type& dd)
|
||||
{
|
||||
*this = *this + dd;
|
||||
return date_type(days_);
|
||||
}
|
||||
|
||||
//see reference
|
||||
protected:
|
||||
/*! This is a private constructor which allows for the creation of new
|
||||
dates. It is not exposed to users since that would require class
|
||||
/*! This is a private constructor which allows for the creation of new
|
||||
dates. It is not exposed to users since that would require class
|
||||
users to understand the inner workings of the date class.
|
||||
*/
|
||||
date(date_int_type days) : days_(days) {};
|
||||
date(date_rep_type days) : days_(days.as_number()) {};
|
||||
BOOST_CONSTEXPR explicit date(date_int_type days) : days_(days) {}
|
||||
BOOST_CXX14_CONSTEXPR explicit date(date_rep_type days) : days_(days.as_number()) {}
|
||||
date_int_type days_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} } // namespace date_time
|
||||
|
||||
/* Copyright (c) 2000
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
|
||||
#ifndef DATE_CLOCK_DEVICE_HPP___
|
||||
#define DATE_CLOCK_DEVICE_HPP___
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include "boost/date_time/c_time.hpp"
|
||||
@@ -13,7 +16,7 @@ namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
//! A clock providing day level services based on C time_t capabilities
|
||||
/*! This clock uses Posix interfaces as its implemenation and hence
|
||||
/*! This clock uses Posix interfaces as its implementation and hence
|
||||
* uses the timezone settings of the operating system. Incorrect
|
||||
* user settings will result in incorrect results for the calls
|
||||
* to local_day.
|
||||
@@ -31,18 +34,20 @@ namespace date_time {
|
||||
//! Get the local day as a ymd_type
|
||||
static typename date_type::ymd_type local_day_ymd()
|
||||
{
|
||||
::std::tm* curr = get_local_time();
|
||||
return ymd_type(curr->tm_year + 1900,
|
||||
curr->tm_mon + 1,
|
||||
curr->tm_mday);
|
||||
::std::tm result;
|
||||
::std::tm* curr = get_local_time(result);
|
||||
return ymd_type(static_cast<unsigned short>(curr->tm_year + 1900),
|
||||
static_cast<unsigned short>(curr->tm_mon + 1),
|
||||
static_cast<unsigned short>(curr->tm_mday));
|
||||
}
|
||||
//! Get the current day in universal date as a ymd_type
|
||||
static typename date_type::ymd_type universal_day_ymd()
|
||||
{
|
||||
::std::tm* curr = get_universal_time();
|
||||
return ymd_type(curr->tm_year + 1900,
|
||||
curr->tm_mon + 1,
|
||||
curr->tm_mday);
|
||||
::std::tm result;
|
||||
::std::tm* curr = get_universal_time(result);
|
||||
return ymd_type(static_cast<unsigned short>(curr->tm_year + 1900),
|
||||
static_cast<unsigned short>(curr->tm_mon + 1),
|
||||
static_cast<unsigned short>(curr->tm_mday));
|
||||
}
|
||||
//! Get the UTC day as a date type
|
||||
static date_type universal_day()
|
||||
@@ -51,33 +56,22 @@ namespace date_time {
|
||||
}
|
||||
|
||||
private:
|
||||
static ::std::tm* get_local_time()
|
||||
static ::std::tm* get_local_time(std::tm& result)
|
||||
{
|
||||
::std::time_t t;
|
||||
::std::time(&t);
|
||||
return ::std::localtime(&t);
|
||||
return c_time::localtime(&t, &result);
|
||||
}
|
||||
static ::std::tm* get_universal_time()
|
||||
static ::std::tm* get_universal_time(std::tm& result)
|
||||
{
|
||||
::std::time_t t;
|
||||
::std::time(&t);
|
||||
return ::std::gmtime(&t);
|
||||
return c_time::gmtime(&t, &result);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
/* Copyright (c) 2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
|
||||
#ifndef DATE_TIME_DATE_DEFS_HPP
|
||||
#define DATE_TIME_DATE_DEFS_HPP
|
||||
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
|
||||
@@ -19,18 +21,6 @@ namespace date_time {
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
/* Copyright (c) 2000,2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,77 +1,146 @@
|
||||
#ifndef DATE_TIME_DATE_DURATION__
|
||||
#define DATE_TIME_DATE_DURATION__
|
||||
/* Copyright (c) 2000 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
|
||||
#include <boost/operators.hpp>
|
||||
#include <boost/date_time/special_defs.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/int_adapter.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
|
||||
|
||||
//! Duration type with date level resolution
|
||||
template<class duration_rep>
|
||||
class date_duration : private
|
||||
boost::less_than_comparable<date_duration< duration_rep>
|
||||
, boost::equality_comparable< date_duration< duration_rep>
|
||||
> >
|
||||
template<class duration_rep_traits>
|
||||
class BOOST_SYMBOL_VISIBLE date_duration : private
|
||||
boost::less_than_comparable1< date_duration< duration_rep_traits >
|
||||
, boost::equality_comparable1< date_duration< duration_rep_traits >
|
||||
, boost::addable1< date_duration< duration_rep_traits >
|
||||
, boost::subtractable1< date_duration< duration_rep_traits >
|
||||
, boost::dividable2< date_duration< duration_rep_traits >, int
|
||||
> > > > >
|
||||
{
|
||||
public:
|
||||
typedef typename duration_rep_traits::int_type duration_rep_type;
|
||||
typedef typename duration_rep_traits::impl_type duration_rep;
|
||||
|
||||
//! Construct from a day count
|
||||
explicit date_duration(duration_rep days) : days_(days) {};
|
||||
duration_rep days() const
|
||||
BOOST_CXX14_CONSTEXPR explicit date_duration(duration_rep day_count) : days_(day_count) {}
|
||||
|
||||
/*! construct from special_values - only works when
|
||||
* instantiated with duration_traits_adapted */
|
||||
BOOST_CXX14_CONSTEXPR date_duration(special_values sv) :
|
||||
days_(duration_rep::from_special(sv))
|
||||
{}
|
||||
|
||||
//! returns days_ as it's instantiated type - used for streaming
|
||||
BOOST_CXX14_CONSTEXPR duration_rep get_rep()const
|
||||
{
|
||||
return days_;
|
||||
};
|
||||
return days_;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR special_values as_special() const
|
||||
{
|
||||
return days_.as_special();
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR bool is_special()const
|
||||
{
|
||||
return days_.is_special();
|
||||
}
|
||||
//! returns days as value, not object.
|
||||
BOOST_CXX14_CONSTEXPR duration_rep_type days() const
|
||||
{
|
||||
return duration_rep_traits::as_number(days_);
|
||||
}
|
||||
//! Returns the smallest duration -- used by to calculate 'end'
|
||||
static date_duration unit()
|
||||
static BOOST_CXX14_CONSTEXPR date_duration unit()
|
||||
{
|
||||
return date_duration<duration_rep>(1);
|
||||
return date_duration<duration_rep_traits>(1);
|
||||
}
|
||||
//! Equality
|
||||
bool operator==(const date_duration& rhs) const
|
||||
//! Equality
|
||||
BOOST_CXX14_CONSTEXPR bool operator==(const date_duration& rhs) const
|
||||
{
|
||||
return days_ == rhs.days_;
|
||||
return days_ == rhs.days_;
|
||||
}
|
||||
//! Less
|
||||
bool operator<(const date_duration& rhs) const
|
||||
//! Less
|
||||
BOOST_CXX14_CONSTEXPR bool operator<(const date_duration& rhs) const
|
||||
{
|
||||
return days_ < rhs.days_;
|
||||
return days_ < rhs.days_;
|
||||
}
|
||||
|
||||
/* For shortcut operators (+=, -=, etc) simply using
|
||||
* "days_ += days_" may not work. If instantiated with
|
||||
* an int_adapter, shortcut operators are not present,
|
||||
* so this will not compile */
|
||||
|
||||
//! Subtract another duration -- result is signed
|
||||
date_duration operator-(const date_duration& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR date_duration& operator-=(const date_duration& rhs)
|
||||
{
|
||||
return date_duration<duration_rep>(days_ - rhs.days_);
|
||||
//days_ -= rhs.days_;
|
||||
days_ = days_ - rhs.days_;
|
||||
return *this;
|
||||
}
|
||||
//! Add a duration -- result is signed
|
||||
date_duration operator+(const date_duration& rhs) const
|
||||
BOOST_CXX14_CONSTEXPR date_duration& operator+=(const date_duration& rhs)
|
||||
{
|
||||
return date_duration<duration_rep>(days_ + rhs.days_);
|
||||
days_ = days_ + rhs.days_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! unary- Allows for dd = -date_duration(2); -> dd == -2
|
||||
BOOST_CXX14_CONSTEXPR date_duration operator-() const
|
||||
{
|
||||
return date_duration<duration_rep_traits>(get_rep() * (-1));
|
||||
}
|
||||
//! Division operations on a duration with an integer.
|
||||
BOOST_CXX14_CONSTEXPR date_duration& operator/=(int divisor)
|
||||
{
|
||||
days_ = days_ / divisor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! return sign information
|
||||
bool is_negative() const
|
||||
BOOST_CXX14_CONSTEXPR bool is_negative() const
|
||||
{
|
||||
return days_ < 0;
|
||||
return days_ < 0;
|
||||
}
|
||||
|
||||
private:
|
||||
duration_rep days_;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/*! Struct for instantiating date_duration with <b>NO</b> special values
|
||||
* functionality. Allows for transparent implementation of either
|
||||
* date_duration<long> or date_duration<int_adapter<long> > */
|
||||
struct BOOST_SYMBOL_VISIBLE duration_traits_long
|
||||
{
|
||||
typedef long int_type;
|
||||
typedef long impl_type;
|
||||
static BOOST_CXX14_CONSTEXPR int_type as_number(impl_type i) { return i; }
|
||||
};
|
||||
|
||||
/*! Struct for instantiating date_duration <b>WITH</b> special values
|
||||
* functionality. Allows for transparent implementation of either
|
||||
* date_duration<long> or date_duration<int_adapter<long> > */
|
||||
struct BOOST_SYMBOL_VISIBLE duration_traits_adapted
|
||||
{
|
||||
typedef long int_type;
|
||||
typedef boost::date_time::int_adapter<long> impl_type;
|
||||
static BOOST_CXX14_CONSTEXPR int_type as_number(impl_type i) { return i.as_number(); }
|
||||
};
|
||||
|
||||
|
||||
} } //namspace date_time
|
||||
|
||||
/* Copyright (c) 2000, 2001
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
#ifndef DATE_DURATION_TYPES_HPP___
|
||||
#define DATE_DURATION_TYPES_HPP___
|
||||
|
||||
/* Copyright (c) 2004 CrystalClear Software, Inc.
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/int_adapter.hpp>
|
||||
#include <boost/date_time/special_defs.hpp>
|
||||
#include <boost/date_time/date_duration.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
|
||||
//! Additional duration type that represents a number of n*7 days
|
||||
template <class duration_config>
|
||||
class BOOST_SYMBOL_VISIBLE weeks_duration : public date_duration<duration_config> {
|
||||
public:
|
||||
BOOST_CXX14_CONSTEXPR weeks_duration(typename duration_config::impl_type w)
|
||||
: date_duration<duration_config>(w * 7) {}
|
||||
BOOST_CXX14_CONSTEXPR weeks_duration(special_values sv)
|
||||
: date_duration<duration_config>(sv) {}
|
||||
};
|
||||
|
||||
// predeclare
|
||||
template<class t>
|
||||
class BOOST_SYMBOL_VISIBLE years_duration;
|
||||
|
||||
//! additional duration type that represents a logical month
|
||||
/*! A logical month enables things like: "date(2002,Mar,2) + months(2) ->
|
||||
* 2002-May2". If the date is a last day-of-the-month, the result will
|
||||
* also be a last-day-of-the-month.
|
||||
*/
|
||||
template<class base_config>
|
||||
class BOOST_SYMBOL_VISIBLE months_duration
|
||||
{
|
||||
private:
|
||||
typedef typename base_config::int_rep int_rep;
|
||||
typedef typename int_rep::int_type int_type;
|
||||
typedef typename base_config::date_type date_type;
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
typedef typename base_config::month_adjustor_type month_adjustor_type;
|
||||
typedef months_duration<base_config> months_type;
|
||||
typedef years_duration<base_config> years_type;
|
||||
public:
|
||||
BOOST_CXX14_CONSTEXPR months_duration(int_rep num) : _m(num) {}
|
||||
BOOST_CXX14_CONSTEXPR months_duration(special_values sv) : _m(sv)
|
||||
{
|
||||
_m = int_rep::from_special(sv);
|
||||
}
|
||||
int_rep number_of_months() const { return _m; }
|
||||
//! returns a negative duration
|
||||
BOOST_CXX14_CONSTEXPR duration_type get_neg_offset(const date_type& d) const
|
||||
{
|
||||
month_adjustor_type m_adj(_m.as_number());
|
||||
return duration_type(m_adj.get_neg_offset(d));
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR duration_type get_offset(const date_type& d) const
|
||||
{
|
||||
month_adjustor_type m_adj(_m.as_number());
|
||||
return duration_type(m_adj.get_offset(d));
|
||||
}
|
||||
BOOST_CONSTEXPR bool operator==(const months_type& rhs) const
|
||||
{
|
||||
return(_m == rhs._m);
|
||||
}
|
||||
BOOST_CONSTEXPR bool operator!=(const months_type& rhs) const
|
||||
{
|
||||
return(_m != rhs._m);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type operator+(const months_type& rhs)const
|
||||
{
|
||||
return months_type(_m + rhs._m);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator+=(const months_type& rhs)
|
||||
{
|
||||
_m = _m + rhs._m;
|
||||
return *this;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type operator-(const months_type& rhs)const
|
||||
{
|
||||
return months_type(_m - rhs._m);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator-=(const months_type& rhs)
|
||||
{
|
||||
_m = _m - rhs._m;
|
||||
return *this;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type operator*(const int_type rhs)const
|
||||
{
|
||||
return months_type(_m * rhs);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator*=(const int_type rhs)
|
||||
{
|
||||
_m = _m * rhs;
|
||||
return *this;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type operator/(const int_type rhs)const
|
||||
{
|
||||
return months_type(_m / rhs);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator/=(const int_type rhs)
|
||||
{
|
||||
_m = _m / rhs;
|
||||
return *this;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type operator+(const years_type& y)const
|
||||
{
|
||||
return months_type(y.number_of_years() * 12 + _m);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator+=(const years_type& y)
|
||||
{
|
||||
_m = y.number_of_years() * 12 + _m;
|
||||
return *this;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type operator-(const years_type& y) const
|
||||
{
|
||||
return months_type(_m - y.number_of_years() * 12);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type& operator-=(const years_type& y)
|
||||
{
|
||||
_m = _m - y.number_of_years() * 12;
|
||||
return *this;
|
||||
}
|
||||
//
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator+(const date_type& d, const months_type& m)
|
||||
{
|
||||
return d + m.get_offset(d);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator+=(date_type& d, const months_type& m)
|
||||
{
|
||||
return d += m.get_offset(d);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator-(const date_type& d, const months_type& m)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return d + m.get_neg_offset(d);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator-=(date_type& d, const months_type& m)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return d += m.get_neg_offset(d);
|
||||
}
|
||||
private:
|
||||
int_rep _m;
|
||||
};
|
||||
|
||||
//! additional duration type that represents a logical year
|
||||
/*! A logical year enables things like: "date(2002,Mar,2) + years(2) ->
|
||||
* 2004-Mar-2". If the date is a last day-of-the-month, the result will
|
||||
* also be a last-day-of-the-month (ie date(2001-Feb-28) + years(3) ->
|
||||
* 2004-Feb-29).
|
||||
*/
|
||||
template<class base_config>
|
||||
class BOOST_SYMBOL_VISIBLE years_duration
|
||||
{
|
||||
private:
|
||||
typedef typename base_config::int_rep int_rep;
|
||||
typedef typename int_rep::int_type int_type;
|
||||
typedef typename base_config::date_type date_type;
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
typedef typename base_config::month_adjustor_type month_adjustor_type;
|
||||
typedef years_duration<base_config> years_type;
|
||||
typedef months_duration<base_config> months_type;
|
||||
public:
|
||||
BOOST_CXX14_CONSTEXPR years_duration(int_rep num) : _y(num) {}
|
||||
BOOST_CXX14_CONSTEXPR years_duration(special_values sv) : _y(sv)
|
||||
{
|
||||
_y = int_rep::from_special(sv);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR int_rep number_of_years() const { return _y; }
|
||||
//! returns a negative duration
|
||||
BOOST_CXX14_CONSTEXPR duration_type get_neg_offset(const date_type& d) const
|
||||
{
|
||||
month_adjustor_type m_adj(_y.as_number() * 12);
|
||||
return duration_type(m_adj.get_neg_offset(d));
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR duration_type get_offset(const date_type& d) const
|
||||
{
|
||||
month_adjustor_type m_adj(_y.as_number() * 12);
|
||||
return duration_type(m_adj.get_offset(d));
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR bool operator==(const years_type& rhs) const
|
||||
{
|
||||
return(_y == rhs._y);
|
||||
}
|
||||
bool operator!=(const years_type& rhs) const
|
||||
{
|
||||
return(_y != rhs._y);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR years_type operator+(const years_type& rhs)const
|
||||
{
|
||||
return years_type(_y + rhs._y);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR years_type& operator+=(const years_type& rhs)
|
||||
{
|
||||
_y = _y + rhs._y;
|
||||
return *this;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR years_type operator-(const years_type& rhs)const
|
||||
{
|
||||
return years_type(_y - rhs._y);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR years_type& operator-=(const years_type& rhs)
|
||||
{
|
||||
_y = _y - rhs._y;
|
||||
return *this;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR years_type operator*(const int_type rhs)const
|
||||
{
|
||||
return years_type(_y * rhs);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR years_type& operator*=(const int_type rhs)
|
||||
{
|
||||
_y = _y * rhs;
|
||||
return *this;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR years_type operator/(const int_type rhs)const
|
||||
{
|
||||
return years_type(_y / rhs);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR years_type& operator/=(const int_type rhs)
|
||||
{
|
||||
_y = _y / rhs;
|
||||
return *this;
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type operator+(const months_type& m) const
|
||||
{
|
||||
return(months_type(_y * 12 + m.number_of_months()));
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR months_type operator-(const months_type& m) const
|
||||
{
|
||||
return(months_type(_y * 12 - m.number_of_months()));
|
||||
}
|
||||
//
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator+(const date_type& d, const years_type& y)
|
||||
{
|
||||
return d + y.get_offset(d);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator+=(date_type& d, const years_type& y)
|
||||
{
|
||||
return d += y.get_offset(d);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator-(const date_type& d, const years_type& y)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return d + y.get_neg_offset(d);
|
||||
}
|
||||
BOOST_CXX14_CONSTEXPR friend date_type operator-=(date_type& d, const years_type& y)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return d += y.get_neg_offset(d);
|
||||
}
|
||||
private:
|
||||
int_rep _y;
|
||||
};
|
||||
}} // namespace boost::date_time
|
||||
|
||||
#endif // DATE_DURATION_TYPES_HPP___
|
||||
@@ -0,0 +1,766 @@
|
||||
#ifndef _DATE_TIME_DATE_FACET__HPP___
|
||||
#define _DATE_TIME_DATE_FACET__HPP___
|
||||
|
||||
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Martin Andrian, Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <iterator> // ostreambuf_iterator
|
||||
#include <locale>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/period.hpp>
|
||||
#include <boost/date_time/special_defs.hpp>
|
||||
#include <boost/date_time/special_values_formatter.hpp>
|
||||
#include <boost/date_time/period_formatter.hpp>
|
||||
#include <boost/date_time/period_parser.hpp>
|
||||
#include <boost/date_time/date_generator_formatter.hpp>
|
||||
#include <boost/date_time/date_generator_parser.hpp>
|
||||
#include <boost/date_time/format_date_parser.hpp>
|
||||
|
||||
namespace boost { namespace date_time {
|
||||
|
||||
|
||||
/*! Class that provides format based I/O facet for date types.
|
||||
*
|
||||
* This class allows the formatting of dates by using format string.
|
||||
* Format strings are:
|
||||
*
|
||||
* - %A => long_weekday_format - Full name Ex: Tuesday
|
||||
* - %a => short_weekday_format - Three letter abbreviation Ex: Tue
|
||||
* - %B => long_month_format - Full name Ex: October
|
||||
* - %b => short_month_format - Three letter abbreviation Ex: Oct
|
||||
* - %x => standard_format_specifier - defined by the locale
|
||||
* - %Y-%b-%d => default_date_format - YYYY-Mon-dd
|
||||
*
|
||||
* Default month format == %b
|
||||
* Default weekday format == %a
|
||||
*/
|
||||
template <class date_type,
|
||||
class CharT,
|
||||
class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
|
||||
class BOOST_SYMBOL_VISIBLE date_facet : public std::locale::facet {
|
||||
public:
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
// greg_weekday is gregorian_calendar::day_of_week_type
|
||||
typedef typename date_type::day_of_week_type day_of_week_type;
|
||||
typedef typename date_type::day_type day_type;
|
||||
typedef typename date_type::month_type month_type;
|
||||
typedef boost::date_time::period<date_type,duration_type> period_type;
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef CharT char_type;
|
||||
typedef boost::date_time::period_formatter<CharT> period_formatter_type;
|
||||
typedef boost::date_time::special_values_formatter<CharT> special_values_formatter_type;
|
||||
typedef std::vector<std::basic_string<CharT> > input_collection_type;
|
||||
// used for the output of the date_generators
|
||||
typedef date_generator_formatter<date_type, CharT> date_gen_formatter_type;
|
||||
typedef partial_date<date_type> partial_date_type;
|
||||
typedef nth_kday_of_month<date_type> nth_kday_type;
|
||||
typedef first_kday_of_month<date_type> first_kday_type;
|
||||
typedef last_kday_of_month<date_type> last_kday_type;
|
||||
typedef first_kday_after<date_type> kday_after_type;
|
||||
typedef first_kday_before<date_type> kday_before_type;
|
||||
static const char_type long_weekday_format[3];
|
||||
static const char_type short_weekday_format[3];
|
||||
static const char_type long_month_format[3];
|
||||
static const char_type short_month_format[3];
|
||||
static const char_type default_period_separator[4];
|
||||
static const char_type standard_format_specifier[3];
|
||||
static const char_type iso_format_specifier[7];
|
||||
static const char_type iso_format_extended_specifier[9];
|
||||
static const char_type default_date_format[9]; // YYYY-Mon-DD
|
||||
static std::locale::id id;
|
||||
|
||||
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
|
||||
std::locale::id& __get_id (void) const { return id; }
|
||||
#endif
|
||||
|
||||
explicit date_facet(::size_t a_ref = 0)
|
||||
: std::locale::facet(a_ref),
|
||||
//m_format(standard_format_specifier)
|
||||
m_format(default_date_format),
|
||||
m_month_format(short_month_format),
|
||||
m_weekday_format(short_weekday_format)
|
||||
{}
|
||||
|
||||
explicit date_facet(const char_type* format_str,
|
||||
const input_collection_type& short_names,
|
||||
::size_t ref_count = 0)
|
||||
: std::locale::facet(ref_count),
|
||||
m_format(format_str),
|
||||
m_month_format(short_month_format),
|
||||
m_weekday_format(short_weekday_format),
|
||||
m_month_short_names(short_names)
|
||||
{}
|
||||
|
||||
|
||||
explicit date_facet(const char_type* format_str,
|
||||
period_formatter_type per_formatter = period_formatter_type(),
|
||||
special_values_formatter_type sv_formatter = special_values_formatter_type(),
|
||||
date_gen_formatter_type dg_formatter = date_gen_formatter_type(),
|
||||
::size_t ref_count = 0)
|
||||
: std::locale::facet(ref_count),
|
||||
m_format(format_str),
|
||||
m_month_format(short_month_format),
|
||||
m_weekday_format(short_weekday_format),
|
||||
m_period_formatter(per_formatter),
|
||||
m_date_gen_formatter(dg_formatter),
|
||||
m_special_values_formatter(sv_formatter)
|
||||
{}
|
||||
void format(const char_type* const format_str) {
|
||||
m_format = format_str;
|
||||
}
|
||||
virtual void set_iso_format()
|
||||
{
|
||||
m_format = iso_format_specifier;
|
||||
}
|
||||
virtual void set_iso_extended_format()
|
||||
{
|
||||
m_format = iso_format_extended_specifier;
|
||||
}
|
||||
void month_format(const char_type* const format_str) {
|
||||
m_month_format = format_str;
|
||||
}
|
||||
void weekday_format(const char_type* const format_str) {
|
||||
m_weekday_format = format_str;
|
||||
}
|
||||
|
||||
void period_formatter(period_formatter_type per_formatter) {
|
||||
m_period_formatter= per_formatter;
|
||||
}
|
||||
void special_values_formatter(const special_values_formatter_type& svf)
|
||||
{
|
||||
m_special_values_formatter = svf;
|
||||
}
|
||||
void short_weekday_names(const input_collection_type& short_names)
|
||||
{
|
||||
m_weekday_short_names = short_names;
|
||||
}
|
||||
void long_weekday_names(const input_collection_type& long_names)
|
||||
{
|
||||
m_weekday_long_names = long_names;
|
||||
}
|
||||
|
||||
void short_month_names(const input_collection_type& short_names)
|
||||
{
|
||||
m_month_short_names = short_names;
|
||||
}
|
||||
|
||||
void long_month_names(const input_collection_type& long_names)
|
||||
{
|
||||
m_month_long_names = long_names;
|
||||
}
|
||||
|
||||
void date_gen_phrase_strings(const input_collection_type& new_strings,
|
||||
typename date_gen_formatter_type::phrase_elements beg_pos=date_gen_formatter_type::first)
|
||||
{
|
||||
m_date_gen_formatter.elements(new_strings, beg_pos);
|
||||
}
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const date_type& d) const
|
||||
{
|
||||
if (d.is_special()) {
|
||||
return do_put_special(next, a_ios, fill_char, d.as_special());
|
||||
}
|
||||
//The following line of code required the date to support a to_tm function
|
||||
return do_put_tm(next, a_ios, fill_char, to_tm(d), m_format);
|
||||
}
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const duration_type& dd) const
|
||||
{
|
||||
if (dd.is_special()) {
|
||||
return do_put_special(next, a_ios, fill_char, dd.get_rep().as_special());
|
||||
}
|
||||
|
||||
typedef std::num_put<CharT, OutItrT> num_put;
|
||||
if (std::has_facet<num_put>(a_ios.getloc())) {
|
||||
return std::use_facet<num_put>(a_ios.getloc()).put(next, a_ios, fill_char, dd.get_rep().as_number());
|
||||
}
|
||||
else {
|
||||
num_put* f = new num_put();
|
||||
std::locale l = std::locale(a_ios.getloc(), f);
|
||||
a_ios.imbue(l);
|
||||
return f->put(next, a_ios, fill_char, dd.get_rep().as_number());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const month_type& m) const
|
||||
{
|
||||
//if (d.is_special()) {
|
||||
// return do_put_special(next, a_ios, fill_char, d.as_special());
|
||||
//}
|
||||
//The following line of code required the date to support a to_tm function
|
||||
std::tm dtm;
|
||||
std::memset(&dtm, 0, sizeof(dtm));
|
||||
dtm.tm_mon = m - 1;
|
||||
return do_put_tm(next, a_ios, fill_char, dtm, m_month_format);
|
||||
}
|
||||
|
||||
//! puts the day of month
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const day_type& day) const
|
||||
{
|
||||
std::tm dtm;
|
||||
std::memset(&dtm, 0, sizeof(dtm));
|
||||
dtm.tm_mday = day.as_number();
|
||||
char_type tmp[3] = {'%','d'};
|
||||
string_type temp_format(tmp);
|
||||
return do_put_tm(next, a_ios, fill_char, dtm, temp_format);
|
||||
}
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const day_of_week_type& dow) const
|
||||
{
|
||||
//if (d.is_special()) {
|
||||
// return do_put_special(next, a_ios, fill_char, d.as_special());
|
||||
//}
|
||||
//The following line of code required the date to support a to_tm function
|
||||
std::tm dtm;
|
||||
std::memset(&dtm, 0, sizeof(dtm));
|
||||
dtm.tm_wday = dow;
|
||||
return do_put_tm(next, a_ios, fill_char, dtm, m_weekday_format);
|
||||
}
|
||||
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const period_type& p) const
|
||||
{
|
||||
return m_period_formatter.put_period(next, a_ios, fill_char, p, *this);
|
||||
}
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const partial_date_type& pd) const
|
||||
{
|
||||
return m_date_gen_formatter.put_partial_date(next, a_ios, fill_char, pd, *this);
|
||||
}
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const nth_kday_type& nkd) const
|
||||
{
|
||||
return m_date_gen_formatter.put_nth_kday(next, a_ios, fill_char, nkd, *this);
|
||||
}
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const first_kday_type& fkd) const
|
||||
{
|
||||
return m_date_gen_formatter.put_first_kday(next, a_ios, fill_char, fkd, *this);
|
||||
}
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const last_kday_type& lkd) const
|
||||
{
|
||||
return m_date_gen_formatter.put_last_kday(next, a_ios, fill_char, lkd, *this);
|
||||
}
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const kday_before_type& fkb) const
|
||||
{
|
||||
return m_date_gen_formatter.put_kday_before(next, a_ios, fill_char, fkb, *this);
|
||||
}
|
||||
|
||||
OutItrT put(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const kday_after_type& fka) const
|
||||
{
|
||||
return m_date_gen_formatter.put_kday_after(next, a_ios, fill_char, fka, *this);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual OutItrT do_put_special(OutItrT next,
|
||||
std::ios_base& /*a_ios*/,
|
||||
char_type /*fill_char*/,
|
||||
const boost::date_time::special_values sv) const
|
||||
{
|
||||
m_special_values_formatter.put_special(next, sv);
|
||||
return next;
|
||||
}
|
||||
virtual OutItrT do_put_tm(OutItrT next,
|
||||
std::ios_base& a_ios,
|
||||
char_type fill_char,
|
||||
const tm& tm_value,
|
||||
string_type a_format) const
|
||||
{
|
||||
// update format string with custom names
|
||||
if (!m_weekday_long_names.empty()) {
|
||||
boost::algorithm::replace_all(a_format,
|
||||
long_weekday_format,
|
||||
m_weekday_long_names[tm_value.tm_wday]);
|
||||
}
|
||||
if (!m_weekday_short_names.empty()) {
|
||||
boost::algorithm::replace_all(a_format,
|
||||
short_weekday_format,
|
||||
m_weekday_short_names[tm_value.tm_wday]);
|
||||
|
||||
}
|
||||
if (!m_month_long_names.empty()) {
|
||||
boost::algorithm::replace_all(a_format,
|
||||
long_month_format,
|
||||
m_month_long_names[tm_value.tm_mon]);
|
||||
}
|
||||
if (!m_month_short_names.empty()) {
|
||||
boost::algorithm::replace_all(a_format,
|
||||
short_month_format,
|
||||
m_month_short_names[tm_value.tm_mon]);
|
||||
}
|
||||
// use time_put facet to create final string
|
||||
const char_type* p_format = a_format.c_str();
|
||||
return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios,
|
||||
fill_char,
|
||||
&tm_value,
|
||||
p_format,
|
||||
p_format + a_format.size());
|
||||
}
|
||||
protected:
|
||||
string_type m_format;
|
||||
string_type m_month_format;
|
||||
string_type m_weekday_format;
|
||||
period_formatter_type m_period_formatter;
|
||||
date_gen_formatter_type m_date_gen_formatter;
|
||||
special_values_formatter_type m_special_values_formatter;
|
||||
input_collection_type m_month_short_names;
|
||||
input_collection_type m_month_long_names;
|
||||
input_collection_type m_weekday_short_names;
|
||||
input_collection_type m_weekday_long_names;
|
||||
private:
|
||||
};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
std::locale::id date_facet<date_type, CharT, OutItrT>::id;
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_facet<date_type, CharT, OutItrT>::long_weekday_format[3] = {'%','A'};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_facet<date_type, CharT, OutItrT>::short_weekday_format[3] = {'%','a'};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_facet<date_type, CharT, OutItrT>::long_month_format[3] = {'%','B'};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_facet<date_type, CharT, OutItrT>::short_month_format[3] = {'%','b'};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_facet<date_type, CharT, OutItrT>::default_period_separator[4] = { ' ', '/', ' '};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
|
||||
{'%', 'x' };
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
|
||||
{'%', 'Y', '%', 'm', '%', 'd' };
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
|
||||
{'%', 'Y', '-', '%', 'm', '-', '%', 'd' };
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_facet<date_type, CharT, OutItrT>::default_date_format[9] =
|
||||
{'%','Y','-','%','b','-','%','d'};
|
||||
|
||||
|
||||
|
||||
//! Input facet
|
||||
template <class date_type,
|
||||
class CharT,
|
||||
class InItrT = std::istreambuf_iterator<CharT, std::char_traits<CharT> > >
|
||||
class BOOST_SYMBOL_VISIBLE date_input_facet : public std::locale::facet {
|
||||
public:
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
// greg_weekday is gregorian_calendar::day_of_week_type
|
||||
typedef typename date_type::day_of_week_type day_of_week_type;
|
||||
typedef typename date_type::day_type day_type;
|
||||
typedef typename date_type::month_type month_type;
|
||||
typedef typename date_type::year_type year_type;
|
||||
typedef boost::date_time::period<date_type,duration_type> period_type;
|
||||
typedef std::basic_string<CharT> string_type;
|
||||
typedef CharT char_type;
|
||||
typedef boost::date_time::period_parser<date_type, CharT> period_parser_type;
|
||||
typedef boost::date_time::special_values_parser<date_type,CharT> special_values_parser_type;
|
||||
typedef std::vector<std::basic_string<CharT> > input_collection_type;
|
||||
typedef format_date_parser<date_type, CharT> format_date_parser_type;
|
||||
// date_generators stuff goes here
|
||||
typedef date_generator_parser<date_type, CharT> date_gen_parser_type;
|
||||
typedef partial_date<date_type> partial_date_type;
|
||||
typedef nth_kday_of_month<date_type> nth_kday_type;
|
||||
typedef first_kday_of_month<date_type> first_kday_type;
|
||||
typedef last_kday_of_month<date_type> last_kday_type;
|
||||
typedef first_kday_after<date_type> kday_after_type;
|
||||
typedef first_kday_before<date_type> kday_before_type;
|
||||
|
||||
static const char_type long_weekday_format[3];
|
||||
static const char_type short_weekday_format[3];
|
||||
static const char_type long_month_format[3];
|
||||
static const char_type short_month_format[3];
|
||||
static const char_type four_digit_year_format[3];
|
||||
static const char_type two_digit_year_format[3];
|
||||
static const char_type default_period_separator[4];
|
||||
static const char_type standard_format_specifier[3];
|
||||
static const char_type iso_format_specifier[7];
|
||||
static const char_type iso_format_extended_specifier[9];
|
||||
static const char_type default_date_format[9]; // YYYY-Mon-DD
|
||||
static std::locale::id id;
|
||||
|
||||
explicit date_input_facet(::size_t a_ref = 0)
|
||||
: std::locale::facet(a_ref),
|
||||
m_format(default_date_format),
|
||||
m_month_format(short_month_format),
|
||||
m_weekday_format(short_weekday_format),
|
||||
m_year_format(four_digit_year_format),
|
||||
m_parser(m_format, std::locale::classic())
|
||||
// default period_parser & special_values_parser used
|
||||
{}
|
||||
|
||||
explicit date_input_facet(const string_type& format_str,
|
||||
::size_t a_ref = 0)
|
||||
: std::locale::facet(a_ref),
|
||||
m_format(format_str),
|
||||
m_month_format(short_month_format),
|
||||
m_weekday_format(short_weekday_format),
|
||||
m_year_format(four_digit_year_format),
|
||||
m_parser(m_format, std::locale::classic())
|
||||
// default period_parser & special_values_parser used
|
||||
{}
|
||||
|
||||
explicit date_input_facet(const string_type& format_str,
|
||||
const format_date_parser_type& date_parser,
|
||||
const special_values_parser_type& sv_parser,
|
||||
const period_parser_type& per_parser,
|
||||
const date_gen_parser_type& date_gen_parser,
|
||||
::size_t ref_count = 0)
|
||||
: std::locale::facet(ref_count),
|
||||
m_format(format_str),
|
||||
m_month_format(short_month_format),
|
||||
m_weekday_format(short_weekday_format),
|
||||
m_year_format(four_digit_year_format),
|
||||
m_parser(date_parser),
|
||||
m_date_gen_parser(date_gen_parser),
|
||||
m_period_parser(per_parser),
|
||||
m_sv_parser(sv_parser)
|
||||
{}
|
||||
|
||||
|
||||
void format(const char_type* const format_str) {
|
||||
m_format = format_str;
|
||||
}
|
||||
virtual void set_iso_format()
|
||||
{
|
||||
m_format = iso_format_specifier;
|
||||
}
|
||||
virtual void set_iso_extended_format()
|
||||
{
|
||||
m_format = iso_format_extended_specifier;
|
||||
}
|
||||
void month_format(const char_type* const format_str) {
|
||||
m_month_format = format_str;
|
||||
}
|
||||
void weekday_format(const char_type* const format_str) {
|
||||
m_weekday_format = format_str;
|
||||
}
|
||||
void year_format(const char_type* const format_str) {
|
||||
m_year_format = format_str;
|
||||
}
|
||||
|
||||
void period_parser(period_parser_type per_parser) {
|
||||
m_period_parser = per_parser;
|
||||
}
|
||||
void short_weekday_names(const input_collection_type& weekday_names)
|
||||
{
|
||||
m_parser.short_weekday_names(weekday_names);
|
||||
}
|
||||
void long_weekday_names(const input_collection_type& weekday_names)
|
||||
{
|
||||
m_parser.long_weekday_names(weekday_names);
|
||||
}
|
||||
|
||||
void short_month_names(const input_collection_type& month_names)
|
||||
{
|
||||
m_parser.short_month_names(month_names);
|
||||
}
|
||||
|
||||
void long_month_names(const input_collection_type& month_names)
|
||||
{
|
||||
m_parser.long_month_names(month_names);
|
||||
}
|
||||
|
||||
void date_gen_element_strings(const input_collection_type& col)
|
||||
{
|
||||
m_date_gen_parser.element_strings(col);
|
||||
}
|
||||
void date_gen_element_strings(const string_type& first,
|
||||
const string_type& second,
|
||||
const string_type& third,
|
||||
const string_type& fourth,
|
||||
const string_type& fifth,
|
||||
const string_type& last,
|
||||
const string_type& before,
|
||||
const string_type& after,
|
||||
const string_type& of)
|
||||
|
||||
{
|
||||
m_date_gen_parser.element_strings(first,second,third,fourth,fifth,last,before,after,of);
|
||||
}
|
||||
|
||||
void special_values_parser(special_values_parser_type sv_parser)
|
||||
{
|
||||
m_sv_parser = sv_parser;
|
||||
}
|
||||
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& /*a_ios*/,
|
||||
date_type& d) const
|
||||
{
|
||||
d = m_parser.parse_date(from, to, m_format, m_sv_parser);
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& /*a_ios*/,
|
||||
month_type& m) const
|
||||
{
|
||||
m = m_parser.parse_month(from, to, m_month_format);
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& /*a_ios*/,
|
||||
day_of_week_type& wd) const
|
||||
{
|
||||
wd = m_parser.parse_weekday(from, to, m_weekday_format);
|
||||
return from;
|
||||
}
|
||||
//! Expects 1 or 2 digit day range: 1-31
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& /*a_ios*/,
|
||||
day_type& d) const
|
||||
{
|
||||
d = m_parser.parse_var_day_of_month(from, to);
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& /*a_ios*/,
|
||||
year_type& y) const
|
||||
{
|
||||
y = m_parser.parse_year(from, to, m_year_format);
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& a_ios,
|
||||
duration_type& dd) const
|
||||
{
|
||||
// skip leading whitespace
|
||||
while(std::isspace(*from) && from != to) { ++from; }
|
||||
|
||||
/* num_get.get() will always consume the first character if it
|
||||
* is a sign indicator (+/-). Special value strings may begin
|
||||
* with one of these signs so we'll need a copy of it
|
||||
* in case num_get.get() fails. */
|
||||
char_type c = '\0';
|
||||
// TODO Are these characters somewhere in the locale?
|
||||
if(*from == '-' || *from == '+') {
|
||||
c = *from;
|
||||
}
|
||||
typedef std::num_get<CharT, InItrT> num_get;
|
||||
typename duration_type::duration_rep_type val = 0;
|
||||
std::ios_base::iostate err = std::ios_base::goodbit;
|
||||
|
||||
if (std::has_facet<num_get>(a_ios.getloc())) {
|
||||
from = std::use_facet<num_get>(a_ios.getloc()).get(from, to, a_ios, err, val);
|
||||
}
|
||||
else {
|
||||
num_get* ng = new num_get();
|
||||
std::locale l = std::locale(a_ios.getloc(), ng);
|
||||
a_ios.imbue(l);
|
||||
from = ng->get(from, to, a_ios, err, val);
|
||||
}
|
||||
if(err & std::ios_base::failbit){
|
||||
typedef typename special_values_parser_type::match_results match_results;
|
||||
match_results mr;
|
||||
if(c == '-' || c == '+') { // was the first character consumed?
|
||||
mr.cache += c;
|
||||
}
|
||||
m_sv_parser.match(from, to, mr);
|
||||
if(mr.current_match == match_results::PARSE_ERROR) {
|
||||
boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
|
||||
BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return from); // should never reach
|
||||
}
|
||||
dd = duration_type(static_cast<special_values>(mr.current_match));
|
||||
}
|
||||
else {
|
||||
dd = duration_type(val);
|
||||
}
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& a_ios,
|
||||
period_type& p) const
|
||||
{
|
||||
p = m_period_parser.get_period(from, to, a_ios, p, duration_type::unit(), *this);
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& a_ios,
|
||||
nth_kday_type& nkd) const
|
||||
{
|
||||
nkd = m_date_gen_parser.get_nth_kday_type(from, to, a_ios, *this);
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& a_ios,
|
||||
partial_date_type& pd) const
|
||||
{
|
||||
|
||||
pd = m_date_gen_parser.get_partial_date_type(from, to, a_ios, *this);
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& a_ios,
|
||||
first_kday_type& fkd) const
|
||||
{
|
||||
fkd = m_date_gen_parser.get_first_kday_type(from, to, a_ios, *this);
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& a_ios,
|
||||
last_kday_type& lkd) const
|
||||
{
|
||||
lkd = m_date_gen_parser.get_last_kday_type(from, to, a_ios, *this);
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& a_ios,
|
||||
kday_before_type& fkb) const
|
||||
{
|
||||
fkb = m_date_gen_parser.get_kday_before_type(from, to, a_ios, *this);
|
||||
return from;
|
||||
}
|
||||
InItrT get(InItrT& from,
|
||||
InItrT& to,
|
||||
std::ios_base& a_ios,
|
||||
kday_after_type& fka) const
|
||||
{
|
||||
fka = m_date_gen_parser.get_kday_after_type(from, to, a_ios, *this);
|
||||
return from;
|
||||
}
|
||||
|
||||
protected:
|
||||
string_type m_format;
|
||||
string_type m_month_format;
|
||||
string_type m_weekday_format;
|
||||
string_type m_year_format;
|
||||
format_date_parser_type m_parser;
|
||||
date_gen_parser_type m_date_gen_parser;
|
||||
period_parser_type m_period_parser;
|
||||
special_values_parser_type m_sv_parser;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
std::locale::id date_input_facet<date_type, CharT, OutItrT>::id;
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::long_weekday_format[3] = {'%','A'};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::short_weekday_format[3] = {'%','a'};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::long_month_format[3] = {'%','B'};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::short_month_format[3] = {'%','b'};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::four_digit_year_format[3] = {'%','Y'};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::two_digit_year_format[3] = {'%','y'};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::default_period_separator[4] = { ' ', '/', ' '};
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
|
||||
{'%', 'x' };
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
|
||||
{'%', 'Y', '%', 'm', '%', 'd' };
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
|
||||
{'%', 'Y', '-', '%', 'm', '-', '%', 'd' };
|
||||
|
||||
template <class date_type, class CharT, class OutItrT>
|
||||
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
|
||||
date_input_facet<date_type, CharT, OutItrT>::default_date_format[9] =
|
||||
{'%','Y','-','%','b','-','%','d'};
|
||||
|
||||
} } // namespaces
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,12 @@
|
||||
#ifndef DATE_TIME_SIMPLE_FORMAT_HPP___
|
||||
#define DATE_TIME_SIMPLE_FORMAT_HPP___
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include "boost/date_time/parse_format_base.hpp"
|
||||
@@ -11,23 +15,24 @@ namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
//! Class to provide simple basic formatting rules
|
||||
template<class charT>
|
||||
class simple_format {
|
||||
public:
|
||||
|
||||
//! String used printed is date is invalid
|
||||
static const char* not_a_date()
|
||||
static const charT* not_a_date()
|
||||
{
|
||||
return "not-a-date";
|
||||
return "not-a-date-time";
|
||||
}
|
||||
//! String used to for positive infinity value
|
||||
static const char* pos_infinity()
|
||||
{ //2001-Jan-03
|
||||
return "+infinity ";
|
||||
static const charT* pos_infinity()
|
||||
{
|
||||
return "+infinity";
|
||||
}
|
||||
//! String used to for positive infinity value
|
||||
static const char* neg_infinity()
|
||||
static const charT* neg_infinity()
|
||||
{
|
||||
return "-infinity ";
|
||||
return "-infinity";
|
||||
}
|
||||
//! Describe month format
|
||||
static month_format_spec month_format()
|
||||
@@ -44,51 +49,110 @@ public:
|
||||
return true;
|
||||
}
|
||||
//! Char to sep?
|
||||
static char year_sep_char()
|
||||
static charT year_sep_char()
|
||||
{
|
||||
return '-';
|
||||
}
|
||||
//! char between year-month
|
||||
static char month_sep_char()
|
||||
static charT month_sep_char()
|
||||
{
|
||||
return '-';
|
||||
}
|
||||
//! Char to separate month-day
|
||||
static char day_sep_char()
|
||||
static charT day_sep_char()
|
||||
{
|
||||
return '-';
|
||||
}
|
||||
//! char between date-hours
|
||||
static char hour_sep_char()
|
||||
static charT hour_sep_char()
|
||||
{
|
||||
return ' ';
|
||||
}
|
||||
//! char between hour and minute
|
||||
static char minute_sep_char()
|
||||
static charT minute_sep_char()
|
||||
{
|
||||
return ':';
|
||||
}
|
||||
//! char for second
|
||||
static char second_sep_char()
|
||||
static charT second_sep_char()
|
||||
{
|
||||
return ':';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
|
||||
//! Specialization of formmating rules for wchar_t
|
||||
template<>
|
||||
class simple_format<wchar_t> {
|
||||
public:
|
||||
|
||||
//! String used printed is date is invalid
|
||||
static const wchar_t* not_a_date()
|
||||
{
|
||||
return L"not-a-date-time";
|
||||
}
|
||||
//! String used to for positive infinity value
|
||||
static const wchar_t* pos_infinity()
|
||||
{
|
||||
return L"+infinity";
|
||||
}
|
||||
//! String used to for positive infinity value
|
||||
static const wchar_t* neg_infinity()
|
||||
{
|
||||
return L"-infinity";
|
||||
}
|
||||
//! Describe month format
|
||||
static month_format_spec month_format()
|
||||
{
|
||||
return month_as_short_string;
|
||||
}
|
||||
static ymd_order_spec date_order()
|
||||
{
|
||||
return ymd_order_iso; //YYYY-MM-DD
|
||||
}
|
||||
//! This format uses '-' to separate date elements
|
||||
static bool has_date_sep_chars()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//! Char to sep?
|
||||
static wchar_t year_sep_char()
|
||||
{
|
||||
return '-';
|
||||
}
|
||||
//! char between year-month
|
||||
static wchar_t month_sep_char()
|
||||
{
|
||||
return '-';
|
||||
}
|
||||
//! Char to separate month-day
|
||||
static wchar_t day_sep_char()
|
||||
{
|
||||
return '-';
|
||||
}
|
||||
//! char between date-hours
|
||||
static wchar_t hour_sep_char()
|
||||
{
|
||||
return ' ';
|
||||
}
|
||||
//! char between hour and minute
|
||||
static wchar_t minute_sep_char()
|
||||
{
|
||||
return ':';
|
||||
}
|
||||
//! char for second
|
||||
static wchar_t second_sep_char()
|
||||
{
|
||||
return ':';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_STD_WSTRING
|
||||
} } //namespace date_time
|
||||
|
||||
/* Copyright (c) 2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,31 +1,42 @@
|
||||
#ifndef DATE_TIME_DATE_FORMATTING_HPP___
|
||||
#define DATE_TIME_DATE_FORMATTING_HPP___
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include "boost/date_time/iso_format.hpp"
|
||||
#include "boost/date_time/compiler_config.hpp"
|
||||
#include <boost/io/ios_state.hpp>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
/* NOTE: "formatter" code for older compilers, ones that define
|
||||
* BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS, is located in
|
||||
* date_formatting_limited.hpp
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
//! Formats a month as as string into an ostream
|
||||
template<class month_type, class format_type>
|
||||
template<class month_type, class format_type, class charT=char>
|
||||
class month_formatter
|
||||
{
|
||||
typedef std::basic_ostream<charT> ostream_type;
|
||||
public:
|
||||
//! Formats a month as as string into an ostream
|
||||
/*! This function demands that month_type provide
|
||||
* functions for converting to short and long strings
|
||||
* if that capability is used.
|
||||
*/
|
||||
static std::ostream& format_month(const month_type& month,
|
||||
std::ostream& os)
|
||||
static ostream_type& format_month(const month_type& month,
|
||||
ostream_type &os)
|
||||
{
|
||||
switch (format_type::month_format())
|
||||
{
|
||||
@@ -41,10 +52,13 @@ namespace date_time {
|
||||
}
|
||||
case month_as_integer:
|
||||
{
|
||||
os << std::setw(2) << std::setfill('0') << month.as_number();
|
||||
boost::io::basic_ios_fill_saver<charT> ifs(os);
|
||||
os << std::setw(2) << std::setfill(os.widen('0')) << month.as_number();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return os;
|
||||
} // format_month
|
||||
@@ -52,7 +66,7 @@ namespace date_time {
|
||||
|
||||
|
||||
//! Convert ymd to a standard string formatting policies
|
||||
template<class ymd_type, class format_type>
|
||||
template<class ymd_type, class format_type, class charT=char>
|
||||
class ymd_formatter
|
||||
{
|
||||
public:
|
||||
@@ -65,20 +79,26 @@ namespace date_time {
|
||||
* an integer or a string as controled by the formatting
|
||||
* policy
|
||||
*/
|
||||
static std::string ymd_to_string(ymd_type ymd)
|
||||
static std::basic_string<charT> ymd_to_string(ymd_type ymd)
|
||||
{
|
||||
typedef typename ymd_type::month_type month_type;
|
||||
std::ostringstream ss;
|
||||
std::basic_ostringstream<charT> ss;
|
||||
|
||||
// Temporarily switch to classic locale to prevent possible formatting
|
||||
// of year with comma or other character (for example 2,008).
|
||||
ss.imbue(std::locale::classic());
|
||||
ss << ymd.year;
|
||||
ss.imbue(std::locale());
|
||||
|
||||
if (format_type::has_date_sep_chars()) {
|
||||
ss << format_type::month_sep_char();
|
||||
}
|
||||
//this name is a bit ugly, oh well....
|
||||
month_formatter<month_type,format_type>::format_month(ymd.month, ss);
|
||||
month_formatter<month_type,format_type,charT>::format_month(ymd.month, ss);
|
||||
if (format_type::has_date_sep_chars()) {
|
||||
ss << format_type::day_sep_char();
|
||||
}
|
||||
ss << std::setw(2) << std::setfill('0')
|
||||
ss << std::setw(2) << std::setfill(ss.widen('0'))
|
||||
<< ymd.day;
|
||||
return ss.str();
|
||||
}
|
||||
@@ -86,42 +106,32 @@ namespace date_time {
|
||||
|
||||
|
||||
//! Convert a date to string using format policies
|
||||
template<class date_type, class format_type>
|
||||
template<class date_type, class format_type, class charT=char>
|
||||
class date_formatter
|
||||
{
|
||||
public:
|
||||
typedef std::basic_string<charT> string_type;
|
||||
//! Convert to a date to standard string using format policies
|
||||
static std::string date_to_string(date_type d)
|
||||
static string_type date_to_string(date_type d)
|
||||
{
|
||||
typedef typename date_type::ymd_type ymd_type;
|
||||
if (d.is_not_a_date()) {
|
||||
return format_type::not_a_date();
|
||||
return string_type(format_type::not_a_date());
|
||||
}
|
||||
if (d.is_neg_infinity()) {
|
||||
return format_type::neg_infinity();
|
||||
return string_type(format_type::neg_infinity());
|
||||
}
|
||||
if (d.is_pos_infinity()) {
|
||||
return format_type::pos_infinity();
|
||||
return string_type(format_type::pos_infinity());
|
||||
}
|
||||
ymd_type ymd = d.year_month_day();
|
||||
return ymd_formatter<ymd_type, format_type>::ymd_to_string(ymd);
|
||||
return ymd_formatter<ymd_type, format_type, charT>::ymd_to_string(ymd);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
|
||||
|
||||
/* Copyright (c) 2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
#ifndef DATE_TIME_DATE_FORMATTING_LIMITED_HPP___
|
||||
#define DATE_TIME_DATE_FORMATTING_LIMITED_HPP___
|
||||
|
||||
/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include "boost/date_time/iso_format.hpp"
|
||||
#include "boost/date_time/compiler_config.hpp"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
//! Formats a month as as string into an ostream
|
||||
template<class month_type, class format_type>
|
||||
class month_formatter
|
||||
{
|
||||
public:
|
||||
//! Formats a month as as string into an ostream
|
||||
/*! This function demands that month_type provide
|
||||
* functions for converting to short and long strings
|
||||
* if that capability is used.
|
||||
*/
|
||||
static std::ostream& format_month(const month_type& month,
|
||||
std::ostream& os)
|
||||
{
|
||||
switch (format_type::month_format())
|
||||
{
|
||||
case month_as_short_string:
|
||||
{
|
||||
os << month.as_short_string();
|
||||
break;
|
||||
}
|
||||
case month_as_long_string:
|
||||
{
|
||||
os << month.as_long_string();
|
||||
break;
|
||||
}
|
||||
case month_as_integer:
|
||||
{
|
||||
os << std::setw(2) << std::setfill('0') << month.as_number();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return os;
|
||||
} // format_month
|
||||
};
|
||||
|
||||
|
||||
//! Convert ymd to a standard string formatting policies
|
||||
template<class ymd_type, class format_type>
|
||||
class ymd_formatter
|
||||
{
|
||||
public:
|
||||
//! Convert ymd to a standard string formatting policies
|
||||
/*! This is standard code for handling date formatting with
|
||||
* year-month-day based date information. This function
|
||||
* uses the format_type to control whether the string will
|
||||
* contain separator characters, and if so what the character
|
||||
* will be. In addtion, it can format the month as either
|
||||
* an integer or a string as controled by the formatting
|
||||
* policy
|
||||
*/
|
||||
static std::string ymd_to_string(ymd_type ymd)
|
||||
{
|
||||
typedef typename ymd_type::month_type month_type;
|
||||
std::ostringstream ss;
|
||||
ss << ymd.year;
|
||||
if (format_type::has_date_sep_chars()) {
|
||||
ss << format_type::month_sep_char();
|
||||
}
|
||||
//this name is a bit ugly, oh well....
|
||||
month_formatter<month_type,format_type>::format_month(ymd.month, ss);
|
||||
if (format_type::has_date_sep_chars()) {
|
||||
ss << format_type::day_sep_char();
|
||||
}
|
||||
ss << std::setw(2) << std::setfill('0')
|
||||
<< ymd.day;
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Convert a date to string using format policies
|
||||
template<class date_type, class format_type>
|
||||
class date_formatter
|
||||
{
|
||||
public:
|
||||
//! Convert to a date to standard string using format policies
|
||||
static std::string date_to_string(date_type d)
|
||||
{
|
||||
typedef typename date_type::ymd_type ymd_type;
|
||||
if (d.is_not_a_date()) {
|
||||
return format_type::not_a_date();
|
||||
}
|
||||
if (d.is_neg_infinity()) {
|
||||
return format_type::neg_infinity();
|
||||
}
|
||||
if (d.is_pos_infinity()) {
|
||||
return format_type::pos_infinity();
|
||||
}
|
||||
ymd_type ymd = d.year_month_day();
|
||||
return ymd_formatter<ymd_type, format_type>::ymd_to_string(ymd);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#ifndef DATE_TIME_DATE_FORMATTING_LOCALES_HPP___
|
||||
#define DATE_TIME_DATE_FORMATTING_LOCALES_HPP___
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
|
||||
@@ -13,6 +17,7 @@
|
||||
#include "boost/date_time/iso_format.hpp"
|
||||
#include "boost/date_time/date_names_put.hpp"
|
||||
#include "boost/date_time/parse_format_base.hpp"
|
||||
#include <boost/io/ios_state.hpp>
|
||||
//#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
@@ -36,33 +41,34 @@ namespace date_time {
|
||||
const facet_type& f)
|
||||
{
|
||||
|
||||
switch (f.month_format())
|
||||
switch (f.month_format())
|
||||
{
|
||||
case month_as_short_string:
|
||||
{
|
||||
case month_as_short_string:
|
||||
{
|
||||
std::ostreambuf_iterator<charT> oitr(os);
|
||||
f.put_month_short(oitr, month.as_enum());
|
||||
break;
|
||||
}
|
||||
case month_as_long_string:
|
||||
{
|
||||
case month_as_long_string:
|
||||
{
|
||||
std::ostreambuf_iterator<charT> oitr(os);
|
||||
f.put_month_long(oitr, month.as_enum());
|
||||
break;
|
||||
}
|
||||
case month_as_integer:
|
||||
{
|
||||
os << std::setw(2) << std::setfill('0') << month.as_number();
|
||||
case month_as_integer:
|
||||
{
|
||||
boost::io::basic_ios_fill_saver<charT> ifs(os);
|
||||
os << std::setw(2) << std::setfill(os.widen('0')) << month.as_number();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // format_month
|
||||
|
||||
};
|
||||
|
||||
|
||||
//! Formats a weekday
|
||||
//! Formats a weekday
|
||||
template<class weekday_type,
|
||||
class facet_type,
|
||||
class charT = char>
|
||||
@@ -86,7 +92,7 @@ namespace date_time {
|
||||
else {
|
||||
f.put_weekday_short(oitr, wd.as_enum());
|
||||
}
|
||||
|
||||
|
||||
} // format_weekday
|
||||
|
||||
};
|
||||
@@ -100,19 +106,19 @@ namespace date_time {
|
||||
{
|
||||
public:
|
||||
typedef typename ymd_type::month_type month_type;
|
||||
typedef ostream_month_formatter<facet_type> month_formatter;
|
||||
typedef ostream_month_formatter<facet_type, charT> month_formatter_type;
|
||||
typedef std::basic_ostream<charT> ostream_type;
|
||||
typedef std::basic_string<charT> foo_type;
|
||||
|
||||
//! Convert ymd to a standard string formatting policies
|
||||
/*! This is standard code for handling date formatting with
|
||||
* year-month-day based date information. This function
|
||||
* year-month-day based date information. This function
|
||||
* uses the format_type to control whether the string will
|
||||
* contain separator characters, and if so what the character
|
||||
* will be. In addtion, it can format the month as either
|
||||
* an integer or a string as controled by the formatting
|
||||
* an integer or a string as controled by the formatting
|
||||
* policy
|
||||
*/
|
||||
*/
|
||||
// static string_type ymd_to_string(ymd_type ymd)
|
||||
// {
|
||||
// std::ostringstream ss;
|
||||
@@ -123,10 +129,11 @@ namespace date_time {
|
||||
|
||||
|
||||
// Put ymd to ostream -- part of ostream refactor
|
||||
static void ymd_put(ymd_type ymd,
|
||||
static void ymd_put(ymd_type ymd,
|
||||
ostream_type& os,
|
||||
const facet_type& f)
|
||||
{
|
||||
boost::io::basic_ios_fill_saver<charT> ifs(os);
|
||||
std::ostreambuf_iterator<charT> oitr(os);
|
||||
switch (f.date_order()) {
|
||||
case ymd_order_iso: {
|
||||
@@ -134,20 +141,20 @@ namespace date_time {
|
||||
if (f.has_date_sep_chars()) {
|
||||
f.month_sep_char(oitr);
|
||||
}
|
||||
month_formatter::format_month(ymd.month, os, f);
|
||||
month_formatter_type::format_month(ymd.month, os, f);
|
||||
if (f.has_date_sep_chars()) {
|
||||
f.day_sep_char(oitr);
|
||||
}
|
||||
os << std::setw(2) << std::setfill('0')
|
||||
os << std::setw(2) << std::setfill(os.widen('0'))
|
||||
<< ymd.day;
|
||||
break;
|
||||
}
|
||||
case ymd_order_us: {
|
||||
month_formatter::format_month(ymd.month, os, f);
|
||||
month_formatter_type::format_month(ymd.month, os, f);
|
||||
if (f.has_date_sep_chars()) {
|
||||
f.day_sep_char(oitr);
|
||||
}
|
||||
os << std::setw(2) << std::setfill('0')
|
||||
os << std::setw(2) << std::setfill(os.widen('0'))
|
||||
<< ymd.day;
|
||||
if (f.has_date_sep_chars()) {
|
||||
f.month_sep_char(oitr);
|
||||
@@ -156,12 +163,12 @@ namespace date_time {
|
||||
break;
|
||||
}
|
||||
case ymd_order_dmy: {
|
||||
os << std::setw(2) << std::setfill('0')
|
||||
os << std::setw(2) << std::setfill(os.widen('0'))
|
||||
<< ymd.day;
|
||||
if (f.has_date_sep_chars()) {
|
||||
f.day_sep_char(oitr);
|
||||
}
|
||||
month_formatter::format_month(ymd.month, os, f);
|
||||
month_formatter_type::format_month(ymd.month, os, f);
|
||||
if (f.has_date_sep_chars()) {
|
||||
f.month_sep_char(oitr);
|
||||
}
|
||||
@@ -183,8 +190,8 @@ namespace date_time {
|
||||
typedef std::basic_ostream<charT> ostream_type;
|
||||
typedef typename date_type::ymd_type ymd_type;
|
||||
|
||||
//! Put date into an ostream
|
||||
static void date_put(const date_type& d,
|
||||
//! Put date into an ostream
|
||||
static void date_put(const date_type& d,
|
||||
ostream_type& os,
|
||||
const facet_type& f)
|
||||
{
|
||||
@@ -197,11 +204,11 @@ namespace date_time {
|
||||
std::ostreambuf_iterator<charT> coi(os);
|
||||
f.put_special_value(coi, sv);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//! Put date into an ostream
|
||||
static void date_put(const date_type& d,
|
||||
|
||||
//! Put date into an ostream
|
||||
static void date_put(const date_type& d,
|
||||
ostream_type& os)
|
||||
{
|
||||
//retrieve the local from the ostream
|
||||
@@ -215,24 +222,13 @@ namespace date_time {
|
||||
facet_type default_facet;
|
||||
date_put(d, os, default_facet);
|
||||
}
|
||||
} // date_to_ostream
|
||||
} // date_to_ostream
|
||||
}; //class date_formatter
|
||||
|
||||
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
#endif
|
||||
|
||||
/* Copyright (c) 2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
#ifndef _DATE_TIME_DATE_GENERATOR_FORMATTER__HPP___
|
||||
#define _DATE_TIME_DATE_GENERATOR_FORMATTER__HPP___
|
||||
|
||||
/* Copyright (c) 2004 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "boost/date_time/date_generators.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
//! Formats date_generators for output
|
||||
/*! Formatting of date_generators follows specific orders for the
|
||||
* various types of date_generators.
|
||||
* - partial_date => "dd Month"
|
||||
* - nth_day_of_the_week_in_month => "nth weekday of month"
|
||||
* - first_day_of_the_week_in_month => "first weekday of month"
|
||||
* - last_day_of_the_week_in_month => "last weekday of month"
|
||||
* - first_day_of_the_week_after => "weekday after"
|
||||
* - first_day_of_the_week_before => "weekday before"
|
||||
* While the order of the elements in these phrases cannot be changed,
|
||||
* the elements themselves can be. Weekday and Month get their formats
|
||||
* and names from the date_facet. The remaining elements are stored in
|
||||
* the date_generator_formatter and can be customized upon construction
|
||||
* or via a member function. The default elements are those shown in the
|
||||
* examples above.
|
||||
*/
|
||||
template <class date_type, class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
|
||||
class date_generator_formatter {
|
||||
public:
|
||||
typedef partial_date<date_type> partial_date_type;
|
||||
typedef nth_kday_of_month<date_type> nth_kday_type;
|
||||
typedef first_kday_of_month<date_type> first_kday_type;
|
||||
typedef last_kday_of_month<date_type> last_kday_type;
|
||||
typedef first_kday_after<date_type> kday_after_type;
|
||||
typedef first_kday_before<date_type> kday_before_type;
|
||||
|
||||
typedef CharT char_type;
|
||||
typedef std::basic_string<char_type> string_type;
|
||||
typedef std::vector<string_type> collection_type;
|
||||
static const char_type first_string[6];
|
||||
static const char_type second_string[7];
|
||||
static const char_type third_string[6];
|
||||
static const char_type fourth_string[7];
|
||||
static const char_type fifth_string[6];
|
||||
static const char_type last_string[5];
|
||||
static const char_type before_string[8];
|
||||
static const char_type after_string[6];
|
||||
static const char_type of_string[3];
|
||||
|
||||
enum phrase_elements {first=0, second, third, fourth, fifth, last,
|
||||
before, after, of, number_of_phrase_elements};
|
||||
|
||||
//! Default format elements used
|
||||
date_generator_formatter()
|
||||
{
|
||||
phrase_strings.reserve(number_of_phrase_elements);
|
||||
phrase_strings.push_back(string_type(first_string));
|
||||
phrase_strings.push_back(string_type(second_string));
|
||||
phrase_strings.push_back(string_type(third_string));
|
||||
phrase_strings.push_back(string_type(fourth_string));
|
||||
phrase_strings.push_back(string_type(fifth_string));
|
||||
phrase_strings.push_back(string_type(last_string));
|
||||
phrase_strings.push_back(string_type(before_string));
|
||||
phrase_strings.push_back(string_type(after_string));
|
||||
phrase_strings.push_back(string_type(of_string));
|
||||
}
|
||||
|
||||
//! Constructor that allows for a custom set of phrase elements
|
||||
date_generator_formatter(const string_type& first_str,
|
||||
const string_type& second_str,
|
||||
const string_type& third_str,
|
||||
const string_type& fourth_str,
|
||||
const string_type& fifth_str,
|
||||
const string_type& last_str,
|
||||
const string_type& before_str,
|
||||
const string_type& after_str,
|
||||
const string_type& of_str)
|
||||
{
|
||||
phrase_strings.reserve(number_of_phrase_elements);
|
||||
phrase_strings.push_back(first_str);
|
||||
phrase_strings.push_back(second_str);
|
||||
phrase_strings.push_back(third_str);
|
||||
phrase_strings.push_back(fourth_str);
|
||||
phrase_strings.push_back(fifth_str);
|
||||
phrase_strings.push_back(last_str);
|
||||
phrase_strings.push_back(before_str);
|
||||
phrase_strings.push_back(after_str);
|
||||
phrase_strings.push_back(of_str);
|
||||
}
|
||||
|
||||
//! Replace the set of phrase elements with those contained in new_strings
|
||||
/*! The order of the strings in the given collection is important.
|
||||
* They must follow:
|
||||
* - first, second, third, fourth, fifth, last, before, after, of.
|
||||
*
|
||||
* It is not necessary to send in a complete set if only a few
|
||||
* elements are to be replaced as long as the correct beg_pos is used.
|
||||
*
|
||||
* Ex: To keep the default first through fifth elements, but replace
|
||||
* the rest with a collection of:
|
||||
* - "final", "prior", "following", "in".
|
||||
* The beg_pos of date_generator_formatter::last would be used.
|
||||
*/
|
||||
void elements(const collection_type& new_strings,
|
||||
phrase_elements beg_pos=first)
|
||||
{
|
||||
if(beg_pos < number_of_phrase_elements) {
|
||||
typename collection_type::iterator itr = phrase_strings.begin();
|
||||
itr += beg_pos;
|
||||
std::copy(new_strings.begin(), new_strings.end(),
|
||||
itr);
|
||||
//phrase_strings.begin());
|
||||
}
|
||||
}
|
||||
|
||||
//!Put a partial_date => "dd Month"
|
||||
template<class facet_type>
|
||||
OutItrT put_partial_date(OutItrT next, std::ios_base& a_ios,
|
||||
CharT a_fill, const partial_date_type& pd,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
facet.put(next, a_ios, a_fill, pd.day());
|
||||
next = a_fill; //TODO change this ???
|
||||
facet.put(next, a_ios, a_fill, pd.month());
|
||||
return next;
|
||||
}
|
||||
|
||||
//! Put an nth_day_of_the_week_in_month => "nth weekday of month"
|
||||
template<class facet_type>
|
||||
OutItrT put_nth_kday(OutItrT next, std::ios_base& a_ios,
|
||||
CharT a_fill, const nth_kday_type& nkd,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
put_string(next, phrase_strings[nkd.nth_week() -1]);
|
||||
next = a_fill; //TODO change this ???
|
||||
facet.put(next, a_ios, a_fill, nkd.day_of_week());
|
||||
next = a_fill; //TODO change this ???
|
||||
put_string(next, string_type(of_string));
|
||||
next = a_fill; //TODO change this ???
|
||||
facet.put(next, a_ios, a_fill, nkd.month());
|
||||
return next;
|
||||
}
|
||||
|
||||
//! Put a first_day_of_the_week_in_month => "first weekday of month"
|
||||
template<class facet_type>
|
||||
OutItrT put_first_kday(OutItrT next, std::ios_base& a_ios,
|
||||
CharT a_fill, const first_kday_type& fkd,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
put_string(next, phrase_strings[first]);
|
||||
next = a_fill; //TODO change this ???
|
||||
facet.put(next, a_ios, a_fill, fkd.day_of_week());
|
||||
next = a_fill; //TODO change this ???
|
||||
put_string(next, string_type(of_string));
|
||||
next = a_fill; //TODO change this ???
|
||||
facet.put(next, a_ios, a_fill, fkd.month());
|
||||
return next;
|
||||
}
|
||||
|
||||
//! Put a last_day_of_the_week_in_month => "last weekday of month"
|
||||
template<class facet_type>
|
||||
OutItrT put_last_kday(OutItrT next, std::ios_base& a_ios,
|
||||
CharT a_fill, const last_kday_type& lkd,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
put_string(next, phrase_strings[last]);
|
||||
next = a_fill; //TODO change this ???
|
||||
facet.put(next, a_ios, a_fill, lkd.day_of_week());
|
||||
next = a_fill; //TODO change this ???
|
||||
put_string(next, string_type(of_string));
|
||||
next = a_fill; //TODO change this ???
|
||||
facet.put(next, a_ios, a_fill, lkd.month());
|
||||
return next;
|
||||
}
|
||||
|
||||
//! Put a first_day_of_the_week_before => "weekday before"
|
||||
template<class facet_type>
|
||||
OutItrT put_kday_before(OutItrT next, std::ios_base& a_ios,
|
||||
CharT a_fill, const kday_before_type& fkb,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
facet.put(next, a_ios, a_fill, fkb.day_of_week());
|
||||
next = a_fill; //TODO change this ???
|
||||
put_string(next, phrase_strings[before]);
|
||||
return next;
|
||||
}
|
||||
|
||||
//! Put a first_day_of_the_week_after => "weekday after"
|
||||
template<class facet_type>
|
||||
OutItrT put_kday_after(OutItrT next, std::ios_base& a_ios,
|
||||
CharT a_fill, const kday_after_type& fka,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
facet.put(next, a_ios, a_fill, fka.day_of_week());
|
||||
next = a_fill; //TODO change this ???
|
||||
put_string(next, phrase_strings[after]);
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
collection_type phrase_strings;
|
||||
|
||||
//! helper function to put the various member string into stream
|
||||
OutItrT put_string(OutItrT next, const string_type& str) const
|
||||
{
|
||||
typename string_type::const_iterator itr = str.begin();
|
||||
while(itr != str.end()) {
|
||||
*next = *itr;
|
||||
++itr;
|
||||
++next;
|
||||
}
|
||||
return next;
|
||||
}
|
||||
};
|
||||
|
||||
template<class date_type, class CharT, class OutItrT>
|
||||
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
|
||||
date_generator_formatter<date_type, CharT, OutItrT>::first_string[6] =
|
||||
{'f','i','r','s','t'};
|
||||
template<class date_type, class CharT, class OutItrT>
|
||||
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
|
||||
date_generator_formatter<date_type, CharT, OutItrT>::second_string[7] =
|
||||
{'s','e','c','o','n','d'};
|
||||
template<class date_type, class CharT, class OutItrT>
|
||||
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
|
||||
date_generator_formatter<date_type, CharT, OutItrT>::third_string[6] =
|
||||
{'t','h','i','r','d'};
|
||||
template<class date_type, class CharT, class OutItrT>
|
||||
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
|
||||
date_generator_formatter<date_type, CharT, OutItrT>::fourth_string[7] =
|
||||
{'f','o','u','r','t','h'};
|
||||
template<class date_type, class CharT, class OutItrT>
|
||||
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
|
||||
date_generator_formatter<date_type, CharT, OutItrT>::fifth_string[6] =
|
||||
{'f','i','f','t','h'};
|
||||
template<class date_type, class CharT, class OutItrT>
|
||||
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
|
||||
date_generator_formatter<date_type, CharT, OutItrT>::last_string[5] =
|
||||
{'l','a','s','t'};
|
||||
template<class date_type, class CharT, class OutItrT>
|
||||
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
|
||||
date_generator_formatter<date_type, CharT, OutItrT>::before_string[8] =
|
||||
{'b','e','f','o','r','e'};
|
||||
template<class date_type, class CharT, class OutItrT>
|
||||
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
|
||||
date_generator_formatter<date_type, CharT, OutItrT>::after_string[6] =
|
||||
{'a','f','t','e','r'};
|
||||
template<class date_type, class CharT, class OutItrT>
|
||||
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
|
||||
date_generator_formatter<date_type, CharT, OutItrT>::of_string[3] =
|
||||
{'o','f'};
|
||||
} } // namespaces
|
||||
|
||||
#endif // _DATE_TIME_DATE_GENERATOR_FORMATTER__HPP___
|
||||
@@ -0,0 +1,330 @@
|
||||
|
||||
#ifndef DATE_TIME_DATE_GENERATOR_PARSER_HPP__
|
||||
#define DATE_TIME_DATE_GENERATOR_PARSER_HPP__
|
||||
|
||||
/* Copyright (c) 2005 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iterator> // istreambuf_iterator
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/string_parse_tree.hpp>
|
||||
#include <boost/date_time/date_generators.hpp>
|
||||
#include <boost/date_time/format_date_parser.hpp>
|
||||
|
||||
namespace boost { namespace date_time {
|
||||
|
||||
//! Class for date_generator parsing
|
||||
/*! The elements of a date_generator "phrase" are parsed from the input stream in a
|
||||
* particular order. All elements are required and the order in which they appear
|
||||
* cannot change, however, the elements themselves can be changed. The default
|
||||
* elements and their order are as follows:
|
||||
*
|
||||
* - partial_date => "dd Month"
|
||||
* - nth_day_of_the_week_in_month => "nth weekday of month"
|
||||
* - first_day_of_the_week_in_month => "first weekday of month"
|
||||
* - last_day_of_the_week_in_month => "last weekday of month"
|
||||
* - first_day_of_the_week_after => "weekday after"
|
||||
* - first_day_of_the_week_before => "weekday before"
|
||||
*
|
||||
* Weekday and Month names and formats are handled via the date_input_facet.
|
||||
*
|
||||
*/
|
||||
template<class date_type, typename charT>
|
||||
class date_generator_parser
|
||||
{
|
||||
public:
|
||||
typedef std::basic_string<charT> string_type;
|
||||
typedef std::istreambuf_iterator<charT> stream_itr_type;
|
||||
|
||||
typedef typename date_type::month_type month_type;
|
||||
typedef typename date_type::day_of_week_type day_of_week_type;
|
||||
typedef typename date_type::day_type day_type;
|
||||
|
||||
typedef string_parse_tree<charT> parse_tree_type;
|
||||
typedef typename parse_tree_type::parse_match_result_type match_results;
|
||||
typedef std::vector<std::basic_string<charT> > collection_type;
|
||||
|
||||
typedef partial_date<date_type> partial_date_type;
|
||||
typedef nth_kday_of_month<date_type> nth_kday_type;
|
||||
typedef first_kday_of_month<date_type> first_kday_type;
|
||||
typedef last_kday_of_month<date_type> last_kday_type;
|
||||
typedef first_kday_after<date_type> kday_after_type;
|
||||
typedef first_kday_before<date_type> kday_before_type;
|
||||
|
||||
typedef charT char_type;
|
||||
static const char_type first_string[6];
|
||||
static const char_type second_string[7];
|
||||
static const char_type third_string[6];
|
||||
static const char_type fourth_string[7];
|
||||
static const char_type fifth_string[6];
|
||||
static const char_type last_string[5];
|
||||
static const char_type before_string[8];
|
||||
static const char_type after_string[6];
|
||||
static const char_type of_string[3];
|
||||
|
||||
enum phrase_elements {first=0, second, third, fourth, fifth, last,
|
||||
before, after, of, number_of_phrase_elements};
|
||||
|
||||
//! Creates a date_generator_parser with the default set of "element_strings"
|
||||
date_generator_parser()
|
||||
{
|
||||
element_strings(string_type(first_string),
|
||||
string_type(second_string),
|
||||
string_type(third_string),
|
||||
string_type(fourth_string),
|
||||
string_type(fifth_string),
|
||||
string_type(last_string),
|
||||
string_type(before_string),
|
||||
string_type(after_string),
|
||||
string_type(of_string));
|
||||
}
|
||||
|
||||
//! Creates a date_generator_parser using a user defined set of element strings
|
||||
date_generator_parser(const string_type& first_str,
|
||||
const string_type& second_str,
|
||||
const string_type& third_str,
|
||||
const string_type& fourth_str,
|
||||
const string_type& fifth_str,
|
||||
const string_type& last_str,
|
||||
const string_type& before_str,
|
||||
const string_type& after_str,
|
||||
const string_type& of_str)
|
||||
{
|
||||
element_strings(first_str, second_str, third_str, fourth_str, fifth_str,
|
||||
last_str, before_str, after_str, of_str);
|
||||
}
|
||||
|
||||
//! Replace strings that determine nth week for generator
|
||||
void element_strings(const string_type& first_str,
|
||||
const string_type& second_str,
|
||||
const string_type& third_str,
|
||||
const string_type& fourth_str,
|
||||
const string_type& fifth_str,
|
||||
const string_type& last_str,
|
||||
const string_type& before_str,
|
||||
const string_type& after_str,
|
||||
const string_type& of_str)
|
||||
{
|
||||
collection_type phrases;
|
||||
phrases.push_back(first_str);
|
||||
phrases.push_back(second_str);
|
||||
phrases.push_back(third_str);
|
||||
phrases.push_back(fourth_str);
|
||||
phrases.push_back(fifth_str);
|
||||
phrases.push_back(last_str);
|
||||
phrases.push_back(before_str);
|
||||
phrases.push_back(after_str);
|
||||
phrases.push_back(of_str);
|
||||
m_element_strings = parse_tree_type(phrases, this->first); // enum first
|
||||
}
|
||||
|
||||
void element_strings(const collection_type& col)
|
||||
{
|
||||
m_element_strings = parse_tree_type(col, this->first); // enum first
|
||||
}
|
||||
|
||||
//! returns partial_date parsed from stream
|
||||
template<class facet_type>
|
||||
partial_date_type
|
||||
get_partial_date_type(stream_itr_type& sitr,
|
||||
stream_itr_type& stream_end,
|
||||
std::ios_base& a_ios,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
// skip leading whitespace
|
||||
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
|
||||
|
||||
day_type d(1);
|
||||
month_type m(1);
|
||||
facet.get(sitr, stream_end, a_ios, d);
|
||||
facet.get(sitr, stream_end, a_ios, m);
|
||||
|
||||
return partial_date_type(d,m);
|
||||
}
|
||||
|
||||
//! returns nth_kday_of_week parsed from stream
|
||||
template<class facet_type>
|
||||
nth_kday_type
|
||||
get_nth_kday_type(stream_itr_type& sitr,
|
||||
stream_itr_type& stream_end,
|
||||
std::ios_base& a_ios,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
// skip leading whitespace
|
||||
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
|
||||
|
||||
typename nth_kday_type::week_num wn;
|
||||
day_of_week_type wd(0); // no default constructor
|
||||
month_type m(1); // no default constructor
|
||||
|
||||
match_results mr = m_element_strings.match(sitr, stream_end);
|
||||
switch(mr.current_match) {
|
||||
case first : { wn = nth_kday_type::first; break; }
|
||||
case second : { wn = nth_kday_type::second; break; }
|
||||
case third : { wn = nth_kday_type::third; break; }
|
||||
case fourth : { wn = nth_kday_type::fourth; break; }
|
||||
case fifth : { wn = nth_kday_type::fifth; break; }
|
||||
default:
|
||||
{
|
||||
boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
|
||||
BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(wn = nth_kday_type::first);
|
||||
}
|
||||
} // week num
|
||||
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
|
||||
extract_element(sitr, stream_end, of); // "of" element
|
||||
facet.get(sitr, stream_end, a_ios, m); // month
|
||||
|
||||
return nth_kday_type(wn, wd, m);
|
||||
}
|
||||
|
||||
//! returns first_kday_of_week parsed from stream
|
||||
template<class facet_type>
|
||||
first_kday_type
|
||||
get_first_kday_type(stream_itr_type& sitr,
|
||||
stream_itr_type& stream_end,
|
||||
std::ios_base& a_ios,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
// skip leading whitespace
|
||||
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
|
||||
|
||||
day_of_week_type wd(0); // no default constructor
|
||||
month_type m(1); // no default constructor
|
||||
|
||||
extract_element(sitr, stream_end, first); // "first" element
|
||||
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
|
||||
extract_element(sitr, stream_end, of); // "of" element
|
||||
facet.get(sitr, stream_end, a_ios, m); // month
|
||||
|
||||
|
||||
return first_kday_type(wd, m);
|
||||
}
|
||||
|
||||
//! returns last_kday_of_week parsed from stream
|
||||
template<class facet_type>
|
||||
last_kday_type
|
||||
get_last_kday_type(stream_itr_type& sitr,
|
||||
stream_itr_type& stream_end,
|
||||
std::ios_base& a_ios,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
// skip leading whitespace
|
||||
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
|
||||
|
||||
day_of_week_type wd(0); // no default constructor
|
||||
month_type m(1); // no default constructor
|
||||
|
||||
extract_element(sitr, stream_end, last); // "last" element
|
||||
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
|
||||
extract_element(sitr, stream_end, of); // "of" element
|
||||
facet.get(sitr, stream_end, a_ios, m); // month
|
||||
|
||||
|
||||
return last_kday_type(wd, m);
|
||||
}
|
||||
|
||||
//! returns first_kday_of_week parsed from stream
|
||||
template<class facet_type>
|
||||
kday_before_type
|
||||
get_kday_before_type(stream_itr_type& sitr,
|
||||
stream_itr_type& stream_end,
|
||||
std::ios_base& a_ios,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
// skip leading whitespace
|
||||
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
|
||||
|
||||
day_of_week_type wd(0); // no default constructor
|
||||
|
||||
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
|
||||
extract_element(sitr, stream_end, before);// "before" element
|
||||
|
||||
return kday_before_type(wd);
|
||||
}
|
||||
|
||||
//! returns first_kday_of_week parsed from stream
|
||||
template<class facet_type>
|
||||
kday_after_type
|
||||
get_kday_after_type(stream_itr_type& sitr,
|
||||
stream_itr_type& stream_end,
|
||||
std::ios_base& a_ios,
|
||||
const facet_type& facet) const
|
||||
{
|
||||
// skip leading whitespace
|
||||
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
|
||||
|
||||
day_of_week_type wd(0); // no default constructor
|
||||
|
||||
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
|
||||
extract_element(sitr, stream_end, after); // "after" element
|
||||
|
||||
return kday_after_type(wd);
|
||||
}
|
||||
|
||||
private:
|
||||
parse_tree_type m_element_strings;
|
||||
|
||||
//! Extracts phrase element from input. Throws ios_base::failure on error.
|
||||
void extract_element(stream_itr_type& sitr,
|
||||
stream_itr_type& stream_end,
|
||||
typename date_generator_parser::phrase_elements ele) const
|
||||
{
|
||||
// skip leading whitespace
|
||||
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
|
||||
match_results mr = m_element_strings.match(sitr, stream_end);
|
||||
if(mr.current_match != ele) {
|
||||
boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<class date_type, class CharT>
|
||||
const typename date_generator_parser<date_type, CharT>::char_type
|
||||
date_generator_parser<date_type, CharT>::first_string[6] =
|
||||
{'f','i','r','s','t'};
|
||||
template<class date_type, class CharT>
|
||||
const typename date_generator_parser<date_type, CharT>::char_type
|
||||
date_generator_parser<date_type, CharT>::second_string[7] =
|
||||
{'s','e','c','o','n','d'};
|
||||
template<class date_type, class CharT>
|
||||
const typename date_generator_parser<date_type, CharT>::char_type
|
||||
date_generator_parser<date_type, CharT>::third_string[6] =
|
||||
{'t','h','i','r','d'};
|
||||
template<class date_type, class CharT>
|
||||
const typename date_generator_parser<date_type, CharT>::char_type
|
||||
date_generator_parser<date_type, CharT>::fourth_string[7] =
|
||||
{'f','o','u','r','t','h'};
|
||||
template<class date_type, class CharT>
|
||||
const typename date_generator_parser<date_type, CharT>::char_type
|
||||
date_generator_parser<date_type, CharT>::fifth_string[6] =
|
||||
{'f','i','f','t','h'};
|
||||
template<class date_type, class CharT>
|
||||
const typename date_generator_parser<date_type, CharT>::char_type
|
||||
date_generator_parser<date_type, CharT>::last_string[5] =
|
||||
{'l','a','s','t'};
|
||||
template<class date_type, class CharT>
|
||||
const typename date_generator_parser<date_type, CharT>::char_type
|
||||
date_generator_parser<date_type, CharT>::before_string[8] =
|
||||
{'b','e','f','o','r','e'};
|
||||
template<class date_type, class CharT>
|
||||
const typename date_generator_parser<date_type, CharT>::char_type
|
||||
date_generator_parser<date_type, CharT>::after_string[6] =
|
||||
{'a','f','t','e','r'};
|
||||
template<class date_type, class CharT>
|
||||
const typename date_generator_parser<date_type, CharT>::char_type
|
||||
date_generator_parser<date_type, CharT>::of_string[3] =
|
||||
{'o','f'};
|
||||
|
||||
} } //namespace
|
||||
|
||||
#endif // DATE_TIME_DATE_GENERATOR_PARSER_HPP__
|
||||
|
||||
@@ -1,83 +1,191 @@
|
||||
#ifndef DATE_TIME_DATE_GENERATORS_HPP__
|
||||
#define DATE_TIME_DATE_GENERATORS_HPP__
|
||||
/* Copyright (c) 2000 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
/*! @file date_generators.hpp
|
||||
Definition and implementation of date algorithm templates
|
||||
*/
|
||||
|
||||
#include "boost/date_time/date.hpp"
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/date_time/date.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
|
||||
//! Generates a date by applying the year to the given month and day.
|
||||
/*!
|
||||
Example usage:
|
||||
@code
|
||||
partial_date pd(1, Jan);
|
||||
date d = pd.get_date(2002); //2002-Jan-01
|
||||
@endcode
|
||||
\ingroup date_alg
|
||||
*/
|
||||
//! Base class for all generators that take a year and produce a date.
|
||||
/*! This class is a base class for polymorphic function objects that take
|
||||
a year and produce a concrete date.
|
||||
@tparam date_type The type representing a date. This type must
|
||||
export a calender_type which defines a year_type.
|
||||
*/
|
||||
template<class date_type>
|
||||
class partial_date {
|
||||
class year_based_generator
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::calendar_type calendar_type;
|
||||
typedef typename calendar_type::day_type day_type;
|
||||
typedef typename calendar_type::month_type month_type;
|
||||
typedef typename calendar_type::year_type year_type;
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
partial_date(day_type d, month_type m) :
|
||||
day_(d),
|
||||
month_(m)
|
||||
{}
|
||||
//! Return a concrete date when provided with a year specific year.
|
||||
date_type get_date(year_type y) const
|
||||
{
|
||||
return date_type(y, month_, day_);
|
||||
}
|
||||
date_type operator()(year_type y) const
|
||||
{
|
||||
return date_type(y, month_, day_);
|
||||
}
|
||||
bool operator==(const partial_date& rhs) const
|
||||
{
|
||||
return (month_ == rhs.month_) && (day_ == rhs.day_);
|
||||
}
|
||||
bool operator<(const partial_date& rhs) const
|
||||
{
|
||||
if (month_ < rhs.month_) return true;
|
||||
if (month_ > rhs.month_) return false;
|
||||
//months are equal
|
||||
return (day_ < rhs.day_);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
day_type day_;
|
||||
month_type month_;
|
||||
year_based_generator() {}
|
||||
virtual ~year_based_generator() {}
|
||||
virtual date_type get_date(year_type y) const = 0;
|
||||
//! Returns a string for use in a POSIX time_zone string
|
||||
virtual std::string to_string() const = 0;
|
||||
};
|
||||
|
||||
//! Generates a date by applying the year to the given month and day.
|
||||
/*!
|
||||
Example usage:
|
||||
@code
|
||||
partial_date pd(1, Jan);
|
||||
partial_date pd2(70);
|
||||
date d = pd.get_date(2002); //2002-Jan-01
|
||||
date d2 = pd2.get_date(2002); //2002-Mar-10
|
||||
@endcode
|
||||
\ingroup date_alg
|
||||
*/
|
||||
template<class date_type>
|
||||
class partial_date : public year_based_generator<date_type>
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::calendar_type calendar_type;
|
||||
typedef typename calendar_type::day_type day_type;
|
||||
typedef typename calendar_type::month_type month_type;
|
||||
typedef typename calendar_type::year_type year_type;
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
typedef typename duration_type::duration_rep duration_rep;
|
||||
partial_date(day_type d, month_type m) :
|
||||
day_(d),
|
||||
month_(m)
|
||||
{}
|
||||
//! Partial date created from number of days into year. Range 1-366
|
||||
/*! Allowable values range from 1 to 366. 1=Jan1, 366=Dec31. If argument
|
||||
* exceeds range, partial_date will be created with closest in-range value.
|
||||
* 60 will always be Feb29, if get_date() is called with a non-leap year
|
||||
* an exception will be thrown */
|
||||
partial_date(duration_rep days) :
|
||||
day_(1), // default values
|
||||
month_(1)
|
||||
{
|
||||
date_type d1(2000,1,1);
|
||||
if(days > 1) {
|
||||
if(days > 366) // prevents wrapping
|
||||
{
|
||||
days = 366;
|
||||
}
|
||||
days = days - 1;
|
||||
duration_type dd(days);
|
||||
d1 = d1 + dd;
|
||||
}
|
||||
day_ = d1.day();
|
||||
month_ = d1.month();
|
||||
}
|
||||
//! Return a concrete date when provided with a year specific year.
|
||||
/*! Will throw an 'invalid_argument' exception if a partial_date object,
|
||||
* instantiated with Feb-29, has get_date called with a non-leap year.
|
||||
* Example:
|
||||
* @code
|
||||
* partial_date pd(29, Feb);
|
||||
* pd.get_date(2003); // throws invalid_argument exception
|
||||
* pg.get_date(2000); // returns 2000-2-29
|
||||
* @endcode
|
||||
*/
|
||||
date_type get_date(year_type y) const BOOST_OVERRIDE
|
||||
{
|
||||
if((day_ == 29) && (month_ == 2) && !(calendar_type::is_leap_year(y))) {
|
||||
std::ostringstream ss;
|
||||
ss << "No Feb 29th in given year of " << y << ".";
|
||||
boost::throw_exception(std::invalid_argument(ss.str()));
|
||||
}
|
||||
return date_type(y, month_, day_);
|
||||
}
|
||||
date_type operator()(year_type y) const
|
||||
{
|
||||
return get_date(y);
|
||||
//return date_type(y, month_, day_);
|
||||
}
|
||||
bool operator==(const partial_date& rhs) const
|
||||
{
|
||||
return (month_ == rhs.month_) && (day_ == rhs.day_);
|
||||
}
|
||||
bool operator<(const partial_date& rhs) const
|
||||
{
|
||||
if (month_ < rhs.month_) return true;
|
||||
if (month_ > rhs.month_) return false;
|
||||
//months are equal
|
||||
return (day_ < rhs.day_);
|
||||
}
|
||||
|
||||
//! Useful generator functor for finding holidays
|
||||
// added for streaming purposes
|
||||
month_type month() const
|
||||
{
|
||||
return month_;
|
||||
}
|
||||
day_type day() const
|
||||
{
|
||||
return day_;
|
||||
}
|
||||
|
||||
//! Returns string suitable for use in POSIX time zone string
|
||||
/*! Returns string formatted with up to 3 digits:
|
||||
* Jan-01 == "0"
|
||||
* Feb-29 == "58"
|
||||
* Dec-31 == "365" */
|
||||
std::string to_string() const BOOST_OVERRIDE
|
||||
{
|
||||
std::ostringstream ss;
|
||||
date_type d(2004, month_, day_);
|
||||
unsigned short c = d.day_of_year();
|
||||
c--; // numbered 0-365 while day_of_year is 1 based...
|
||||
ss << c;
|
||||
return ss.str();
|
||||
}
|
||||
private:
|
||||
day_type day_;
|
||||
month_type month_;
|
||||
};
|
||||
|
||||
//! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5.
|
||||
inline const char* nth_as_str(int ele)
|
||||
{
|
||||
static const char* const _nth_as_str[] = {"out of range", "first", "second",
|
||||
"third", "fourth", "fifth"};
|
||||
if(ele >= 1 && ele <= 5) {
|
||||
return _nth_as_str[ele];
|
||||
}
|
||||
else {
|
||||
return _nth_as_str[0];
|
||||
}
|
||||
}
|
||||
|
||||
//! Useful generator functor for finding holidays
|
||||
/*! Based on the idea in Cal. Calc. for finding holidays that are
|
||||
* the 'first Monday of September'.
|
||||
* the 'first Monday of September'. When instantiated with
|
||||
* 'fifth' kday of month, the result will be the last kday of month
|
||||
* which can be the fourth or fifth depending on the structure of
|
||||
* the month.
|
||||
*
|
||||
* The algorithm here basically guesses for the first
|
||||
* day of the month. Then finds the first day of the correct
|
||||
* type. That is, if the first of the month is a Tuesday
|
||||
* and it needs Wenesday then we simply increment by a day
|
||||
* and it needs Wednesday then we simply increment by a day
|
||||
* and then we can add the length of a week until we get
|
||||
* to the 'nth kday'. There are probably more efficient
|
||||
* algorithms based on using a mod 7, but this one works
|
||||
* to the 'nth kday'. There are probably more efficient
|
||||
* algorithms based on using a mod 7, but this one works
|
||||
* reasonably well for basic applications.
|
||||
* \ingroup date_alg
|
||||
*/
|
||||
template<class date_type>
|
||||
class nth_kday_of_month {
|
||||
class nth_kday_of_month : public year_based_generator<date_type>
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::calendar_type calendar_type;
|
||||
typedef typename calendar_type::day_of_week_type day_of_week_type;
|
||||
@@ -93,7 +201,7 @@ namespace date_time {
|
||||
dow_(dow)
|
||||
{}
|
||||
//! Return a concrete date when provided with a year specific year.
|
||||
date_type get_date(year_type y) const
|
||||
date_type get_date(year_type y) const BOOST_OVERRIDE
|
||||
{
|
||||
date_type d(y, month_, 1); //first day of month
|
||||
duration_type one_day(1);
|
||||
@@ -106,20 +214,53 @@ namespace date_time {
|
||||
d = d + one_week;
|
||||
week++;
|
||||
}
|
||||
// remove wrapping to next month behavior
|
||||
if(d.month() != month_) {
|
||||
d = d - one_week;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
// added for streaming
|
||||
month_type month() const
|
||||
{
|
||||
return month_;
|
||||
}
|
||||
week_num nth_week() const
|
||||
{
|
||||
return wn_;
|
||||
}
|
||||
day_of_week_type day_of_week() const
|
||||
{
|
||||
return dow_;
|
||||
}
|
||||
const char* nth_week_as_str() const
|
||||
{
|
||||
return nth_as_str(wn_);
|
||||
}
|
||||
//! Returns string suitable for use in POSIX time zone string
|
||||
/*! Returns a string formatted as "M4.3.0" ==> 3rd Sunday in April. */
|
||||
std::string to_string() const BOOST_OVERRIDE
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << 'M'
|
||||
<< static_cast<int>(month_) << '.'
|
||||
<< static_cast<int>(wn_) << '.'
|
||||
<< static_cast<int>(dow_);
|
||||
return ss.str();
|
||||
}
|
||||
private:
|
||||
month_type month_;
|
||||
week_num wn_;
|
||||
day_of_week_type dow_;
|
||||
};
|
||||
|
||||
//! Useful generator functor for finding holidays and daylight savings
|
||||
//! Useful generator functor for finding holidays and daylight savings
|
||||
/*! Similar to nth_kday_of_month, but requires less paramters
|
||||
* \ingroup date_alg
|
||||
*/
|
||||
template<class date_type>
|
||||
class first_kday_of_month {
|
||||
class first_kday_of_month : public year_based_generator<date_type>
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::calendar_type calendar_type;
|
||||
typedef typename calendar_type::day_of_week_type day_of_week_type;
|
||||
@@ -128,14 +269,14 @@ namespace date_time {
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
//!Specify the first 'Sunday' in 'April' spec
|
||||
/*!@param dow The day of week, eg: Sunday, Monday, etc
|
||||
* @param month The month of the year, eg: Jan, Feb, Mar, etc
|
||||
*/
|
||||
first_kday_of_month(day_of_week_type dow, month_type month) :
|
||||
month_(month),
|
||||
* @param m The month of the year, eg: Jan, Feb, Mar, etc
|
||||
*/
|
||||
first_kday_of_month(day_of_week_type dow, month_type m) :
|
||||
month_(m),
|
||||
dow_(dow)
|
||||
{}
|
||||
//! Return a concrete date when provided with a year specific year.
|
||||
date_type get_date(year_type year) const
|
||||
date_type get_date(year_type year) const BOOST_OVERRIDE
|
||||
{
|
||||
date_type d(year, month_,1);
|
||||
duration_type one_day(1);
|
||||
@@ -144,6 +285,26 @@ namespace date_time {
|
||||
}
|
||||
return d;
|
||||
}
|
||||
// added for streaming
|
||||
month_type month() const
|
||||
{
|
||||
return month_;
|
||||
}
|
||||
day_of_week_type day_of_week() const
|
||||
{
|
||||
return dow_;
|
||||
}
|
||||
//! Returns string suitable for use in POSIX time zone string
|
||||
/*! Returns a string formatted as "M4.1.0" ==> 1st Sunday in April. */
|
||||
std::string to_string() const BOOST_OVERRIDE
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << 'M'
|
||||
<< static_cast<int>(month_) << '.'
|
||||
<< 1 << '.'
|
||||
<< static_cast<int>(dow_);
|
||||
return ss.str();
|
||||
}
|
||||
private:
|
||||
month_type month_;
|
||||
day_of_week_type dow_;
|
||||
@@ -152,14 +313,15 @@ namespace date_time {
|
||||
|
||||
|
||||
//! Calculate something like Last Sunday of January
|
||||
/*! Useful generator functor for finding holidays and daylight savings
|
||||
/*! Useful generator functor for finding holidays and daylight savings
|
||||
* Get the last day of the month and then calculate the difference
|
||||
* to the last previous day.
|
||||
* @param date_type A date class that exports day_of_week, month_type, etc.
|
||||
* @tparam date_type A date class that exports day_of_week, month_type, etc.
|
||||
* \ingroup date_alg
|
||||
*/
|
||||
template<class date_type>
|
||||
class last_kday_of_month {
|
||||
class last_kday_of_month : public year_based_generator<date_type>
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::calendar_type calendar_type;
|
||||
typedef typename calendar_type::day_of_week_type day_of_week_type;
|
||||
@@ -168,14 +330,14 @@ namespace date_time {
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
//!Specify the date spec like last 'Sunday' in 'April' spec
|
||||
/*!@param dow The day of week, eg: Sunday, Monday, etc
|
||||
* @param month The month of the year, eg: Jan, Feb, Mar, etc
|
||||
*/
|
||||
last_kday_of_month(day_of_week_type dow, month_type month) :
|
||||
month_(month),
|
||||
* @param m The month of the year, eg: Jan, Feb, Mar, etc
|
||||
*/
|
||||
last_kday_of_month(day_of_week_type dow, month_type m) :
|
||||
month_(m),
|
||||
dow_(dow)
|
||||
{}
|
||||
//! Return a concrete date when provided with a year specific year.
|
||||
date_type get_date(year_type year) const
|
||||
date_type get_date(year_type year) const BOOST_OVERRIDE
|
||||
{
|
||||
date_type d(year, month_, calendar_type::end_of_month_day(year,month_));
|
||||
duration_type one_day(1);
|
||||
@@ -184,23 +346,44 @@ namespace date_time {
|
||||
}
|
||||
return d;
|
||||
}
|
||||
// added for streaming
|
||||
month_type month() const
|
||||
{
|
||||
return month_;
|
||||
}
|
||||
day_of_week_type day_of_week() const
|
||||
{
|
||||
return dow_;
|
||||
}
|
||||
//! Returns string suitable for use in POSIX time zone string
|
||||
/*! Returns a string formatted as "M4.5.0" ==> last Sunday in April. */
|
||||
std::string to_string() const BOOST_OVERRIDE
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << 'M'
|
||||
<< static_cast<int>(month_) << '.'
|
||||
<< 5 << '.'
|
||||
<< static_cast<int>(dow_);
|
||||
return ss.str();
|
||||
}
|
||||
private:
|
||||
month_type month_;
|
||||
day_of_week_type dow_;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
//! Calculate something like "First Sunday after Jan 1,2002
|
||||
/*! Date generator that takes a date and finds kday after
|
||||
*@code
|
||||
typedef boost::date_time::first_kday_after<date> firstkdayafter;
|
||||
firstkdayafter fkaf(Monday);
|
||||
fkaf.get_date(date(2002,Feb,1));
|
||||
@endcode
|
||||
typedef boost::date_time::first_kday_after<date> firstkdayafter;
|
||||
firstkdayafter fkaf(Monday);
|
||||
fkaf.get_date(date(2002,Feb,1));
|
||||
@endcode
|
||||
* \ingroup date_alg
|
||||
*/
|
||||
template<class date_type>
|
||||
class first_kday_after {
|
||||
class first_kday_after
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::calendar_type calendar_type;
|
||||
typedef typename calendar_type::day_of_week_type day_of_week_type;
|
||||
@@ -218,7 +401,11 @@ namespace date_time {
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
// added for streaming
|
||||
day_of_week_type day_of_week() const
|
||||
{
|
||||
return dow_;
|
||||
}
|
||||
private:
|
||||
day_of_week_type dow_;
|
||||
};
|
||||
@@ -226,14 +413,15 @@ namespace date_time {
|
||||
//! Calculate something like "First Sunday before Jan 1,2002
|
||||
/*! Date generator that takes a date and finds kday after
|
||||
*@code
|
||||
typedef boost::date_time::first_kday_before<date> firstkdaybefore;
|
||||
firstkdaybefore fkbf(Monday);
|
||||
fkbf.get_date(date(2002,Feb,1));
|
||||
@endcode
|
||||
typedef boost::date_time::first_kday_before<date> firstkdaybefore;
|
||||
firstkdaybefore fkbf(Monday);
|
||||
fkbf.get_date(date(2002,Feb,1));
|
||||
@endcode
|
||||
* \ingroup date_alg
|
||||
*/
|
||||
template<class date_type>
|
||||
class first_kday_before {
|
||||
class first_kday_before
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::calendar_type calendar_type;
|
||||
typedef typename calendar_type::day_of_week_type day_of_week_type;
|
||||
@@ -251,32 +439,76 @@ namespace date_time {
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
// added for streaming
|
||||
day_of_week_type day_of_week() const
|
||||
{
|
||||
return dow_;
|
||||
}
|
||||
private:
|
||||
day_of_week_type dow_;
|
||||
};
|
||||
|
||||
//! Calculates the number of days until the next weekday
|
||||
/*! Calculates the number of days until the next weekday.
|
||||
* If the date given falls on a Sunday and the given weekday
|
||||
* is Tuesday the result will be 2 days */
|
||||
template<typename date_type, class weekday_type>
|
||||
inline
|
||||
typename date_type::duration_type days_until_weekday(const date_type& d, const weekday_type& wd)
|
||||
{
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
duration_type wks(0);
|
||||
duration_type dd(wd.as_number() - d.day_of_week().as_number());
|
||||
if(dd.is_negative()){
|
||||
wks = duration_type(7);
|
||||
}
|
||||
return dd + wks;
|
||||
}
|
||||
|
||||
//! Calculates the number of days since the previous weekday
|
||||
/*! Calculates the number of days since the previous weekday
|
||||
* If the date given falls on a Sunday and the given weekday
|
||||
* is Tuesday the result will be 5 days. The answer will be a positive
|
||||
* number because Tuesday is 5 days before Sunday, not -5 days before. */
|
||||
template<typename date_type, class weekday_type>
|
||||
inline
|
||||
typename date_type::duration_type days_before_weekday(const date_type& d, const weekday_type& wd)
|
||||
{
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
duration_type wks(0);
|
||||
duration_type dd(wd.as_number() - d.day_of_week().as_number());
|
||||
if(dd.days() > 0){
|
||||
wks = duration_type(7);
|
||||
}
|
||||
// we want a number of days, not an offset. The value returned must
|
||||
// be zero or larger.
|
||||
return (-dd + wks);
|
||||
}
|
||||
|
||||
//! Generates a date object representing the date of the following weekday from the given date
|
||||
/*! Generates a date object representing the date of the following
|
||||
* weekday from the given date. If the date given is 2004-May-9
|
||||
* (a Sunday) and the given weekday is Tuesday then the resulting date
|
||||
* will be 2004-May-11. */
|
||||
template<class date_type, class weekday_type>
|
||||
inline
|
||||
date_type next_weekday(const date_type& d, const weekday_type& wd)
|
||||
{
|
||||
return d + days_until_weekday(d, wd);
|
||||
}
|
||||
|
||||
//! Generates a date object representing the date of the previous weekday from the given date
|
||||
/*! Generates a date object representing the date of the previous
|
||||
* weekday from the given date. If the date given is 2004-May-9
|
||||
* (a Sunday) and the given weekday is Tuesday then the resulting date
|
||||
* will be 2004-May-4. */
|
||||
template<class date_type, class weekday_type>
|
||||
inline
|
||||
date_type previous_weekday(const date_type& d, const weekday_type& wd)
|
||||
{
|
||||
return d - days_before_weekday(d, wd);
|
||||
}
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided as is without express or implied warranty.
|
||||
*
|
||||
*
|
||||
* Author: Jeff Garland (jeff@CrystalClearSoftware.com)
|
||||
* Created: Sun Sep 9 17:20:39 2001
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#ifndef DATE_ITERATOR_HPP___
|
||||
#define DATE_ITERATOR_HPP___
|
||||
/* Copyright (c) 2000 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <iterator>
|
||||
@@ -28,7 +32,7 @@ namespace date_time {
|
||||
template<class date_type>
|
||||
class date_itr_base {
|
||||
// works, but benefit unclear at the moment
|
||||
// class date_itr_base : public std::iterator<std::input_iterator_tag,
|
||||
// class date_itr_base : public std::iterator<std::input_iterator_tag,
|
||||
// date_type, void, void, void>{
|
||||
public:
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
@@ -36,25 +40,31 @@ namespace date_time {
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
|
||||
date_itr_base(date_type d) : current_(d) {}
|
||||
virtual ~date_itr_base() {};
|
||||
date_itr_base& operator++()
|
||||
virtual ~date_itr_base() {}
|
||||
date_itr_base& operator++()
|
||||
{
|
||||
current_ = current_ + get_offset(current_);
|
||||
return *this;
|
||||
};
|
||||
}
|
||||
date_itr_base& operator--()
|
||||
{
|
||||
current_ = current_ + get_neg_offset(current_);
|
||||
return *this;
|
||||
}
|
||||
virtual duration_type get_offset(const date_type& current) const=0;
|
||||
date_type operator*() {return current_;};
|
||||
date_type* operator->() {return ¤t_;};
|
||||
bool operator< (const date_type& d) {return current_ < d;}
|
||||
bool operator<= (const date_type& d) {return current_ <= d;}
|
||||
bool operator> (const date_type& d) {return current_ > d;}
|
||||
bool operator>= (const date_type& d) {return current_ >= d;}
|
||||
bool operator== (const date_type& d) {return current_ == d;}
|
||||
bool operator!= (const date_type& d) {return current_ != d;}
|
||||
virtual duration_type get_neg_offset(const date_type& current) const=0;
|
||||
const date_type& operator*() const {return current_;}
|
||||
const date_type* operator->() const {return ¤t_;}
|
||||
bool operator< (const date_type& d) const {return current_ < d;}
|
||||
bool operator<= (const date_type& d) const {return current_ <= d;}
|
||||
bool operator> (const date_type& d) const {return current_ > d;}
|
||||
bool operator>= (const date_type& d) const {return current_ >= d;}
|
||||
bool operator== (const date_type& d) const {return current_ == d;}
|
||||
bool operator!= (const date_type& d) const {return current_ != d;}
|
||||
private:
|
||||
date_type current_;
|
||||
};
|
||||
|
||||
|
||||
//! Overrides the base date iterator providing hook for functors
|
||||
/*
|
||||
* <b>offset_functor</b>
|
||||
@@ -67,32 +77,25 @@ namespace date_time {
|
||||
class date_itr : public date_itr_base<date_type> {
|
||||
public:
|
||||
typedef typename date_type::duration_type duration_type;
|
||||
date_itr(date_type d, int factor=1) :
|
||||
date_itr_base<date_type>(d),
|
||||
of_(factor)
|
||||
date_itr(date_type d, int factor=1) :
|
||||
date_itr_base<date_type>(d),
|
||||
of_(factor)
|
||||
{}
|
||||
private:
|
||||
virtual duration_type get_offset(const date_type& current) const
|
||||
{
|
||||
return of_.get_offset(current);
|
||||
}
|
||||
private:
|
||||
virtual duration_type get_neg_offset(const date_type& current) const
|
||||
{
|
||||
return of_.get_neg_offset(current);
|
||||
}
|
||||
offset_functor of_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
/* Copyright (c) 2000, 2001
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
#ifndef DATE_TIME_DATE_NAMES_PUT_HPP___
|
||||
#define DATE_TIME_DATE_NAMES_PUT_HPP___
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002-2005 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
|
||||
#include "boost/date_time/locale_config.hpp" // set BOOST_DATE_TIME_NO_LOCALE
|
||||
#include <boost/date_time/locale_config.hpp> // set BOOST_DATE_TIME_NO_LOCALE
|
||||
|
||||
#ifndef BOOST_DATE_TIME_NO_LOCALE
|
||||
|
||||
#include "boost/date_time/special_defs.hpp"
|
||||
#include "boost/date_time/date_defs.hpp"
|
||||
#include "boost/date_time/parse_format_base.hpp"
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/special_defs.hpp>
|
||||
#include <boost/date_time/date_defs.hpp>
|
||||
#include <boost/date_time/parse_format_base.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <locale>
|
||||
|
||||
|
||||
@@ -22,22 +28,22 @@ namespace date_time {
|
||||
//! Output facet base class for gregorian dates.
|
||||
/*! This class is a base class for date facets used to localize the
|
||||
* names of months and the names of days in the week.
|
||||
*
|
||||
*
|
||||
* Requirements of Config
|
||||
* - define an enumeration month_enum that enumerates the months.
|
||||
* - define an enumeration month_enum that enumerates the months.
|
||||
* The enumeration should be '1' based eg: Jan==1
|
||||
* - define as_short_string and as_long_string
|
||||
*
|
||||
* (see langer & kreft p334).
|
||||
*
|
||||
*
|
||||
*/
|
||||
template<class Config,
|
||||
class charT = char,
|
||||
class charT = char,
|
||||
class OutputIterator = std::ostreambuf_iterator<charT> >
|
||||
class date_names_put : public std::locale::facet
|
||||
class BOOST_SYMBOL_VISIBLE date_names_put : public std::locale::facet
|
||||
{
|
||||
public:
|
||||
date_names_put() {};
|
||||
date_names_put() {}
|
||||
typedef OutputIterator iter_type;
|
||||
typedef typename Config::month_type month_type;
|
||||
typedef typename Config::month_enum month_enum;
|
||||
@@ -45,8 +51,16 @@ namespace date_time {
|
||||
typedef typename Config::special_value_enum special_value_enum;
|
||||
//typedef typename Config::format_type format_type;
|
||||
typedef std::basic_string<charT> string_type;
|
||||
typedef charT char_type;
|
||||
static const char_type default_special_value_names[3][17];
|
||||
static const char_type separator[2];
|
||||
|
||||
static std::locale::id id;
|
||||
|
||||
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
|
||||
std::locale::id& __get_id (void) const { return id; }
|
||||
#endif
|
||||
|
||||
void put_special_value(iter_type& oitr, special_value_enum sv) const
|
||||
{
|
||||
do_put_special_value(oitr, sv);
|
||||
@@ -101,41 +115,29 @@ namespace date_time {
|
||||
virtual void do_put_month_short(iter_type& oitr, month_enum moy) const
|
||||
{
|
||||
month_type gm(moy);
|
||||
put_string(oitr, gm.as_short_string());
|
||||
charT c = '\0';
|
||||
put_string(oitr, gm.as_short_string(c));
|
||||
}
|
||||
//! Default facet implementation uses month_type defaults
|
||||
virtual void do_put_month_long(iter_type& oitr,
|
||||
virtual void do_put_month_long(iter_type& oitr,
|
||||
month_enum moy) const
|
||||
{
|
||||
month_type gm(moy);
|
||||
put_string(oitr, gm.as_long_string());
|
||||
charT c = '\0';
|
||||
put_string(oitr, gm.as_long_string(c));
|
||||
}
|
||||
//! Default facet implementation for special value types
|
||||
virtual void do_put_special_value(iter_type& oitr, special_value_enum sv) const
|
||||
{
|
||||
switch (sv) {
|
||||
case not_a_date_time:
|
||||
{
|
||||
put_string(oitr, "not-a-date-time");
|
||||
break;
|
||||
}
|
||||
case pos_infin:
|
||||
{
|
||||
put_string(oitr, "+infinity");
|
||||
break;
|
||||
}
|
||||
case neg_infin:
|
||||
{
|
||||
put_string(oitr, "-infinity");
|
||||
break;
|
||||
}
|
||||
default: {} //quiet compilers that want all cases covered here (eg: gcc 3.1)
|
||||
if(sv <= 2) { // only output not_a_date_time, neg_infin, or pos_infin
|
||||
string_type s(default_special_value_names[sv]);
|
||||
put_string(oitr, s);
|
||||
}
|
||||
}
|
||||
virtual void do_put_weekday_short(iter_type& oitr, weekday_enum wd) const
|
||||
virtual void do_put_weekday_short(iter_type&, weekday_enum) const
|
||||
{
|
||||
}
|
||||
virtual void do_put_weekday_long(iter_type& oitr, weekday_enum wd) const
|
||||
virtual void do_put_weekday_long(iter_type&, weekday_enum) const
|
||||
{
|
||||
}
|
||||
virtual bool do_has_date_sep_chars() const
|
||||
@@ -144,19 +146,22 @@ namespace date_time {
|
||||
}
|
||||
virtual void do_year_sep_char(iter_type& oitr) const
|
||||
{
|
||||
put_string(oitr, "-");
|
||||
string_type s(separator);
|
||||
put_string(oitr, s);
|
||||
}
|
||||
//! char between year-month
|
||||
virtual void do_month_sep_char(iter_type& oitr) const
|
||||
{
|
||||
put_string(oitr, "-");
|
||||
string_type s(separator);
|
||||
put_string(oitr, s);
|
||||
}
|
||||
//! Char to separate month-day
|
||||
virtual void do_day_sep_char(iter_type& oitr) const
|
||||
{
|
||||
put_string(oitr, "-");
|
||||
string_type s(separator); //put in '-'
|
||||
put_string(oitr, s);
|
||||
}
|
||||
//! Default for date order
|
||||
//! Default for date order
|
||||
virtual ymd_order_spec do_date_order() const
|
||||
{
|
||||
return ymd_order_iso;
|
||||
@@ -166,33 +171,53 @@ namespace date_time {
|
||||
{
|
||||
return month_as_short_string;
|
||||
}
|
||||
void put_string(iter_type& oi, const char* const s) const
|
||||
void put_string(iter_type& oi, const charT* const s) const
|
||||
{
|
||||
string_type s1(s);
|
||||
string_type s1(boost::lexical_cast<string_type>(s));
|
||||
typename string_type::iterator si,end;
|
||||
for (si=s1.begin(), end=s1.end(); si!=end; si++, oi++) {
|
||||
*oi = *si;
|
||||
}
|
||||
}
|
||||
void put_string(iter_type& oi, const string_type& s1) const
|
||||
{
|
||||
typename string_type::const_iterator si,end;
|
||||
for (si=s1.begin(), end=s1.end(); si!=end; si++, oi++) {
|
||||
*oi = *si;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//! Generate storage location for a std::locale::id
|
||||
|
||||
template<class Config, class charT, class OutputIterator>
|
||||
const typename date_names_put<Config, charT, OutputIterator>::char_type
|
||||
date_names_put<Config, charT, OutputIterator>::default_special_value_names[3][17] = {
|
||||
{'n','o','t','-','a','-','d','a','t','e','-','t','i','m','e'},
|
||||
{'-','i','n','f','i','n','i','t','y'},
|
||||
{'+','i','n','f','i','n','i','t','y'} };
|
||||
|
||||
template<class Config, class charT, class OutputIterator>
|
||||
const typename date_names_put<Config, charT, OutputIterator>::char_type
|
||||
date_names_put<Config, charT, OutputIterator>::separator[2] =
|
||||
{'-', '\0'} ;
|
||||
|
||||
|
||||
//! Generate storage location for a std::locale::id
|
||||
template<class Config, class charT, class OutputIterator>
|
||||
std::locale::id date_names_put<Config, charT, OutputIterator>::id;
|
||||
|
||||
//! An date name output facet that takes an array of char* to define strings
|
||||
//! A date name output facet that takes an array of char* to define strings
|
||||
template<class Config,
|
||||
class charT = char,
|
||||
class charT = char,
|
||||
class OutputIterator = std::ostreambuf_iterator<charT> >
|
||||
class all_date_names_put : public date_names_put<Config, charT, OutputIterator>
|
||||
class BOOST_SYMBOL_VISIBLE all_date_names_put : public date_names_put<Config, charT, OutputIterator>
|
||||
{
|
||||
public:
|
||||
all_date_names_put(const char* const month_short_names[],
|
||||
const char* const month_long_names[],
|
||||
const char* const special_value_names[],
|
||||
const char* const weekday_short_names[],
|
||||
const char* const weekday_long_names[],
|
||||
char separator_char = '-',
|
||||
all_date_names_put(const charT* const month_short_names[],
|
||||
const charT* const month_long_names[],
|
||||
const charT* const special_value_names[],
|
||||
const charT* const weekday_short_names[],
|
||||
const charT* const weekday_long_names[],
|
||||
charT separator_char = '-',
|
||||
ymd_order_spec order_spec = ymd_order_iso,
|
||||
month_format_spec month_format = month_as_short_string) :
|
||||
month_short_names_(month_short_names),
|
||||
@@ -206,45 +231,66 @@ namespace date_time {
|
||||
separator_char_[0] = separator_char;
|
||||
separator_char_[1] = '\0';
|
||||
|
||||
};
|
||||
}
|
||||
typedef OutputIterator iter_type;
|
||||
typedef typename Config::month_enum month_enum;
|
||||
typedef typename Config::weekday_enum weekday_enum;
|
||||
typedef typename Config::special_value_enum special_value_enum;
|
||||
|
||||
const charT* const* get_short_month_names() const
|
||||
{
|
||||
return month_short_names_;
|
||||
}
|
||||
const charT* const* get_long_month_names() const
|
||||
{
|
||||
return month_long_names_;
|
||||
}
|
||||
const charT* const* get_special_value_names() const
|
||||
{
|
||||
return special_value_names_;
|
||||
}
|
||||
const charT* const* get_short_weekday_names()const
|
||||
{
|
||||
return weekday_short_names_;
|
||||
}
|
||||
const charT* const* get_long_weekday_names()const
|
||||
{
|
||||
return weekday_long_names_;
|
||||
}
|
||||
|
||||
protected:
|
||||
//! Generic facet that takes array of chars
|
||||
virtual void do_put_month_short(iter_type& oitr, month_enum moy) const
|
||||
{
|
||||
put_string(oitr, month_short_names_[moy-1]);
|
||||
this->put_string(oitr, month_short_names_[moy-1]);
|
||||
}
|
||||
//! Long month names
|
||||
//! Long month names
|
||||
virtual void do_put_month_long(iter_type& oitr, month_enum moy) const
|
||||
{
|
||||
put_string(oitr, month_long_names_[moy-1]);
|
||||
this->put_string(oitr, month_long_names_[moy-1]);
|
||||
}
|
||||
//! Special values names
|
||||
virtual void do_put_special_value(iter_type& oitr, special_value_enum sv) const
|
||||
{
|
||||
put_string(oitr, special_value_names_[sv]);
|
||||
this->put_string(oitr, special_value_names_[sv]);
|
||||
}
|
||||
virtual void do_put_weekday_short(iter_type& oitr, weekday_enum wd) const
|
||||
{
|
||||
put_string(oitr, weekday_short_names_[wd]);
|
||||
this->put_string(oitr, weekday_short_names_[wd]);
|
||||
}
|
||||
virtual void do_put_weekday_long(iter_type& oitr, weekday_enum wd) const
|
||||
{
|
||||
put_string(oitr, weekday_long_names_[wd]);
|
||||
this->put_string(oitr, weekday_long_names_[wd]);
|
||||
}
|
||||
//! char between year-month
|
||||
virtual void do_month_sep_char(iter_type& oitr) const
|
||||
{
|
||||
put_string(oitr, separator_char_);
|
||||
this->put_string(oitr, separator_char_);
|
||||
}
|
||||
//! Char to separate month-day
|
||||
virtual void do_day_sep_char(iter_type& oitr) const
|
||||
{
|
||||
put_string(oitr, separator_char_);
|
||||
this->put_string(oitr, separator_char_);
|
||||
}
|
||||
//! Set the date ordering
|
||||
virtual ymd_order_spec do_date_order() const
|
||||
@@ -258,29 +304,18 @@ namespace date_time {
|
||||
}
|
||||
|
||||
private:
|
||||
const char* const* month_short_names_;
|
||||
const char* const* month_long_names_;
|
||||
const char* const* special_value_names_;
|
||||
const char* const* weekday_short_names_;
|
||||
const char* const* weekday_long_names_;
|
||||
char separator_char_[2];
|
||||
const charT* const* month_short_names_;
|
||||
const charT* const* month_long_names_;
|
||||
const charT* const* special_value_names_;
|
||||
const charT* const* weekday_short_names_;
|
||||
const charT* const* weekday_long_names_;
|
||||
charT separator_char_[2];
|
||||
ymd_order_spec order_spec_;
|
||||
month_format_spec month_format_spec_;
|
||||
month_format_spec month_format_spec_;
|
||||
};
|
||||
|
||||
} } //namespace boost::date_time
|
||||
|
||||
#endif //BOOST_NO_STD_LOCALE
|
||||
|
||||
/* Copyright (c) 2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
#endif
|
||||
|
||||
@@ -1,103 +1,342 @@
|
||||
|
||||
#ifndef _DATE_TIME_DATE_PARSING_HPP___
|
||||
#define _DATE_TIME_DATE_PARSING_HPP___
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include "boost/tokenizer.hpp"
|
||||
#include "boost/lexical_cast.hpp"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <boost/tokenizer.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
#include <boost/date_time/parse_format_base.hpp>
|
||||
#include <boost/date_time/period.hpp>
|
||||
|
||||
#if defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
#include <cctype> // ::tolower(int)
|
||||
#else
|
||||
#include <locale> // std::tolower(char, locale)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace date_time {
|
||||
|
||||
|
||||
//! Generic function to parse a delimited date (eg: 2002-02-10)
|
||||
template<class date_type>
|
||||
date_type
|
||||
parse_date(const std::string& s)
|
||||
//! A function to replace the std::transform( , , ,tolower) construct
|
||||
/*! This function simply takes a string, and changes all the characters
|
||||
* in that string to lowercase (according to the default system locale).
|
||||
* In the event that a compiler does not support locales, the old
|
||||
* C style tolower() is used.
|
||||
*/
|
||||
inline
|
||||
std::string
|
||||
convert_to_lower(std::string inp)
|
||||
{
|
||||
typedef typename date_type::year_type year_type;
|
||||
int pos = 0;
|
||||
typename date_type::ymd_type ymd(year_type::min(),1,1);
|
||||
boost::tokenizer<boost::char_delimiters_separator<char> > tok(s);
|
||||
for(boost::tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg){
|
||||
int i = boost::lexical_cast<int>(*beg);
|
||||
switch(pos) {
|
||||
case 0: ymd.year = i; break;
|
||||
case 1: ymd.month = i; break;
|
||||
case 2: ymd.day = i; break;
|
||||
};
|
||||
pos++;
|
||||
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
const std::locale loc(std::locale::classic());
|
||||
#endif
|
||||
std::string::size_type i = 0, n = inp.length();
|
||||
for (; i < n; ++i) {
|
||||
inp[i] =
|
||||
#if defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
static_cast<char>(std::tolower(inp[i]));
|
||||
#else
|
||||
// tolower and others were brought in to std for borland >= v564
|
||||
// in compiler_config.hpp
|
||||
std::tolower(inp[i], loc);
|
||||
#endif
|
||||
}
|
||||
return date_type(ymd);
|
||||
return inp;
|
||||
}
|
||||
|
||||
//! Generic function to parse undelimited date (eg: 20020201)
|
||||
template<class date_type>
|
||||
date_type
|
||||
parse_undelimited_date(const std::string& s)
|
||||
{
|
||||
int offsets[] = {4,2,2};
|
||||
int pos = 0;
|
||||
typedef typename date_type::year_type year_type;
|
||||
typename date_type::ymd_type ymd(year_type::min(),1,1);
|
||||
boost::offset_separator osf(offsets, offsets+3);
|
||||
boost::tokenizer<boost::offset_separator> tok(s, osf);
|
||||
for(boost::tokenizer<boost::offset_separator>::iterator ti=tok.begin(); ti!=tok.end();++ti){
|
||||
int i = boost::lexical_cast<int>(*ti);
|
||||
// std::cout << i << std::endl;
|
||||
switch(pos) {
|
||||
case 0: ymd.year = i; break;
|
||||
case 1: ymd.month = i; break;
|
||||
case 2: ymd.day = i; break;
|
||||
};
|
||||
pos++;
|
||||
}
|
||||
return date_type(ymd);
|
||||
}
|
||||
|
||||
|
||||
template<class date_type>
|
||||
date_type
|
||||
parse_date2(const std::string& s)
|
||||
{
|
||||
//using namespace boost;
|
||||
int pos = 0;
|
||||
typedef typename date_type::year_type year_type;
|
||||
typename date_type::ymd_type ymd(year_type::min(),1,1);
|
||||
boost::char_delimiters_separator<char> delim("DT");
|
||||
boost::tokenizer<boost::char_delimiters_separator<char> > tok(s);
|
||||
for(boost::tokenizer<>::iterator beg=tok.begin(); beg!=tok.end();++beg){
|
||||
int i = boost::lexical_cast<int>(*beg);
|
||||
switch(pos) {
|
||||
case 0: ymd.year = i; break;
|
||||
case 1: ymd.month = i; break;
|
||||
case 2: ymd.day = i; break;
|
||||
};
|
||||
pos++;
|
||||
//! Helper function for parse_date.
|
||||
template<class month_type>
|
||||
inline unsigned short
|
||||
month_str_to_ushort(std::string const& s) {
|
||||
if((s.at(0) >= '0') && (s.at(0) <= '9')) {
|
||||
return boost::lexical_cast<unsigned short>(s);
|
||||
}
|
||||
else {
|
||||
std::string str = convert_to_lower(s);
|
||||
//c++98 support
|
||||
#if defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||
static std::map<std::string, unsigned short> month_map;
|
||||
typedef std::map<std::string, unsigned short>::value_type vtype;
|
||||
if( month_map.empty() ) {
|
||||
month_map.insert( vtype("jan", static_cast<unsigned short>(1)) );
|
||||
month_map.insert( vtype("january", static_cast<unsigned short>(1)) );
|
||||
month_map.insert( vtype("feb", static_cast<unsigned short>(2)) );
|
||||
month_map.insert( vtype("february", static_cast<unsigned short>(2)) );
|
||||
month_map.insert( vtype("mar", static_cast<unsigned short>(3)) );
|
||||
month_map.insert( vtype("march", static_cast<unsigned short>(3)) );
|
||||
month_map.insert( vtype("apr", static_cast<unsigned short>(4)) );
|
||||
month_map.insert( vtype("april", static_cast<unsigned short>(4)) );
|
||||
month_map.insert( vtype("may", static_cast<unsigned short>(5)) );
|
||||
month_map.insert( vtype("jun", static_cast<unsigned short>(6)) );
|
||||
month_map.insert( vtype("june", static_cast<unsigned short>(6)) );
|
||||
month_map.insert( vtype("jul", static_cast<unsigned short>(7)) );
|
||||
month_map.insert( vtype("july", static_cast<unsigned short>(7)) );
|
||||
month_map.insert( vtype("aug", static_cast<unsigned short>(8)) );
|
||||
month_map.insert( vtype("august", static_cast<unsigned short>(8)) );
|
||||
month_map.insert( vtype("sep", static_cast<unsigned short>(9)) );
|
||||
month_map.insert( vtype("september", static_cast<unsigned short>(9)) );
|
||||
month_map.insert( vtype("oct", static_cast<unsigned short>(10)) );
|
||||
month_map.insert( vtype("october", static_cast<unsigned short>(10)) );
|
||||
month_map.insert( vtype("nov", static_cast<unsigned short>(11)) );
|
||||
month_map.insert( vtype("november", static_cast<unsigned short>(11)) );
|
||||
month_map.insert( vtype("dec", static_cast<unsigned short>(12)) );
|
||||
month_map.insert( vtype("december", static_cast<unsigned short>(12)) );
|
||||
}
|
||||
#else //c+11 and beyond
|
||||
static std::map<std::string, unsigned short> month_map =
|
||||
{ { "jan", static_cast<unsigned short>(1) }, { "january", static_cast<unsigned short>(1) },
|
||||
{ "feb", static_cast<unsigned short>(2) }, { "february", static_cast<unsigned short>(2) },
|
||||
{ "mar", static_cast<unsigned short>(3) }, { "march", static_cast<unsigned short>(3) },
|
||||
{ "apr", static_cast<unsigned short>(4) }, { "april", static_cast<unsigned short>(4) },
|
||||
{ "may", static_cast<unsigned short>(5) },
|
||||
{ "jun", static_cast<unsigned short>(6) }, { "june", static_cast<unsigned short>(6) },
|
||||
{ "jul", static_cast<unsigned short>(7) }, { "july", static_cast<unsigned short>(7) },
|
||||
{ "aug", static_cast<unsigned short>(8) }, { "august", static_cast<unsigned short>(8) },
|
||||
{ "sep", static_cast<unsigned short>(9) }, { "september", static_cast<unsigned short>(9) },
|
||||
{ "oct", static_cast<unsigned short>(10) }, { "october", static_cast<unsigned short>(10)},
|
||||
{ "nov", static_cast<unsigned short>(11) }, { "november", static_cast<unsigned short>(11)},
|
||||
{ "dec", static_cast<unsigned short>(12) }, { "december", static_cast<unsigned short>(12)}
|
||||
};
|
||||
#endif
|
||||
std::map<std::string, unsigned short>::const_iterator mitr = month_map.find( str );
|
||||
if ( mitr != month_map.end() ) {
|
||||
return mitr->second;
|
||||
}
|
||||
}
|
||||
return 13; // intentionally out of range - name not found
|
||||
}
|
||||
return date_type(ymd);
|
||||
}
|
||||
|
||||
|
||||
//! Generic function to parse a delimited date (eg: 2002-02-10)
|
||||
/*! Accepted formats are: "2003-02-10" or " 2003-Feb-10" or
|
||||
* "2003-Feburary-10"
|
||||
* The order in which the Month, Day, & Year appear in the argument
|
||||
* string can be accomodated by passing in the appropriate ymd_order_spec
|
||||
*/
|
||||
template<class date_type>
|
||||
date_type
|
||||
parse_date(const std::string& s, int order_spec = ymd_order_iso) {
|
||||
std::string spec_str;
|
||||
if(order_spec == ymd_order_iso) {
|
||||
spec_str = "ymd";
|
||||
}
|
||||
else if(order_spec == ymd_order_dmy) {
|
||||
spec_str = "dmy";
|
||||
}
|
||||
else { // (order_spec == ymd_order_us)
|
||||
spec_str = "mdy";
|
||||
}
|
||||
|
||||
typedef typename date_type::month_type month_type;
|
||||
unsigned pos = 0;
|
||||
unsigned short year(0), month(0), day(0);
|
||||
typedef typename std::basic_string<char>::traits_type traits_type;
|
||||
typedef boost::char_separator<char, traits_type> char_separator_type;
|
||||
typedef boost::tokenizer<char_separator_type,
|
||||
std::basic_string<char>::const_iterator,
|
||||
std::basic_string<char> > tokenizer;
|
||||
typedef boost::tokenizer<char_separator_type,
|
||||
std::basic_string<char>::const_iterator,
|
||||
std::basic_string<char> >::iterator tokenizer_iterator;
|
||||
// may need more delimiters, these work for the regression tests
|
||||
const char sep_char[] = {',','-','.',' ','/','\0'};
|
||||
char_separator_type sep(sep_char);
|
||||
tokenizer tok(s,sep);
|
||||
for(tokenizer_iterator beg=tok.begin();
|
||||
beg!=tok.end() && pos < spec_str.size();
|
||||
++beg, ++pos) {
|
||||
switch(spec_str.at(pos)) {
|
||||
case 'y':
|
||||
{
|
||||
year = boost::lexical_cast<unsigned short>(*beg);
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
{
|
||||
month = month_str_to_ushort<month_type>(*beg);
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
{
|
||||
day = boost::lexical_cast<unsigned short>(*beg);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
} //switch
|
||||
}
|
||||
return date_type(year, month, day);
|
||||
}
|
||||
|
||||
//! Generic function to parse undelimited date (eg: 20020201)
|
||||
template<class date_type>
|
||||
date_type
|
||||
parse_undelimited_date(const std::string& s) {
|
||||
int offsets[] = {4,2,2};
|
||||
int pos = 0;
|
||||
//typename date_type::ymd_type ymd((year_type::min)(),1,1);
|
||||
unsigned short y = 0, m = 0, d = 0;
|
||||
|
||||
/* The two bool arguments state that parsing will not wrap
|
||||
* (only the first 8 characters will be parsed) and partial
|
||||
* strings will not be parsed.
|
||||
* Ex:
|
||||
* "2005121" will parse 2005 & 12, but not the "1" */
|
||||
boost::offset_separator osf(offsets, offsets+3, false, false);
|
||||
|
||||
typedef typename boost::tokenizer<boost::offset_separator,
|
||||
std::basic_string<char>::const_iterator,
|
||||
std::basic_string<char> > tokenizer_type;
|
||||
tokenizer_type tok(s, osf);
|
||||
for(typename tokenizer_type::iterator ti=tok.begin(); ti!=tok.end();++ti) {
|
||||
unsigned short i = boost::lexical_cast<unsigned short>(*ti);
|
||||
switch(pos) {
|
||||
case 0: y = i; break;
|
||||
case 1: m = i; break;
|
||||
case 2: d = i; break;
|
||||
default: break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return date_type(y,m,d);
|
||||
}
|
||||
|
||||
//! Helper function for 'date gregorian::from_stream()'
|
||||
/*! Creates a string from the iterators that reference the
|
||||
* begining & end of a char[] or string. All elements are
|
||||
* used in output string */
|
||||
template<class date_type, class iterator_type>
|
||||
inline
|
||||
date_type
|
||||
from_stream_type(iterator_type& beg,
|
||||
iterator_type const& end,
|
||||
char)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
while(beg != end) {
|
||||
ss << *beg++;
|
||||
}
|
||||
return parse_date<date_type>(ss.str());
|
||||
}
|
||||
|
||||
//! Helper function for 'date gregorian::from_stream()'
|
||||
/*! Returns the first string found in the stream referenced by the
|
||||
* begining & end iterators */
|
||||
template<class date_type, class iterator_type>
|
||||
inline
|
||||
date_type
|
||||
from_stream_type(iterator_type& beg,
|
||||
iterator_type const& /* end */,
|
||||
std::string const&)
|
||||
{
|
||||
return parse_date<date_type>(*beg);
|
||||
}
|
||||
|
||||
/* I believe the wchar stuff would be best elsewhere, perhaps in
|
||||
* parse_date<>()? In the mean time this gets us started... */
|
||||
//! Helper function for 'date gregorian::from_stream()'
|
||||
/*! Creates a string from the iterators that reference the
|
||||
* begining & end of a wstring. All elements are
|
||||
* used in output string */
|
||||
template<class date_type, class iterator_type>
|
||||
inline
|
||||
date_type from_stream_type(iterator_type& beg,
|
||||
iterator_type const& end,
|
||||
wchar_t)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
std::locale loc;
|
||||
std::ctype<wchar_t> const& fac = std::use_facet<std::ctype<wchar_t> >(loc);
|
||||
while(beg != end) {
|
||||
ss << fac.narrow(*beg++, 'X'); // 'X' will cause exception to be thrown
|
||||
}
|
||||
#else
|
||||
while(beg != end) {
|
||||
char c = 'X'; // 'X' will cause exception to be thrown
|
||||
const wchar_t wc = *beg++;
|
||||
if (wc >= 0 && wc <= 127)
|
||||
c = static_cast< char >(wc);
|
||||
ss << c;
|
||||
}
|
||||
#endif
|
||||
return parse_date<date_type>(ss.str());
|
||||
}
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
//! Helper function for 'date gregorian::from_stream()'
|
||||
/*! Creates a string from the first wstring found in the stream
|
||||
* referenced by the begining & end iterators */
|
||||
template<class date_type, class iterator_type>
|
||||
inline
|
||||
date_type
|
||||
from_stream_type(iterator_type& beg,
|
||||
iterator_type const& /* end */,
|
||||
std::wstring const&) {
|
||||
std::wstring ws = *beg;
|
||||
std::ostringstream ss;
|
||||
std::wstring::iterator wsb = ws.begin(), wse = ws.end();
|
||||
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
|
||||
std::locale loc;
|
||||
std::ctype<wchar_t> const& fac = std::use_facet<std::ctype<wchar_t> >(loc);
|
||||
while(wsb != wse) {
|
||||
ss << fac.narrow(*wsb++, 'X'); // 'X' will cause exception to be thrown
|
||||
}
|
||||
#else
|
||||
while(wsb != wse) {
|
||||
char c = 'X'; // 'X' will cause exception to be thrown
|
||||
const wchar_t wc = *wsb++;
|
||||
if (wc >= 0 && wc <= 127)
|
||||
c = static_cast< char >(wc);
|
||||
ss << c;
|
||||
}
|
||||
#endif
|
||||
return parse_date<date_type>(ss.str());
|
||||
}
|
||||
#endif // BOOST_NO_STD_WSTRING
|
||||
#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
|
||||
// This function cannot be compiled with MSVC 6.0 due to internal compiler shorcomings
|
||||
#else
|
||||
//! function called by wrapper functions: date_period_from_(w)string()
|
||||
template<class date_type, class charT>
|
||||
period<date_type, typename date_type::duration_type>
|
||||
from_simple_string_type(const std::basic_string<charT>& s){
|
||||
typedef typename std::basic_string<charT>::traits_type traits_type;
|
||||
typedef typename boost::char_separator<charT, traits_type> char_separator;
|
||||
typedef typename boost::tokenizer<char_separator,
|
||||
typename std::basic_string<charT>::const_iterator,
|
||||
std::basic_string<charT> > tokenizer;
|
||||
const charT sep_list[4] = {'[','/',']','\0'};
|
||||
char_separator sep(sep_list);
|
||||
tokenizer tokens(s, sep);
|
||||
typename tokenizer::iterator tok_it = tokens.begin();
|
||||
std::basic_string<charT> date_string = *tok_it;
|
||||
// get 2 string iterators and generate a date from them
|
||||
typename std::basic_string<charT>::iterator date_string_start = date_string.begin(),
|
||||
date_string_end = date_string.end();
|
||||
typedef typename std::iterator_traits<typename std::basic_string<charT>::iterator>::value_type value_type;
|
||||
date_type d1 = from_stream_type<date_type>(date_string_start, date_string_end, value_type());
|
||||
date_string = *(++tok_it); // next token
|
||||
date_string_start = date_string.begin(), date_string_end = date_string.end();
|
||||
date_type d2 = from_stream_type<date_type>(date_string_start, date_string_end, value_type());
|
||||
return period<date_type, typename date_type::duration_type>(d1, d2);
|
||||
}
|
||||
#endif
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
|
||||
|
||||
/* Copyright (c) 2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#ifndef DATE_TIME_DST_RULES_HPP__
|
||||
#define DATE_TIME_DST_RULES_HPP__
|
||||
/* Copyright (c) 2002 CrystalClear Software, Inc.
|
||||
* Disclaimer & Full Copyright at end of file
|
||||
* Author: Jeff Garland
|
||||
|
||||
/* Copyright (c) 2002,2003, 2007 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
/*! @file dst_rules.hpp
|
||||
@@ -17,12 +21,12 @@
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
enum time_is_dst_result {is_not_in_dst, is_in_dst,
|
||||
enum time_is_dst_result {is_not_in_dst, is_in_dst,
|
||||
ambiguous, invalid_time_label};
|
||||
|
||||
|
||||
//! Dynamic class used to caluclate dst transition information
|
||||
template<class date_type_,
|
||||
template<class date_type_,
|
||||
class time_duration_type_>
|
||||
class dst_calculator
|
||||
{
|
||||
@@ -33,14 +37,14 @@ namespace boost {
|
||||
//! Check the local time offset when on dst start day
|
||||
/*! On this dst transition, the time label between
|
||||
* the transition boundary and the boudary + the offset
|
||||
* are invalid times. If before the boundary then still
|
||||
* not in dst.
|
||||
* are invalid times. If before the boundary then still
|
||||
* not in dst.
|
||||
*@param time_of_day Time offset in the day for the local time
|
||||
*@param dst_start_offset_minutes Local day offset for start of dst
|
||||
*@param dst_length_minutes Number of minutes to adjust clock forward
|
||||
*@retval status of time label w.r.t. dst
|
||||
*/
|
||||
static time_is_dst_result
|
||||
static time_is_dst_result
|
||||
process_local_dst_start_day(const time_duration_type& time_of_day,
|
||||
unsigned int dst_start_offset_minutes,
|
||||
long dst_length_minutes)
|
||||
@@ -53,19 +57,19 @@ namespace boost {
|
||||
if (time_of_day >= time_duration_type(0,offset,0)) {
|
||||
return is_in_dst;
|
||||
}
|
||||
return invalid_time_label;
|
||||
return invalid_time_label;
|
||||
}
|
||||
|
||||
//! Check the local time offset when on the last day of dst
|
||||
/*! This is the calculation for the DST end day. On that day times
|
||||
* prior to the conversion time - dst_length (1 am in US) are still
|
||||
* in dst. Times between the above and the switch time are
|
||||
* prior to the conversion time - dst_length (1 am in US) are still
|
||||
* in dst. Times between the above and the switch time are
|
||||
* ambiguous. Times after the start_offset are not in dst.
|
||||
*@param time_of_day Time offset in the day for the local time
|
||||
*@param dst_end_offset_minutes Local time of day for end of dst
|
||||
*@retval status of time label w.r.t. dst
|
||||
*/
|
||||
static time_is_dst_result
|
||||
static time_is_dst_result
|
||||
process_local_dst_end_day(const time_duration_type& time_of_day,
|
||||
unsigned int dst_end_offset_minutes,
|
||||
long dst_length_minutes)
|
||||
@@ -82,20 +86,54 @@ namespace boost {
|
||||
}
|
||||
|
||||
//! Calculates if the given local time is dst or not
|
||||
/*! Determines if the time is really in DST or not. Also checks for
|
||||
/*! Determines if the time is really in DST or not. Also checks for
|
||||
* invalid and ambiguous.
|
||||
* @param current_day The day to check for dst
|
||||
* @param time_of_day Time offset within the day to check
|
||||
* @param time_of_day Time offset within the day to check
|
||||
* @param dst_start_day Starting day of dst for the given locality
|
||||
* @param dst_start_offset_minutes Offset within day for dst
|
||||
* @param dst_start_offset Time offset within day for dst boundary
|
||||
* @param dst_end_day Ending day of dst for the given locality
|
||||
* @param dst_end_offset Time offset within day given in dst for dst boundary
|
||||
* @param dst_length_minutes length of dst adjusment
|
||||
* @retval The time is either ambiguous, invalid, in dst, or not in dst
|
||||
*/
|
||||
static time_is_dst_result
|
||||
local_is_dst(const date_type& current_day,
|
||||
const time_duration_type& time_of_day,
|
||||
const date_type& dst_start_day,
|
||||
const time_duration_type& dst_start_offset,
|
||||
const date_type& dst_end_day,
|
||||
const time_duration_type& dst_end_offset,
|
||||
const time_duration_type& dst_length)
|
||||
{
|
||||
unsigned int start_minutes = static_cast<unsigned>(
|
||||
dst_start_offset.hours() * 60 + dst_start_offset.minutes());
|
||||
unsigned int end_minutes = static_cast<unsigned>(
|
||||
dst_end_offset.hours() * 60 + dst_end_offset.minutes());
|
||||
long length_minutes = static_cast<long>(
|
||||
dst_length.hours() * 60 + dst_length.minutes());
|
||||
|
||||
return local_is_dst(current_day, time_of_day,
|
||||
dst_start_day, start_minutes,
|
||||
dst_end_day, end_minutes,
|
||||
length_minutes);
|
||||
}
|
||||
|
||||
//! Calculates if the given local time is dst or not
|
||||
/*! Determines if the time is really in DST or not. Also checks for
|
||||
* invalid and ambiguous.
|
||||
* @param current_day The day to check for dst
|
||||
* @param time_of_day Time offset within the day to check
|
||||
* @param dst_start_day Starting day of dst for the given locality
|
||||
* @param dst_start_offset_minutes Offset within day for dst
|
||||
* boundary (eg 120 for US which is 02:00:00)
|
||||
* @param dst_end_day Ending day of dst for the given locality
|
||||
* @param dst_end_offset_minutes Offset within day given in dst for dst
|
||||
* @param dst_end_offset_minutes Offset within day given in dst for dst
|
||||
* boundary (eg 120 for US which is 02:00:00)
|
||||
* @param dst_length_minutes Length of dst adjusment (eg: 60 for US)
|
||||
* @retval The time is either ambiguous, invalid, in dst, or not in dst
|
||||
*/
|
||||
static time_is_dst_result
|
||||
static time_is_dst_result
|
||||
local_is_dst(const date_type& current_day,
|
||||
const time_duration_type& time_of_day,
|
||||
const date_type& dst_start_day,
|
||||
@@ -127,7 +165,7 @@ namespace boost {
|
||||
dst_start_offset_minutes,
|
||||
dst_length_minutes);
|
||||
}
|
||||
|
||||
|
||||
if (current_day == dst_end_day) {
|
||||
return process_local_dst_end_day(time_of_day,
|
||||
dst_end_offset_minutes,
|
||||
@@ -145,29 +183,29 @@ namespace boost {
|
||||
* calculation at compile time covering all the cases. Unfortunately
|
||||
* because of the number of dimensions related to daylight savings
|
||||
* calculation the number of parameters is high. In addition, the
|
||||
* start and end transition rules are complex types that specify
|
||||
* start and end transition rules are complex types that specify
|
||||
* an algorithm for calculation of the starting day and ending
|
||||
* day of daylight savings time including the month and day
|
||||
* day of daylight savings time including the month and day
|
||||
* specifications (eg: last sunday in October).
|
||||
*
|
||||
* @param date_type A type that represents dates, typically gregorian::date
|
||||
* @param time_duration_type Used for the offset in the day calculations
|
||||
* @param dst_traits A set of traits that define the rules of dst
|
||||
* @param dst_traits A set of traits that define the rules of dst
|
||||
* calculation. The dst_trait must include the following:
|
||||
* start_rule_functor - Rule to calculate the starting date of a
|
||||
* dst transition (eg: last_kday_of_month).
|
||||
* start_day - static function that returns month of dst start for
|
||||
* start_day - static function that returns month of dst start for
|
||||
* start_rule_functor
|
||||
* start_month -static function that returns day or day of week for
|
||||
* start_month -static function that returns day or day of week for
|
||||
* dst start of dst
|
||||
* end_rule_functor - Rule to calculate the end of dst day.
|
||||
* end_day - static fucntion that returns end day for end_rule_functor
|
||||
* end_month - static function that returns end month for end_rule_functor
|
||||
* dst_start_offset_minutes - number of minutes from start of day to transition to dst -- 120 (or 2:00 am) is typical for the U.S. and E.U.
|
||||
* dst_start_offset_minutes - number of minutes from start of day to transition off of dst -- 180 (or 3:00 am) is typical for E.U.
|
||||
* dst_start_offset_minutes - number of minutes from start of day to transition off of dst -- 180 (or 3:00 am) is typical for E.U.
|
||||
* dst_length_minutes - number of minutes that dst shifts clock
|
||||
*/
|
||||
template<class date_type,
|
||||
template<class date_type,
|
||||
class time_duration_type,
|
||||
class dst_traits>
|
||||
class dst_calc_engine
|
||||
@@ -178,12 +216,12 @@ namespace boost {
|
||||
typedef dst_calculator<date_type, time_duration_type> dstcalc;
|
||||
|
||||
//! Calculates if the given local time is dst or not
|
||||
/*! Determines if the time is really in DST or not. Also checks for
|
||||
/*! Determines if the time is really in DST or not. Also checks for
|
||||
* invalid and ambiguous.
|
||||
* @retval The time is either ambiguous, invalid, in dst, or not in dst
|
||||
*/
|
||||
static time_is_dst_result local_is_dst(const date_type& d,
|
||||
const time_duration_type& td)
|
||||
const time_duration_type& td)
|
||||
{
|
||||
|
||||
year_type y = d.year();
|
||||
@@ -192,10 +230,10 @@ namespace boost {
|
||||
return dstcalc::local_is_dst(d,td,
|
||||
dst_start,
|
||||
dst_traits::dst_start_offset_minutes(),
|
||||
dst_end,
|
||||
dst_traits::dst_end_offset_minutes(),
|
||||
dst_end,
|
||||
dst_traits::dst_end_offset_minutes(),
|
||||
dst_traits::dst_shift_length_minutes());
|
||||
|
||||
|
||||
}
|
||||
|
||||
static bool is_dst_boundary_day(date_type d)
|
||||
@@ -206,25 +244,19 @@ namespace boost {
|
||||
}
|
||||
|
||||
//! The time of day for the dst transition (eg: typically 01:00:00 or 02:00:00)
|
||||
static time_duration_type dst_offset()
|
||||
static time_duration_type dst_offset()
|
||||
{
|
||||
return time_duration_type(0,dst_traits::dst_shift_length_minutes(),0);
|
||||
}
|
||||
|
||||
static date_type local_dst_start_day(year_type year)
|
||||
{
|
||||
typedef typename dst_traits::start_rule_functor start_rule;
|
||||
start_rule start(dst_traits::start_day(),
|
||||
dst_traits::start_month());
|
||||
return start.get_date(year);
|
||||
return dst_traits::local_dst_start_day(year);
|
||||
}
|
||||
|
||||
static date_type local_dst_end_day(year_type year)
|
||||
{
|
||||
typedef typename dst_traits::end_rule_functor end_rule;
|
||||
end_rule end(dst_traits::end_day(),
|
||||
dst_traits::end_month());
|
||||
return end.get_date(year);
|
||||
return dst_traits::local_dst_end_day(year);
|
||||
}
|
||||
|
||||
|
||||
@@ -232,12 +264,14 @@ namespace boost {
|
||||
|
||||
//! Depricated: Class to calculate dst boundaries for US time zones
|
||||
/* Use dst_calc_engine instead.
|
||||
* In 2007 US/Canada DST rules changed
|
||||
* (http://en.wikipedia.org/wiki/Energy_Policy_Act_of_2005#Change_to_daylight_saving_time).
|
||||
*/
|
||||
template<class date_type_,
|
||||
template<class date_type_,
|
||||
class time_duration_type_,
|
||||
unsigned int dst_start_offset_minutes=120, //from start of day
|
||||
unsigned int dst_start_offset_minutes=120, //from start of day
|
||||
short dst_length_minutes=60> //1 hour == 60 min in US
|
||||
class us_dst_rules
|
||||
class us_dst_rules
|
||||
{
|
||||
public:
|
||||
typedef time_duration_type_ time_duration_type;
|
||||
@@ -246,15 +280,16 @@ namespace boost {
|
||||
typedef typename date_type::calendar_type calendar_type;
|
||||
typedef date_time::last_kday_of_month<date_type> lkday;
|
||||
typedef date_time::first_kday_of_month<date_type> fkday;
|
||||
typedef date_time::nth_kday_of_month<date_type> nkday;
|
||||
typedef dst_calculator<date_type, time_duration_type> dstcalc;
|
||||
|
||||
//! Calculates if the given local time is dst or not
|
||||
/*! Determines if the time is really in DST or not. Also checks for
|
||||
/*! Determines if the time is really in DST or not. Also checks for
|
||||
* invalid and ambiguous.
|
||||
* @retval The time is either ambiguous, invalid, in dst, or not in dst
|
||||
*/
|
||||
static time_is_dst_result local_is_dst(const date_type& d,
|
||||
const time_duration_type& td)
|
||||
const time_duration_type& td)
|
||||
{
|
||||
|
||||
year_type y = d.year();
|
||||
@@ -262,9 +297,9 @@ namespace boost {
|
||||
date_type dst_end = local_dst_end_day(y);
|
||||
return dstcalc::local_is_dst(d,td,
|
||||
dst_start,dst_start_offset_minutes,
|
||||
dst_end, dst_start_offset_minutes,
|
||||
dst_end, dst_start_offset_minutes,
|
||||
dst_length_minutes);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -277,16 +312,28 @@ namespace boost {
|
||||
|
||||
static date_type local_dst_start_day(year_type year)
|
||||
{
|
||||
//first sunday in april
|
||||
fkday fsia(Sunday, gregorian::Apr);
|
||||
return fsia.get_date(year);
|
||||
if (year >= year_type(2007)) {
|
||||
//second sunday in march
|
||||
nkday ssim(nkday::second, Sunday, date_time::Mar);
|
||||
return ssim.get_date(year);
|
||||
} else {
|
||||
//first sunday in april
|
||||
fkday fsia(Sunday, date_time::Apr);
|
||||
return fsia.get_date(year);
|
||||
}
|
||||
}
|
||||
|
||||
static date_type local_dst_end_day(year_type year)
|
||||
{
|
||||
//last sunday in october
|
||||
lkday lsio(Sunday, gregorian::Oct);
|
||||
return lsio.get_date(year);
|
||||
if (year >= year_type(2007)) {
|
||||
//first sunday in november
|
||||
fkday fsin(Sunday, date_time::Nov);
|
||||
return fsin.get_date(year);
|
||||
} else {
|
||||
//last sunday in october
|
||||
lkday lsio(Sunday, date_time::Oct);
|
||||
return lsio.get_date(year);
|
||||
}
|
||||
}
|
||||
|
||||
static time_duration_type dst_offset()
|
||||
@@ -294,6 +341,8 @@ namespace boost {
|
||||
return time_duration_type(0,dst_length_minutes,0);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -309,25 +358,25 @@ namespace boost {
|
||||
//! Calculates if the given local time is dst or not
|
||||
/*! @retval Always is_not_in_dst since this is for zones without dst
|
||||
*/
|
||||
static time_is_dst_result local_is_dst(const date_type&,
|
||||
const time_duration_type&)
|
||||
{
|
||||
return is_not_in_dst;
|
||||
}
|
||||
|
||||
//! Calculates if the given utc time is in dst
|
||||
static time_is_dst_result utc_is_dst(const date_type&,
|
||||
const time_duration_type&)
|
||||
static time_is_dst_result local_is_dst(const date_type&,
|
||||
const time_duration_type&)
|
||||
{
|
||||
return is_not_in_dst;
|
||||
}
|
||||
|
||||
static bool is_dst_boundary_day(date_type d)
|
||||
//! Calculates if the given utc time is in dst
|
||||
static time_is_dst_result utc_is_dst(const date_type&,
|
||||
const time_duration_type&)
|
||||
{
|
||||
return is_not_in_dst;
|
||||
}
|
||||
|
||||
static bool is_dst_boundary_day(date_type /*d*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static time_duration_type dst_offset()
|
||||
static time_duration_type dst_offset()
|
||||
{
|
||||
return time_duration_type(0,0,0);
|
||||
}
|
||||
@@ -338,17 +387,5 @@ namespace boost {
|
||||
} } //namespace date_time
|
||||
|
||||
|
||||
/* Copyright (c) 2002
|
||||
* CrystalClear Software, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. CrystalClear Software makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
*/
|
||||
#ifndef DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__
|
||||
#define DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
//! Defines base interface for calculating start and end date of daylight savings
|
||||
template<class date_type>
|
||||
class dst_day_calc_rule
|
||||
{
|
||||
public:
|
||||
typedef typename date_type::year_type year_type;
|
||||
virtual ~dst_day_calc_rule() {}
|
||||
virtual date_type start_day(year_type y) const=0;
|
||||
virtual std::string start_rule_as_string() const=0;
|
||||
virtual date_type end_day(year_type y) const=0;
|
||||
virtual std::string end_rule_as_string() const=0;
|
||||
|
||||
};
|
||||
|
||||
//! Canonical form for a class that provides day rule calculation
|
||||
/*! This class is used to generate specific sets of dst rules
|
||||
*
|
||||
*@tparam spec Provides a specifiction of the function object types used
|
||||
* to generate start and end days of daylight savings as well
|
||||
* as the date type.
|
||||
*/
|
||||
template<class spec>
|
||||
class day_calc_dst_rule : public dst_day_calc_rule<typename spec::date_type>
|
||||
{
|
||||
public:
|
||||
typedef typename spec::date_type date_type;
|
||||
typedef typename date_type::year_type year_type;
|
||||
typedef typename spec::start_rule start_rule;
|
||||
typedef typename spec::end_rule end_rule;
|
||||
day_calc_dst_rule(start_rule dst_start,
|
||||
end_rule dst_end) :
|
||||
dst_start_(dst_start),
|
||||
dst_end_(dst_end)
|
||||
{}
|
||||
virtual date_type start_day(year_type y) const
|
||||
{
|
||||
return dst_start_.get_date(y);
|
||||
}
|
||||
virtual std::string start_rule_as_string() const
|
||||
{
|
||||
return dst_start_.to_string();
|
||||
}
|
||||
virtual date_type end_day(year_type y) const
|
||||
{
|
||||
return dst_end_.get_date(y);
|
||||
}
|
||||
virtual std::string end_rule_as_string() const
|
||||
{
|
||||
return dst_end_.to_string();
|
||||
}
|
||||
private:
|
||||
start_rule dst_start_;
|
||||
end_rule dst_end_;
|
||||
};
|
||||
|
||||
|
||||
} }//namespace
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
#ifndef DATE_TIME_FILETIME_FUNCTIONS_HPP__
|
||||
#define DATE_TIME_FILETIME_FUNCTIONS_HPP__
|
||||
|
||||
/* Copyright (c) 2004 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
/*! @file filetime_functions.hpp
|
||||
* Function(s) for converting between a FILETIME structure and a
|
||||
* time object. This file is only available on systems that have
|
||||
* BOOST_HAS_FTIME defined.
|
||||
*/
|
||||
|
||||
#include <boost/date_time/compiler_config.hpp>
|
||||
|
||||
#if defined(BOOST_HAS_FTIME) // skip this file if no FILETIME
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/date_time/time.hpp>
|
||||
#include <boost/date_time/date_defs.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace date_time {
|
||||
|
||||
//! Create a time object from an initialized FILETIME struct.
|
||||
/*!
|
||||
* Create a time object from an initialized FILETIME struct.
|
||||
* A FILETIME struct holds 100-nanosecond units (0.0000001). When
|
||||
* built with microsecond resolution the file_time's sub second value
|
||||
* will be truncated. Nanosecond resolution has no truncation.
|
||||
*
|
||||
* \note The function is templated on the FILETIME type, so that
|
||||
* it can be used with both native FILETIME and the ad-hoc
|
||||
* boost::detail::winapi::FILETIME_ type.
|
||||
*/
|
||||
template< typename TimeT, typename FileTimeT >
|
||||
inline
|
||||
TimeT time_from_ftime(const FileTimeT& ft)
|
||||
{
|
||||
typedef typename TimeT::date_type date_type;
|
||||
typedef typename TimeT::date_duration_type date_duration_type;
|
||||
typedef typename TimeT::time_duration_type time_duration_type;
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/2523
|
||||
// Since this function can be called with arbitrary times, including ones that
|
||||
// are before 1970-Jan-01, we'll have to cast the time a bit differently,
|
||||
// than it is done in the microsec_clock::file_time_to_microseconds function. This allows to
|
||||
// avoid integer wrapping for dates before 1970-Jan-01.
|
||||
|
||||
// 100-nanos since 1601-Jan-01
|
||||
uint64_t ft_as_integer = (static_cast< uint64_t >(ft.dwHighDateTime) << 32) | static_cast< uint64_t >(ft.dwLowDateTime);
|
||||
uint64_t sec = ft_as_integer / 10000000UL;
|
||||
uint32_t sub_sec = static_cast< uint32_t >(ft_as_integer % 10000000UL) // 100-nanoseconds since the last second
|
||||
#if !defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
|
||||
/ 10U; // microseconds since the last second
|
||||
#else
|
||||
* 100U; // nanoseconds since the last second
|
||||
#endif
|
||||
|
||||
// split sec into usable chunks: days, hours, minutes, & seconds
|
||||
const uint32_t sec_per_day = 86400; // seconds per day
|
||||
uint32_t days = static_cast< uint32_t >(sec / sec_per_day);
|
||||
uint32_t tmp = static_cast< uint32_t >(sec % sec_per_day);
|
||||
uint32_t hours = tmp / 3600; // sec_per_hour
|
||||
tmp %= 3600;
|
||||
uint32_t minutes = tmp / 60; // sec_per_min
|
||||
tmp %= 60;
|
||||
uint32_t seconds = tmp; // seconds
|
||||
|
||||
date_duration_type dd(days);
|
||||
date_type d = date_type(1601, Jan, 01) + dd;
|
||||
return TimeT(d, time_duration_type(hours, minutes, seconds, sub_sec));
|
||||
}
|
||||
|
||||
}} // boost::date_time
|
||||
|
||||
#endif // BOOST_HAS_FTIME
|
||||
|
||||
#endif // DATE_TIME_FILETIME_FUNCTIONS_HPP__
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef _BOOST_DATE_TIME_FIND_MATCH_HPP___
|
||||
#define _BOOST_DATE_TIME_FIND_MATCH_HPP___
|
||||
|
||||
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
|
||||
* Use, modification and distribution is subject to the
|
||||
* Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace date_time {
|
||||
|
||||
|
||||
//! Find index of a string in either of 2 arrays
|
||||
/*! find_match searches both arrays for a match to 's'. Both arrays
|
||||
* must contain 'size' elements. The index of the match is returned.
|
||||
* If no match is found, 'size' is returned.
|
||||
* Ex. "Jan" returns 0, "Dec" returns 11, "Tue" returns 2.
|
||||
* 'size' can be sent in with: (greg_month::max)() (which 12),
|
||||
* (greg_weekday::max)() + 1 (which is 7) or date_time::NumSpecialValues */
|
||||
template<class charT>
|
||||
short find_match(const charT* const* short_names,
|
||||
const charT* const* long_names,
|
||||
short size,
|
||||
const std::basic_string<charT>& s) {
|
||||
for(short i = 0; i < size; ++i){
|
||||
if(short_names[i] == s || long_names[i] == s){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return size; // not-found, return a value out of range
|
||||
}
|
||||
|
||||
|
||||
} } //namespace date_time
|
||||
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user