00332223836c5ebd95d7164a9e99a2033241939e
[freeside.git] / rt / docs / timezones_in_charts.pod
1 =head1 INTRO
2
3 Every date in RT's DB is stored in UTC format. This affects charts
4 groupped by time periods (Annually, Monthly, etc.). To produce
5 charts that are in a specific timezone we have to use DB's specific
6 functions to convert time. Each DB has very different requirements.
7
8 =head1 CONFIGURATION
9
10 This code is experimental and you can turn it on and off using
11 boolean option $ChartsTimezonesInDB in the RT config.
12
13 =head1 DATABASE SPECIFIC NOTES
14
15 =head2 mysql
16
17 Time can not just be converted using numeric time shift as this
18 shift value depends on day saving time properties of the time zone.
19
20 mysql since 4.1.3 supports named timezones, but you have to fill
21 special tables with up to date data. On modern systems it's Usually
22 very easy:
23
24     mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
25
26 mysql's doc recommends to restart server. Read more about timezones
27 in mysql in the following document
28 http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html .
29
30 =head2 Postgres
31
32 Postgres database uses system's functions to deal with timezones.
33 You shouldn't do anything particular except making sure that
34 data in F</usr/share/zoneinfo> is up to date. On some systems
35 this means upgrading a system package.
36
37 =head3 Note for users of Pg 7.2 and older or users upgraded from those
38
39 You should be sure that timestamps in RT DB have no TZ set. TIMESTAMP
40 column type in Postgres prior to Pg 7.3 has timezone info by default.
41 In newer versions it's not the case anymore. If you have such system
42 then you should alter columns.
43
44 =head2 Other databases
45
46 There is no implementation for other DBs, yet.
47
48 =head1 FOR DEVELOPERS
49
50 =head2 Postgres
51
52 We use timestamp type for all datetime fields. It either has timezone
53 info or not, by default since Pg 7.3 it has no timezone. Conversion is
54 kinda tricky:
55
56     timezone('Europe/Moscow', timezone('UTC', column_without_tz_info))
57     timezone('to_tz', timezone('from_tz', column_without_tz_info))
58     http://www.postgresql.org/docs/7.4/static/functions-datetime.html#FUNCTIONS-DATETIME-ZONECONVERT
59
60 This function flips HAS_TZ flag on the argument. First call makes
61 no conversion, but flips HAS_TZ flag. So next call flips it back
62 and does actual conversion.
63
64 http://www.postgresql.org/docs/7.4/static/datatype-datetime.html#DATATYPE-TIMEZONES
65
66 =head2 mysql
67
68 Once there is a timezone info loaded in tables on the server
69 we have all the same set of named timezones like in system
70 and DateTime (DateTime project has copy of the TZ data in a module).
71
72 CONVERT_TZ(TS, from, to) exists since mysql 4.1.3. Note that it
73 takes timestamp, so supports limitted range (usuall 1970-2038).
74
75 =head2 Oracle
76
77 Look at FROM_TZ function.
78
79 =head2 SQLite
80
81 As far as I can see has no support.
82
83 =cut
84