Description
The C++ Date And Time Parsing Utilities library is comprised
of a set of extremely fast and efficient parsing routines for
common date and time formats.
Date And Time Parsing Utilities Library License
Free use of the Date and Time Parsing Utilities Library is permitted under
the guidelines and in accordance with the
MIT License.
Compatibility
The C++ Date and Time Parsing Utilities Library implementation is fully compatible with the following C++ compilers:
GNU Compiler Collection (3.5+)
Clang/LLVM (1.1+)
Microsoft Visual Studio C++ Compiler (7.1+)
Intel® C++ Compiler (8.x+)
AMD Optimizing C++ Compiler (1.2+)
Nvidia C++ Compiler (19.x+)
PGI C++ (10.x+)
IBM XL C/C++ (9.x+)
C++ Builder (XE4+)
Download
Simple Date-Time Parsing Example
The following is a simple example demonstrating a datetime type
instance being populated from a data string that represents a date-time
value in the
RFC-822 HTTP date-time format .
If the parsing process is successful each component of the datetime object
will be printed to stdout, otherwise an error will be raised.
#include <iostream>
#include <string>
#include "strtk.hpp"
#include "datetime_utils.hpp"
int main()
{
// Setup the RFC-822 HTTP date-time format handlers
dt_utils::datetime dt;
dt_utils::datetime_format22 fmt(dt);
std::string data = "Sat, 17 Mar 2006 13:27:54 +0325";
dt.clear();
if (strtk::string_to_type_converter(data, fmt))
{
std::cout << "Date-Time: " << data << "\n";
std::cout << "Year: " << dt.year << "\n";
std::cout << "Month: " << dt.month << "\n";
std::cout << "Day: " << dt.day << "\n";
std::cout << "Hour: " << dt.hour << "\n";
std::cout << "Minute: " << dt.minute << "\n";
std::cout << "Second: " << dt.second << "\n";
std::cout << "TZD: " << dt.tzd << "\n";
}
else
std::cout << "Error occured during parsing of date-time: " << data << "\n";
return 0;
}
Date-Time Format Capabilities
The following is a list of the various formats that are supported by the library.
# Type Format Example
00 date_format00 YYYYMMDD 20060314
01 date_format01 YYYYDDMM 20061403
02 date_format02 YYYY/MM/DD 2006/03/14
03 date_format03 YYYY/DD/MM 2006/14/03
04 date_format04 DD/MM/YYYY 14/03/2006
05 date_format05 MM/DD/YYYY 03/14/2006
06 date_format06 YYYY-MM-DD 2006-03-14
07 date_format07 YYYY-DD-MM 2006-14-03
08 date_format08 DD-MM-YYYY 14-03-2006
09 date_format09 MM-DD-YYYY 03-14-2006
10 date_format10 DD.MM.YYYY 14.03.2006
11 date_format11 MM.DD.YYYY 03.14.2006
12 date_format12 DD-Mon-YY 03-Mar-06
13 date_format13 ?D-Mon-YY 14-Mar-06 7-Mar-06
14 date_format14 DD-Mon-YYYY 03-Mar-2006
15 date_format15 ?D-Mon-YYYY 14-Mar-2006 7-Mar-2006
16 time_format0 HH:MM:SS.mss 13:27:54.123
17 time_format1 HH:MM:SS 13:27:54
18 time_format2 HH MM SS mss 13 27 54 123
19 time_format3 HH MM SS 13 27 54
20 time_format4 HH.MM.SS.mss 13.27.54.123
21 time_format5 HH.MM.SS 13.27.54
22 time_format6 HHMM 1327
23 time_format7 HHMMSS 132754
24 time_format8 HHMMSSmss 132754123
25 datetime_format00 YYYYMMDD HH:MM:SS.mss 20060314 13:27:54.123
26 datetime_format01 YYYY/MM/DD HH:MM:SS.mss 2006/03/14 13:27:54.123
27 datetime_format02 DD/MM/YYYY HH:MM:SS.mss 14/03/2006 13:27:54.123
28 datetime_format03 YYYYMMDD HH:MM:SS 20060314 13:27:54
29 datetime_format04 YYYY/MM/DD HH:MM:SS 2006/03/14 13:27:54
30 datetime_format05 DD/MM/YYYY HH:MM:SS 14/03/2006 13:27:54
31 datetime_format06 YYYY-MM-DD HH:MM:SS.mss 2006-03-14 13:27:54.123
32 datetime_format07 DD-MM-YYYY HH:MM:SS.mss 14-03-2006 13:27:54.123
33 datetime_format08 YYYY-MM-DD HH:MM:SS 2006-03-14 13:27:54
34 datetime_format09 DD-MM-YYYY HH:MM:SS 14-03-2006 13:27:54
35 datetime_format10 YYYY-MM-DDTHH:MM:SS 2006-03-14T13:27:54
36 datetime_format11 YYYY-MM-DDTHH:MM:SS.mss 2006-03-14T13:27:54.123
37 datetime_format12 YYYYMMDDTHH:MM:SS 20060314T13:27:54
38 datetime_format13 YYYYMMDDTHH:MM:SS.mss 20060314T13:27:54.123
39 datetime_format14 DD-MM-YYYYTHH:MM:SS.mss 14-03-2006T13:27:54.123
40 datetime_format15 DD-MM-YYYYTHH:MM:SS 14-03-2006T13:27:54
41 datetime_format16 YYYYMMDDTHHMM 20060314T1327
42 datetime_format17 YYYYMMDDTHHMMSS 20060314T132754
43 datetime_format18 YYYYMMDDTHHMMSSMSS 20060314T132754123
44 datetime_format19 ISO8601 DateThh:mm:ssTZD 2006-03-04T13:27:54+03:45 2006-03-04T13:27:54-01:28
45 datetime_format20 ISO8601 DateThh:mmTZD 2006-03-04T13:27+03:45 2006-03-04T13:27-01:28
46 datetime_format21 NCSA Common Log DateTime 04/Mar/2006:13:27:54 -0537 17/Sep/2006:18:12:45 +1142
47 datetime_format22 RFC-822 HTTP DateTime Sat, 04 Mar 2006 13:27:54 GMT Sat, 04 Mar 2006 13:27:54 -0234
Dependencies
The Date and Time Parsing Utilities Library requires the String Toolkit library.