From fdc791a676134b7426a4242bf171aa943c9c2ab9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 27 Sep 2015 11:15:28 -0400 Subject: [PATCH] ISO8601d: Implemented ::parse_epoch --- src/ISO8601.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ISO8601.cpp b/src/ISO8601.cpp index c734c071a..5ee96318e 100644 --- a/src/ISO8601.cpp +++ b/src/ISO8601.cpp @@ -582,13 +582,21 @@ bool ISO8601d::parse_named (Nibbler& n) } //////////////////////////////////////////////////////////////////////////////// +// Valid epoch values are unsigned integers after 1980-01-01T00:00:00Z. This +// restriction means that '12' will not be identified as an epoch date. bool ISO8601d::parse_epoch (Nibbler& n) { -/* - if (isEpoch (input)) - return true; -*/ + n.save (); + int epoch; + if (n.getUnsignedInt (epoch) && + epoch >= 315532800) + { + _date = static_cast (epoch); + return true; + } + + n.restore (); return false; }