# Libraries for Magic Smoke by (c) Konrad Rosenbaum, 2007-2010
-LIBS += -L../zip -lzip -L../pack/qtbase -lqwbase
-INCLUDEPATH += ../zip ../pack/qtbase
+LIBS += -L../zip -lzip -L../pack/qtbase -lqwbase -L../tzone -ltzdata
+INCLUDEPATH += ../zip ../pack/qtbase ../tzone
//TODO!!
}
-void MLocalFormat::setTimeZone(QString olsenname, QList< MOTimeTransition > transitions)
+void MLocalFormat::setTimeZone(QString olsenname)
{
//TODO!!
}
/**overrides the local time zone
\param olsenname the name of the local timezone in olsen notation, eg. "Europe/Berlin"
\param transitions a list of time transitions, if missing the system attempts to locate the transition DB itself*/
- virtual void setTimeZone(QString olsenname,QList<MOTimeTransition> transitions=QList<MOTimeTransition>());
+ virtual void setTimeZone(QString olsenname);
/**overrides the formatting to be non-localized, numbers use decimal dot and no thousand separator, no currency symbol and "-" as negative sign; otherwise things stay the same; this is a helper for the shortcut methods like cent2str*/
virtual void setNonLocalized();
<Property name="description" type="string"/>
</Class>
- <Class name="TimeTransition">
+ <!-- <Class name="TimeTransition">
<Doc>Helper class: encapsulates a single transition between UTC-offsets for a timezone. This is based on the Olsen TZ database and used by ServerFormat.</Doc>
<Property name="ts" type="int64">The Unix timestamp (seconds since Epoch) at which the transition occurs.</Property>
<Property name="offset" type="int">Offset in seconds from UTC (positive is east).</Property>
<Property name="abbr" type="astring">The abbreviated name of the timezone during this period</Property>
<Property name="isdst" type="bool">true if this is a daylight saving time</Property>
- </Class>
+ </Class> -->
<Class name="ServerFormat">
<Doc>Transport class for server formatting settings. This is used by both UIs to format numbers, dates, money, etc. The XML version of it is stored in the template directory, distributed between main and language dependent directory.</Doc>
<Property name="currencysymbol" type="astring">The currency used</Property>
<Property name="moneynegative" type="astring">One or two characters: for negative money values the first one is placed in front of the money value and the second one behind the money value</Property>
<Property name="timezone" type="astring">Olsen database time zone name</Property>
- <Property name="TZtransitions" type="List:TimeTransition">list of all precalculated transitions in this timezone, how far into the future calculations go depends on the server, usually at the moment till 2037</Property>
+ <!-- <Property name="TZtransitions" type="List:TimeTransition">list of all precalculated transitions in this timezone, how far into the future calculations go depends on the server, usually at the moment till 2037</Property> -->
</Class>
</Wolf>
</Transaction>
<Transaction name="GetLanguage" updating="no">
- <Doc>This transaction returns basic language and formatting settings from the server - it must be used before the client displays any times or monetary values, even if it does not indend to translate any strings.</Doc>
+ <Doc>This transaction returns basic language and formatting settings from the server - it must be used before the client displays any times or monetary values, even if it does not indend to translate any strings. If the transaction fails on the first attempt (eg. because the language could not be found), the client MUST repeat the request with "C" as language to retrieve formatting rules - "C" as language MUST succeed on the server, regardless of any other settings.</Doc>
<Input>
<Var name="language" type="astring">The language that the client wants to use, use "C" for no translation wanted.</Var>
<Var name="format" type="astring">The translation file format that the client supports: either "ts" for Qt translation XML source files, or "qm" for translated binary Qt translation files.</Var>
$nlst=explode("_",trim($trans->getlanguage()));
//set format object
if(count($nlst)>0)
- $trans->setformats(new ServerFormat($nlst[0]));
+ $trans->setformats(new WOServerFormat($nlst[0]));
else
- $trans->setformats(new ServerFormat();
+ $trans->setformats(new WOServerFormat());
//if this is "C", abort parsing and return
if(strtolower(trim($trans->getlanguage()))=="c")
return;
$trans->abortWithError(translate("Translation","Format must be either 'ts' or 'qm'."));
//does the syntax match?
foreach($nlst as $nm)
- if(!ereg("^[a-zA-Z]{1,3}$",$nm))
+ if(!preg_match("/^[a-zA-Z]{1,3}$/",$nm))
$trans->abortWithError(translate("Translation","Language invalid."));
//find the longest match for language
for($i=count($nlst);$i>0;$i--){
parent::__construct();
global $template;
$this->loadConfig($template."/format.cfg");
- if($lang!="")
+ if($lang!="" && preg_match('/^[a-zA-Z0-9_-]+$/',$lang))
$this->loadConfig($template."/".$lang."/format.cfg");
}
case "moneydecimals":$this->setmoneydecimals($val);break;
case "currencysymbol":$this->setcurrencysymbol($val);break;
case "moneynegative":$this->setmoneynegative($val);break;
- case "timezone":$this->settimezone($val);$this->loadtimezone();break;
+ case "timezone":$this->settimezone($val);break;
default: die("Unknown keyword in format config $file line ".($num+1));break;
}
}
}
-
- /** \internal helper for loadConfig to initialize timezone transitions*/
- protected function loadtimezone()
- {
- $dtz=new DateTimeZone($this->prop_timezone);
- $tr=array();
- foreach($dtz->getTransitions() as $tran){
- $t=new WOTimeTransition;
- $t->setts($tran["ts"]);
- $t->setoffset($tran["offset"]);
- $t->setabbr($tran["abbr"]);
- $t->setisdst($tran["isdst"]);
- $tr[]=$t;
- }
- $this->prop_TZtransitions=$tr;
- }
}
?>
\ No newline at end of file