Language and development rules: Difference between revisions

Jump to navigation Jump to search
Line 265: Line 265:


== Dates and Timezones ==
== Dates and Timezones ==
Dolibarr wants an application that is multi-user and multi-location. It's therefore necessary to store dates in the right format. To avoid problems with conversions the following rules should be applied:
Dolibarr is an application that is multi-user and multi-location. It's therefore necessary to store dates in the right format. To avoid problems with conversions, the following rules should be applied:


* Une date en mémoire doit être au format Timestamp GMT.
* A date into memory must always be stored with Timestamp GMT format.
* Une date stockée en base de données contient le Timestamp GMT en rapport avec la date soumise dans la requête en heure locale <b>du serveur PHP</b>. Cela ne concerne pas les dates mises à jour automatiquement par la base (champ '''tms''' en base).
* A date stored into database, is the GMT Timestamp of date submitted into the request usng the <b>PHP server</b> timezone. This does not apply to date update automatically by database (fields '''tms''' into database).
Ainsi le 1er janvier 1970, 3 heures à Paris (TZ=+1) = 2 heures à Greenwitch (TZ=0) sera stocké en mémoire 7200 et sera soumis à la base de données avec la chaine '19700101030000' (PHP convertit en heure de son TZ et la base déconvertit avec son TZ qui est le même que celui de PHP).
For exemple le 1st january 1970, 3 hour at Paris (TZ=+1) = 2 hour at Greenwitch (TZ=0) will be stored into memory with value 7200 and will be submitted into a SQL request to database with the string '19700101030000' (PHP convert into its TZ hour and databse will unconvert it using its timezone too that is same than PHP).


Les méthodes select doivent donc traduire les champs dates lus qui sont au format chaine TZ de la base ('19700101030000') par appel de la méthode db->jdate afin de récupérer une information en mémoire au format Timestamp GMT. Et les méthodes insert doivent lors de la génération de la requête convertir la date mémoire connue en variable, par la méthode db->idate (Voir exemples générés par le squelette).
All select methods should translate date fields, that are with format TZ of database ('19700101030000'), into a timestamp field by calling the method db->jdate. This is to store into memory a GTM Timestamp date. All insert methods must convert, during generation of SQL request, the memory date into the string by using db->idate (you may find examples into skeleton).


* Les dates mises à jour automatiquement par la base (champ '''tms''' en base) contiennent le Timestamp GMT au moment où la modification est faite. Les méthodes select récupèrent directement cette donnée en mémoire au format Timestamp GMT.
* Dates that are update automatically (field '''tms''' into database) contains a GMT Timestamp GMT of date when change is done.


== UTF8/ISO encoding ==
== UTF8/ISO encoding ==

Navigation menu