mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
ISO8601: Added static ::dayOfWeek
This commit is contained in:
parent
71e2f1bf2f
commit
91588c7e96
2 changed files with 21 additions and 0 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <Lexer.h>
|
||||
#include <ISO8601.h>
|
||||
#include <Date.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
||||
#define DAY 86400
|
||||
|
@ -796,6 +797,24 @@ bool ISO8601p::parse (const std::string& input, std::string::size_type& start)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Static
|
||||
int ISO8601d::dayOfWeek (const std::string& input)
|
||||
{
|
||||
if (ISO8601d::minimumMatchLength== 0)
|
||||
minimumMatchLength= 3;
|
||||
|
||||
if (closeEnough (STRING_DATE_SUNDAY, input, minimumMatchLength)) return 0;
|
||||
else if (closeEnough (STRING_DATE_MONDAY, input, minimumMatchLength)) return 1;
|
||||
else if (closeEnough (STRING_DATE_TUESDAY, input, minimumMatchLength)) return 2;
|
||||
else if (closeEnough (STRING_DATE_WEDNESDAY, input, minimumMatchLength)) return 3;
|
||||
else if (closeEnough (STRING_DATE_THURSDAY, input, minimumMatchLength)) return 4;
|
||||
else if (closeEnough (STRING_DATE_FRIDAY, input, minimumMatchLength)) return 5;
|
||||
else if (closeEnough (STRING_DATE_SATURDAY, input, minimumMatchLength)) return 6;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ISO8601p::clear ()
|
||||
{
|
||||
|
|
|
@ -44,6 +44,8 @@ public:
|
|||
operator time_t () const;
|
||||
bool parse (const std::string&, std::string::size_type&, const std::string& format = "");
|
||||
|
||||
static int dayOfWeek (const std::string&);
|
||||
|
||||
private:
|
||||
void clear ();
|
||||
bool parse_date_time (Nibbler&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue