mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Date
- Added the ability to suppres ISO (fixed) and epoch date parsing.
This commit is contained in:
parent
52eaf3f9c2
commit
79576819c3
2 changed files with 8 additions and 4 deletions
10
src/Date.cpp
10
src/Date.cpp
|
@ -125,7 +125,11 @@ Date::Date (const int m, const int d, const int y,
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */)
|
Date::Date (
|
||||||
|
const std::string& input,
|
||||||
|
const std::string& format /* = "m/d/Y" */,
|
||||||
|
const bool iso /* = true */,
|
||||||
|
const bool epoch /* = true */)
|
||||||
{
|
{
|
||||||
// Before parsing according to "format", perhaps this is a relative date?
|
// Before parsing according to "format", perhaps this is a relative date?
|
||||||
if (isRelativeDate (input))
|
if (isRelativeDate (input))
|
||||||
|
@ -139,11 +143,11 @@ Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Parse an ISO date.
|
// Parse an ISO date.
|
||||||
if (n.getDateISO (_t) && n.depleted ())
|
if (iso && n.getDateISO (_t) && n.depleted ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Perhaps it is an epoch date, in string form?
|
// Perhaps it is an epoch date, in string form?
|
||||||
if (isEpoch (input))
|
if (epoch && isEpoch (input))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
throw ::format (STRING_DATE_INVALID_FORMAT, input, format);
|
throw ::format (STRING_DATE_INVALID_FORMAT, input, format);
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
Date (time_t);
|
Date (time_t);
|
||||||
Date (const int, const int, const int);
|
Date (const int, const int, const int);
|
||||||
Date (const int, const int, const int, const int, const int, const int);
|
Date (const int, const int, const int, const int, const int, const int);
|
||||||
Date (const std::string&, const std::string& format = "m/d/Y");
|
Date (const std::string&, const std::string& format = "m/d/Y", const bool iso = true, const bool epoch = true);
|
||||||
Date (const Date&);
|
Date (const Date&);
|
||||||
virtual ~Date ();
|
virtual ~Date ();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue