From 4a6df38e6a32cfd156fac27c282c15d3e0b0cfa3 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 11 Aug 2015 23:13:23 -0400 Subject: [PATCH] ISO8601: Modifed ::format to use only precise values. --- src/ISO8601.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ISO8601.cpp b/src/ISO8601.cpp index 1e4c313d2..0d8a43196 100644 --- a/src/ISO8601.cpp +++ b/src/ISO8601.cpp @@ -713,7 +713,7 @@ bool ISO8601p::parse (const std::string& input, std::string::size_type& start) { start = original_start + n.cursor (); - // Linear lookup - should be logarithmic. + // Linear lookup - should instead be logarithmic. for (unsigned int i = 0; i < NUM_DURATIONS; i++) { if (durations[i].unit == unit && @@ -761,7 +761,7 @@ bool ISO8601p::parse (const std::string& input, std::string::size_type& start) start = original_start + n.cursor (); double quantity = strtod (number.c_str (), NULL); - // Linear lookup - should be logarithmic. + // Linear lookup - should instead be logarithmic. double seconds = 1; for (unsigned int i = 0; i < NUM_DURATIONS; i++) { @@ -800,14 +800,10 @@ const std::string ISO8601p::format () const int seconds = t % 60; t /= 60; int minutes = t % 60; t /= 60; int hours = t % 24; t /= 24; - int days = t % 30; t /= 30; - int months = t % 12; t /= 12; - int years = t; + int days = t; std::stringstream s; s << 'P'; - if (years) s << years << 'Y'; - if (months) s << months << 'M'; if (days) s << days << 'D'; if (hours || minutes || seconds)