summaryrefslogtreecommitdiff
path: root/times.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-19 14:47:33 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:27 -0400
commitc5214c87594e0de68111a9160dba5dc1aceb9a43 (patch)
tree41419220704bb48e79d506cee4d12cb3e35fdc69 /times.cc
parent53c132ad98caf765eaba51fe4c5a85e4a69ddf06 (diff)
downloadfork-ledger-c5214c87594e0de68111a9160dba5dc1aceb9a43.tar.gz
fork-ledger-c5214c87594e0de68111a9160dba5dc1aceb9a43.tar.bz2
fork-ledger-c5214c87594e0de68111a9160dba5dc1aceb9a43.zip
Changed date parser to use lex/yacc.
Diffstat (limited to 'times.cc')
-rw-r--r--times.cc88
1 files changed, 87 insertions, 1 deletions
diff --git a/times.cc b/times.cc
index 60926112..bb75f8d9 100644
--- a/times.cc
+++ b/times.cc
@@ -2,6 +2,92 @@
namespace ledger {
- ptime now = boost::posix_time::second_clock::universal_time();
+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)
+{
+}
}