--- /dev/null
+//
+// C++ Implementation: locale
+//
+// Description:
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "../../misc/misc.h"
+#include <QtCore>
+
+void printout(MLocalFormat&mf)
+{
+ qDebug()<<" 10000 as int" << mf.formatNumber(10000);
+ qDebug()<<" 12345.678 as float" << mf.formatNumber(12345.678);
+ qDebug()<<" 10000 as money" <<mf.formatMoney(10000);
+ qDebug()<<" -10000 as int" << mf.formatNumber(-10000);
+ qDebug()<<" -12345.678 as float" << mf.formatNumber(-12345.678);
+ qDebug()<<" -10000 as money" <<mf.formatMoney(-10000);
+ QDateTime tm(QDate(2003,2,1),QTime(16,5,6,7),Qt::LocalTime);
+ qDebug()<<" time used: "<<tm.toString(Qt::ISODate);
+ qDebug()<<" 1feb2003 4:05:06.007 pm as date"<<mf.formatDate(tm.date());
+ qDebug()<<" 1feb2003 4:05:06.007 pm as time"<<mf.formatTime(tm.time());
+ qDebug()<<" 1feb2003 4:05:06.007 pm as date+time"<<mf.formatDateTime(tm);
+ qDebug()<<" 1feb2003 4:05:06.007 pm as detailed date"<<mf.formatDateTime(tm,"year=%Y/%y month=%M/%m/%N/%n day=%D/%d/%W/%w");
+ qDebug()<<" 1feb2003 4:05:06.007 pm as detailed time"<<mf.formatDateTime(tm,"hour=%H/%h/%A/%a minute=%I/%i second=%S/%s milli=%Z/%z am/pm=%P/%p TZ=%t");
+ qDebug()<<" 1feb2003 4:05:06.007 pm as detailed mistake"<<mf.formatDateTime(tm,"mistake=%k %%=%");
+ qDebug()<<" current time"<<mf.formatDateTime(QDateTime::currentDateTime(),"%Y-%M-%D %H:%I:%S.%Z %t");
+ qint64 u=QDateTime::currentDateTime().toTime_t();
+ qDebug()<<" current time via unix"<<u<<mf.formatDateTime(QDateTime::fromTime_t(u),"%Y-%M-%D %H:%I:%S.%Z %t");
+}
+
+void testreg(MLocalFormat&mf)
+{
+ qDebug()<<"";
+ QRegExp r=mf.moneyRegExp(true,true);
+ qDebug()<<" money regexp"<<r.pattern()<<"is valid"<<r.isValid();
+ qDebug()<<" testing 123.45"<<r.exactMatch("123.45");
+ qDebug()<<" testing 1,23.45"<<r.exactMatch("1,23.45");
+ qDebug()<<" testing -1,23.45"<<r.exactMatch("-1,23.45");
+ qDebug()<<" testing 1,23.456"<<r.exactMatch("1,23.456");
+ qDebug()<<" testing 1_23;456"<<r.exactMatch("1_23;456");
+ qDebug()<<" testing 123.45x"<<r.exactMatch("123.45x");
+ qDebug()<<" testing 123;456Credits"<<r.exactMatch("123;456Credits");
+ qDebug()<<" testing -123;456Credits"<<r.exactMatch("-123;456Credits");
+ qDebug()<<" testing [123;456]Credits"<<r.exactMatch("[123;456]Credits");
+}
+
+void scanin(MLocalFormat&mf)
+{
+ qDebug()<<"";
+ qDebug()<<" scan 1234 as int"<<mf.scanInt(" 1234 ");
+ qDebug()<<" scan -1234 as int"<<mf.scanInt(" -1234 ");
+ qDebug()<<" scan 12,34 as int"<<mf.scanInt(" 12,34 ");
+ qDebug()<<" scan 12_34 as int"<<mf.scanInt(" 12_34 ");
+ qDebug()<<" scan 12/34 as int"<<mf.scanInt(" 12/34 ");
+ qDebug()<<" scan 12.34 as int"<<mf.scanInt(" 12.34 ");
+
+ qDebug()<<"";
+ qDebug()<<" scan 1234.56 as float"<<mf.scanFloat(" 1234.56 ");
+ qDebug()<<" scan 1234 as float"<<mf.scanFloat(" 1234 ");
+ qDebug()<<" scan 12,34.56 as float"<<mf.scanFloat(" 12,34.56 ");
+ qDebug()<<" scan 12_34;56 as float"<<mf.scanFloat(" 12_34;56 ");
+ qDebug()<<" scan -12,34.56 as float"<<mf.scanFloat(" -12,34.56 ");
+
+ qDebug()<<"";
+ qDebug()<<" scan 1234.56 as money"<<mf.scanMoney(" 1234.56 ");
+ qDebug()<<" scan 12,34.56 as money"<<mf.scanMoney(" 12,34.56 ");
+ qDebug()<<" scan 12_34;56 as money"<<mf.scanMoney(" 12_34;56 ");
+ qDebug()<<" scan 12,34.5 as money"<<mf.scanMoney(" 12,34.5 ");
+ qDebug()<<" scan 12,34.567 as money"<<mf.scanMoney(" 12,34.567 ");
+ qDebug()<<" scan 12,34.5.6 as money"<<mf.scanMoney(" 12,34.5.6 ");
+ qDebug()<<" scan 12,34.5,6 as money"<<mf.scanMoney(" 12,34.5,6 ");
+ qDebug()<<" scan 12,34.5 6 as money"<<mf.scanMoney(" 12,34.5 6 ");
+ qDebug()<<" scan -12,34.56 as money"<<mf.scanMoney(" -12,34.56 ");
+ qDebug()<<" scan [12,34.56] as money"<<mf.scanMoney(" [12,34.56] ");
+ qDebug()<<" scan [12_34;56]Cu as money"<<mf.scanMoney(" [12_34;56]Cu ");
+ qDebug()<<" scan -12_34;56Cu as money"<<mf.scanMoney(" -12_34;56Cu ");
+ qDebug()<<" scan -[12_34;56]Cu as money"<<mf.scanMoney(" -[12_34;56]Cu ");
+}
+
+int main(int ac,char**av)
+{
+ QCoreApplication app(ac,av);
+
+ MLocalFormat mf;
+ qDebug()<<"default format:";
+ printout(mf);
+ scanin(mf);
+ testreg(mf);
+
+ qDebug()<<"\nchanging settings:";
+ qDebug()<<"strange names for days and months";
+ mf.setWeekDays(QStringList()<<"mundai"<<"toosdai"<<"whensdai"<<"soorsdai"<<"fraidai"<<"satt-dai"<<"sunndai");
+ mf.setShortWeekDays(QStringList()<<"mun"<<"too"<<"when"<<"soo"<<"frai"<<"satt"<<"sunn");
+ mf.setMonths(QStringList()<<"janner"<<"febber"<<"marsh"<<"abbrill"<<"mai"<<"shoon"<<"shoolai"<<"ogust"<<"sebtumbr"<<"oggdobr"<<"noffembr"<<"dessembr");
+ mf.setShortMonths(QStringList()<<"j1"<<"f2"<<"m3"<<"a4"<<"m5"<<"j6"<<"j7"<<"a8"<<"s9"<<"o10"<<"n11"<<"d12");
+ qDebug()<<"decimal dot=; thousand divider=_ 2 digits per block";
+ mf.setNumberFormat(';','_',2);
+ qDebug()<<"currency=Credits, 3 currency decimals, negative is [123.45]";
+ mf.setMoneyFormat("Credits",3,"[]");
+ printout(mf);
+ scanin(mf);
+ testreg(mf);
+
+ qDebug()<<"\nresetting settings:";
+ mf=MLocalFormat();
+ printout(mf);
+ scanin(mf);
+ testreg(mf);
+}
\ No newline at end of file