summaryrefslogtreecommitdiff
path: root/src/times.cc
diff options
context:
space:
mode:
authorMichael Budde <mbudde@gmail.com>2019-03-31 13:18:09 +0200
committerMartin Michlmayr <tbm@cyrius.com>2019-04-02 11:56:27 +0700
commitc4eab0007a788703bc63db82fd995ef646820529 (patch)
tree5e1c69743d65eeb949a60279efca64cece486b05 /src/times.cc
parent928fe50958f980d3ff92f54abe07dd97d53e2279 (diff)
downloadfork-ledger-c4eab0007a788703bc63db82fd995ef646820529.tar.gz
fork-ledger-c4eab0007a788703bc63db82fd995ef646820529.tar.bz2
fork-ledger-c4eab0007a788703bc63db82fd995ef646820529.zip
Add support for '%F' date format specifier
'%F' is equivalent to '%Y-%m-%d'. Using the '%F' format without this change this would not give any hard errors but instead give dates with wrong years because the 'has_year' trait would not be correctly detected and thus parsed dates would get set to the current year. Fixes #1775
Diffstat (limited to 'src/times.cc')
-rw-r--r--src/times.cc14
1 files changed, 7 insertions, 7 deletions
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 *) {}