]> git.evergreen-ils.org Git - OpenSRF.git/blob - doc/TZ-handling.txt
LP#1824184: Change potentially slow log statements to subroutines
[OpenSRF.git] / doc / TZ-handling.txt
1 Propagating client time zone in OpenSRF
2 =======================================
3
4 OpenSRF has long inspected the envelope of incoming requests for information
5 about the client's locale and made this information available to business
6 logic.  This is used, among other things, to drive transparent translation of
7 in-database strings within Evergreen.  In addition to locale, OpenSRF will
8 now respect client-supplied adjustment to the effective time zone in which it
9 operates, and provide that information to the business logic layer of
10 applications built on the framework.
11
12 Client
13 ------
14
15 As most clients that have time zones which differ from that of the server on
16 which the OpenSRF processes run are, in fact, web browsers, it is necessary
17 to include time zone detection directly within the browser.  This will be
18 stored in a cookie to be sent with all subsequent HTTP requests, and used in
19 all OpenSRF-over-HTTP calls made using the JavaScript bindings for OpenSRF,
20 including those for WebSockets communication.
21
22 For non-browser clients, such as support scripts written in Perl or other
23 scripting languages, the local system's mechanisms for detecting time zone
24 is relied upon.  For instance, Perl scripts can directly read the TZ
25 environment variable.
26
27 Additionally, the srfsh client now reads its local time zone from the
28 environment and passes that to the server. 
29
30 Server
31 ------
32
33 Within OpenSRF services implemented in Perl, this information is now passed up
34 to the business logic layer via the TZ environment variable, and is reverted
35 to the server's value at the end of each request.  This allows automatic,
36 transparent use of the client's time zone in almost all cases, and provides a
37 system-normal access mechanism when direct access is required.
38
39 For OpenSRF services implemented in C, the time zone information is provided
40 as part of the request context object that is passed to implementation
41 functions.  In particular, this allows services that interact with a database
42 to set the time zone in which the database interprets timestamps to that of
43 the client.
44