From d77db196ee5ec2ffe1d9795dc8fdb5b2b6d8303c Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Wed, 30 May 2012 21:48:44 +0000 Subject: [PATCH] added: to Date: bool ParseMonthDayTime(const CStringType * str, const CStringType ** str_after = 0); parsing: MM:DD HH[:MM[:SS]] git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@416 e52654a7-88a9-db11-a3e9-0013d4bc506e --- date/date.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/date/date.h b/date/date.h index fd896b0..e108807 100644 --- a/date/date.h +++ b/date/date.h @@ -407,7 +407,7 @@ public: this method doesn't test if the values are correct use IsCorrectDate() to check - */ + */ template bool ParseTime(const CStringType * str, const CStringType ** str_after = 0); @@ -415,6 +415,28 @@ public: bool ParseTime(const StringType & str); + /* + parsing month, day, hour and minutes (if exists) and seconds (if exists) + the input string can be as follows: + "10-23 14" -- only month, day and hour given (min and sec will be zero) + "10-23 14:10" -- month, day and hour with minutes (sec will be zero) + "10-23 14:10:35" -- month, day, hour, minutes and seconds + + white characters are ommited so these are valid strings too: + " 10 - 23 14 : 10 : 35 " + " 10 - 23 14 : 10 : 35some text " + a white character means a space or a tab + + this method doesn't test if the values are correct + use IsCorrectDate() to check + */ + template + bool ParseMonthDayTime(const CStringType * str, const CStringType ** str_after = 0); + + template + bool ParseMonthDayTime(const StringType & str); + + /* parsing year/month/day hour:min:sec the input strings can be as follows: @@ -685,6 +707,31 @@ bool Date::ParseTime(const StringType & str) +template +bool Date::ParseMonthDayTime(const CStringType * str, const CStringType ** str_after) +{ +const CStringType * after; +bool result = false; + + if( ParseMonthDay(str, &after) ) + if( ParseTime(after, &after) ) + result = true; + + SetAfter(after, str_after); + +return result; +} + + +template +bool Date::ParseMonthDayTime(const StringType & str) +{ + return ParseMonthDayTime(str.c_str()); +} + + + + template bool Date::Parse(const CStringType * str, const CStringType ** str_after) {