Project 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.


Download
http://www.partow.net/programming/datetime/index.html


Compatible C++ Compilers:
  • GNU Compiler Collection (4.1+)
  • Intel® C++ Compiler (9.x+)
  • Clang/LLVM (1.1+)
  • PGI C++ (10.x+)
  • Microsoft Visual Studio C++ Compiler (7.1+)
  • IBM XL C/C++ (10.x+)
  • C++ Builder (XE4+)


Date-Time Format Capabilities
# 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
14 date_format14 DD-Mon-YYYY 03-Mar-2006
15 date_format15 ?D-Mon-YYYY 14-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
45 datetime_format20 ISO8601 DateThh:mmTZD 2006-03-04T13:27+03:45
46 datetime_format21 NCSA Common Log DateTime 04/Mar/2006:13:27:54 -0537
47 datetime_format22 RFC-822 HTTP DateTime Sat, 04 Mar 2006 13:27:54 GMT



Simple Example
The following example will parse an NCSA Common Log date-time string into its various components, and print them to stdout.

#include <iostream>
#include <string>

#include "strtk.hpp"
#include "datetime_utils.hpp"

int main()
{
   std::string data = "04/Mar/2006:13:27:54 -0537";
   dt_utils::datetime dt;
   dt_utils::datetime_format21 dt21(dt);

   strtk::string_to_type_converter(data,dt21)

   std::cout << "dt.year:   " << dt.year   << std::endl;
   std::cout << "dt.month:  " << dt.month  << std::endl;
   std::cout << "dt.day:    " << dt.day    << std::endl;
   std::cout << "dt.hour:   " << dt.hour   << std::endl;
   std::cout << "dt.minute: " << dt.minute << std::endl;
   std::cout << "dt.second: " << dt.second << std::endl;
   std::cout << "dt.tzd:    " << dt.tzd    << std::endl;

   return 0;
}

Last edited Apr 20 at 8:20 AM by ArashPartow, version 8