blob: bb75f8d9c4d49e3f4b139a7a304ab9aecae90917 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#include "times.h"
namespace ledger {
ptime now = boost::posix_time::second_clock::universal_time();
bool day_before_month = false;
ptime parse_datetime(std::istream& in)
{
#if 1
return parse_abs_datetime(in);
#else
std::string word;
if (! in.good() || in.eof())
return ptime();
in >> word;
// Grammar
//
// datetime: absdate [time]
// | reldate
// | datetime preposition
//
// reldate: NOW | TODAY | YESTERDAY | TOMORROW
// | skip_or_quantity specifier
//
// skip_or_quantity: skip | quantity
//
// skip: LAST | NEXT
//
// quantity: INTEGER | CARDINAL
//
// specifier: DAY | WEEK | MONTH | QUARTER | YEAR | DECADE
//
// preposition: AGO | BACK
// | BEFORE reldate
// | SINCE/FROM reldate
// | UNTIL reldate
// | AFTER reldate
if (std::isdigit(word[0])) {
// This could be any of a variety of formats:
//
// 20070702 [TIME]
// 22072007T171940
// 22072007T171940-0700
// 2007-07-02 [TIME]
// 2007/07/02 [TIME]
// 2007.07.02 [TIME]
// 2007-Jul-22 [TIME]
// 07-22-2007 [TIME]
// 07-22-07 [TIME]
// 07/22/2007 [TIME]
// 07/22/2007 [TIME]
// 07.22.2007 [TIME]
// 07.22.07 [TIME]
// 22-07-2007 [TIME]
// 22-07-07 [TIME]
// 22/07/2007 [TIME]
// 22/07/07 [TIME]
// 22.07.2007 [TIME]
// 22.07.07 [TIME]
// 22 Jul 2007 [TIME]
// 22 July 2007 [TIME]
//
// (NUMBER) (SPECIFIER)
} else {
// If there is no starting digit, then it could be any of these:
//
// now
// today
// yesterday
// tomorrow
// (last|next) (week|month|quarter|year|decade)
// (one|two|three|four|five|six|seven|eight|nine|ten) SPECIFIER
// PREPOSITION DATE
//
// PREPOSITION = (from|after|before|since|until)
// SPECIFIER = (weeks?|months?|quarters?|years?|decades?) (ago|back)
//
//
}
#endif
}
ptime datetime_range_from_stream(std::istream& in)
{
}
}
|