- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
struct DateTime {
string x;
DateTime() { x = Now(); }
DateTime(const string& _x): x(_x) { if (BadDateTime) throw Exception(); }
operator string() { return x; }
};
string correctDateTime(const string& value)
{
try
{
DateTime(value); // if the value is bad, ctor will throw
return value;
}
catch (…) {}
return DateTime(); // and we replace bad DateTime with currentDateTime
}