Public Member Functions | |
| DateTimeFromString (const QString &text) | |
| DateTimeData | value (bool &ok) const |
Protected Member Functions | |
| virtual bool | ap_parsed () |
| virtual bool | AP_parsed () |
| virtual bool | d_parsed () |
| virtual bool | dd_parsed () |
| virtual bool | ddd_parsed () |
| virtual bool | dddd_parsed () |
| virtual bool | h_parsed () |
| virtual bool | H_parsed () |
| virtual bool | hh_parsed () |
| virtual bool | HH_parsed () |
| virtual bool | M_parsed () |
| virtual bool | m_parsed () |
| virtual bool | MM_parsed () |
| virtual bool | mm_parsed () |
| virtual bool | MMM_parsed () |
| virtual bool | MMMM_parsed () |
| virtual bool | other_parsed (const QChar &c) |
| virtual bool | quote_parsed (const StringSection &text) |
| virtual bool | s_parsed () |
| virtual bool | ss_parsed () |
| virtual bool | ssz_parsed () |
| virtual bool | sz_parsed () |
| virtual bool | yy_parsed () |
| virtual bool | yyyy_parsed () |
| virtual bool | z_parsed () |
| virtual bool | zzz_parsed () |
| QGpCoreTools::DateTimeFromString::DateTimeFromString | ( | const QString & | text | ) |
References QGpCoreTools::StringSection::set().
{
_text=text;
_current.set(_text);
_year=1970;
_month=1;
_day=1;
_hour=0;
_minute=0;
_second=0;
_fraction=0.0;
_ampm=UndefinedAMPM;
}
| bool QGpCoreTools::DateTimeFromString::ap_parsed | ( | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::StringSection::beginWith(), QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(_current.beginWith("am")) {
if(_ampm!=IgnoreAMPM) {
_ampm=AM;
}
_current+=2;
return true;
} else if(_current.beginWith("pm")) {
if(_ampm!=IgnoreAMPM) {
_ampm=PM;
}
_current+=2;
return true;
}
App::stream() << tr("expected am or pm: '%1'").arg(_current.left(2).toString()) << endl;
return false;
}
| bool QGpCoreTools::DateTimeFromString::AP_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::d_parsed | ( | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toInt(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(_current[0].isDigit() || _current[0].isSpace()) {
if(_current[1].isDigit()) {
_day=_current.left(2).toInt();
if(_day>=1 && _day<=31) {
_current+=2;
return true;
}
} else {
_day=_current.left(1).toInt();
if(_day>=1) {
_current+=1;
return true;
}
}
}
App::stream() << tr("expected a number between 1 and 31: '%1'").arg(_current.left(2).toString()) << endl;
return false;
}
| bool QGpCoreTools::DateTimeFromString::dd_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::ddd_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::dddd_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::h_parsed | ( | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toInt(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
_ampm=IgnoreAMPM;
if(_current[0].isDigit() || _current[0].isSpace()) {
if(_current[1].isDigit()) {
_hour=_current.left(2).toInt();
if(_hour<=23) {
_current+=2;
return true;
}
} else {
_hour=_current.left(1).toInt();
_current+=1;
return true;
}
}
App::stream() << tr("expected a number between 0 and 23: '%1'").arg(_current.left(2).toString()) << endl;
return false;
}
| bool QGpCoreTools::DateTimeFromString::H_parsed | ( | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toInt(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(_current[0].isDigit() || _current[0].isSpace()) {
if(_current[1].isDigit()) {
_hour=_current.left(2).toInt();
if(_hour<=12) {
_current+=2;
return true;
}
} else {
_hour=_current.left(1).toInt();
_current+=1;
return true;
}
}
App::stream() << tr("expected a number between 0 and 12: '%1'").arg(_current.left(2).toString()) << endl;
return false;
}
| bool QGpCoreTools::DateTimeFromString::hh_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::HH_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::M_parsed | ( | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toInt(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(_current[0].isDigit() || _current[0].isSpace()) {
if(_current[1].isDigit()) {
_month=_current.left(2).toInt();
if(_month>=1 && _month<=12) {
_current+=2;
return true;
}
} else {
_month=_current.left(1).toInt();
if(_month>=1) {
_current+=1;
return true;
}
}
}
App::stream() << tr("expected a number between 1 and 12: '%1'").arg(_current.left(2).toString()) << endl;
return false;
}
| bool QGpCoreTools::DateTimeFromString::m_parsed | ( | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toInt(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(_current[0].isDigit() || _current[0].isSpace()) {
if(_current[1].isDigit()) {
_minute=_current.left(2).toInt();
if(_minute<=59) {
_current+=2;
return true;
}
} else {
_minute=_current.left(1).toInt();
_current+=1;
return true;
}
}
App::stream() << tr("expected a number between 0 and 59: '%1'").arg(_current.left(2).toString()) << endl;
return false;
}
| bool QGpCoreTools::DateTimeFromString::MM_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::mm_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::MMM_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::MMMM_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::other_parsed | ( | const QChar & | c | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(c!=_current[0]) {
App::stream() << tr("wrong character: '%1'").arg(_current.left(1).toString()) << endl;
return false;
} else {
_current+=1;
return true;
}
}
| bool QGpCoreTools::DateTimeFromString::quote_parsed | ( | const StringSection & | text | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::StringSection::beginWith(), QGpCoreTools::endl(), QGpCoreTools::StringSection::size(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(_current.beginWith(text)) {
_current+=text.size();
return true;
}
App::stream() << tr("expected '%1'").arg(text.toString()) << endl;
return false;
}
| bool QGpCoreTools::DateTimeFromString::s_parsed | ( | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toInt(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(_current[0].isDigit() || _current[0].isSpace()) {
if(_current[1].isDigit()) {
_second=_current.left(2).toInt();
if(_second<=59) {
_current+=2;
return true;
}
} else {
_second=_current.left(1).toInt();
_current+=1;
return true;
}
}
App::stream() << tr("expected a number between 0 and 59: '%1'").arg(_current.left(2).toString()) << endl;
return false;
}
| bool QGpCoreTools::DateTimeFromString::ss_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::ssz_parsed | ( | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toDouble(), QGpCoreTools::StringSection::toInt(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(_current[0].isDigit() && _current[1].isDigit()) {
_second=_current.left(2).toInt();
_current+=2;
if(_current[0]=='.' || _current[0]==',') {
int i=1;
while(_current[i].isDigit()) {
i++;
}
_fraction=_current.left(i).toDouble();
_current+=i;
}
return true;
}
App::stream() << tr("expected a decimal number between 00 and 60 (excluding 60): '%1'").arg(_current.left(10).toString()) << endl;
return false;
}
| bool QGpCoreTools::DateTimeFromString::sz_parsed | ( | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toDouble(), QGpCoreTools::StringSection::toInt(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(_current[0].isDigit() || _current[0].isSpace()) {
int i;
if(_current[1].isDigit()) {
i=2;
} else {
i=1;
}
_second=_current.left(i).toInt();
_current+=i;
if(_current[0]=='.' || _current[0]==',') {
i=1;
while(_current[i].isDigit()) {
i++;
}
_fraction=_current.left(i).toDouble();
_current+=i;
}
return true;
}
App::stream() << tr("expected a decimal number between 0 and 60 (excluding 60): '%1'").arg(_current.left(10).toString()) << endl;
return false;
}
| DateTimeData QGpCoreTools::DateTimeFromString::value | ( | bool & | ok | ) | const |
References QGpCoreTools::DateTimeData::date(), QGpCoreTools::endl(), QGpCoreTools::DateTimeData::setDate(), QGpCoreTools::DateTimeData::setTime(), QGpCoreTools::App::stream(), and QGpCoreTools::tr().
Referenced by QGpCoreTools::DateTimeData::fromString().
{
DateTimeData t;
ok=true;
if(!t.setDate(_year, _month, _day)) {
App::stream() << tr("not a valid date") << endl;
ok=false;
return t;
}
if(!_dayShort.isEmpty() && _dayShort!=QDate::shortDayName(t.date().dayOfWeek())) {
App::stream() << tr("%1 is not a %2").arg(t.date().toString("yyyy-MM-dd")).arg(_dayShort) << endl;
ok=false;
}
if(!_dayLong.isEmpty() && _dayLong!=QDate::longDayName(t.date().dayOfWeek())) {
App::stream() << tr("%1 is not a %2").arg(t.date().toString("yyyy-MM-dd")).arg(_dayLong) << endl;
ok=false;
}
int h;
switch(_ampm) {
case UndefinedAMPM:
case IgnoreAMPM:
h=_hour;
break;
case AM:
if(_hour>12) {
App::stream() << tr("not a valid hour with am/pm") << endl;
ok=false;
return t;
}
h=_hour;
break;
case PM:
if(_hour>12) {
App::stream() << tr("not a valid hour with am/pm") << endl;
ok=false;
return t;
}
h=_hour+12;
break;
}
if(!t.setTime(_hour, _minute, _second, _fraction)) {
App::stream() << tr("not a valid time") << endl;
ok=false;
}
return t;
}
| bool QGpCoreTools::DateTimeFromString::yy_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::yyyy_parsed | ( | ) | [protected, virtual] |
| bool QGpCoreTools::DateTimeFromString::z_parsed | ( | ) | [protected, virtual] |
Implements QGpCoreTools::DateTimeParser.
References QGpCoreTools::endl(), QGpCoreTools::StringSection::left(), QGpCoreTools::App::stream(), QGpCoreTools::StringSection::toInt(), QGpCoreTools::StringSection::toString(), and QGpCoreTools::tr().
{
if(_current[0].isDigit() || _current[0].isSpace()) {
if(_current[1].isDigit()) {
if(_current[2].isDigit()) {
_fraction=_current.left(3).toInt()*0.001;
_current+=3;
} else {
_fraction=_current.left(2).toInt()*0.001;
_current+=2;
}
} else {
_fraction=_current.left(1).toInt()*0.001;
_current+=1;
}
return true;
}
App::stream() << tr("expected a number between 0 and 999: '%1'").arg(_current.left(3).toString()) << endl;
return false;
}
| bool QGpCoreTools::DateTimeFromString::zzz_parsed | ( | ) | [protected, virtual] |