summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/NEWS.md4
-rw-r--r--src/times.cc14
-rw-r--r--test/regress/1775.test20
3 files changed, 31 insertions, 7 deletions
diff --git a/doc/NEWS.md b/doc/NEWS.md
index 76f4d983..1d1e618d 100644
--- a/doc/NEWS.md
+++ b/doc/NEWS.md
@@ -1,5 +1,9 @@
# Ledger NEWS
+## 3.1.4 (unreleased)
+
+- Add support for '%F' date format specifier (bug #1775)
+
## 3.1.3 (2019-03-31)
- Properly reject postings with a comment right after the flag (bug #1753)
diff --git a/src/times.cc b/src/times.cc
index b9c67078..640e5019 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -55,18 +55,18 @@ namespace {
temporal_io_t(const char * _fmt_str, bool _input)
: fmt_str(_fmt_str),
- traits(icontains(fmt_str, "%y"),
- icontains(fmt_str, "%m") || icontains(fmt_str, "%b"),
- icontains(fmt_str, "%d")),
+ traits(icontains(fmt_str, "%F") || icontains(fmt_str, "%y"),
+ icontains(fmt_str, "%F") || icontains(fmt_str, "%m") || icontains(fmt_str, "%b"),
+ icontains(fmt_str, "%F") || icontains(fmt_str, "%d")),
input(_input) {
}
void set_format(const char * fmt) {
fmt_str = fmt;
- traits = date_traits_t(icontains(fmt_str, "%y"),
- icontains(fmt_str, "%m") ||
- icontains(fmt_str, "%b"),
- icontains(fmt_str, "%d"));
+ traits = date_traits_t(icontains(fmt_str, "%F") || icontains(fmt_str, "%y"),
+ icontains(fmt_str, "%F") ||
+ icontains(fmt_str, "%m") || icontains(fmt_str, "%b"),
+ icontains(fmt_str, "%F") || icontains(fmt_str, "%d"));
}
T parse(const char *) {}
diff --git a/test/regress/1775.test b/test/regress/1775.test
new file mode 100644
index 00000000..10ae3639
--- /dev/null
+++ b/test/regress/1775.test
@@ -0,0 +1,20 @@
+2017-02-28 * Test
+ Assets:A 10.00 EUR
+ Assets:B -10.00 EUR
+
+2017-03-30 * Test
+ Assets:A 10.00 EUR
+ Assets:B -10.00 EUR
+
+2018-03-30 * Test
+ Assets:A 10.00 EUR
+ Assets:B -10.00 EUR
+
+test reg --input-date-format %F
+17-Feb-28 Test Assets:A 10.00 EUR 10.00 EUR
+ Assets:B -10.00 EUR 0
+17-Mar-30 Test Assets:A 10.00 EUR 10.00 EUR
+ Assets:B -10.00 EUR 0
+18-Mar-30 Test Assets:A 10.00 EUR 10.00 EUR
+ Assets:B -10.00 EUR 0
+end test