DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSF_TIMEZONES_PVT

Source


1 PACKAGE BODY csf_timezones_pvt AS
2 /* $Header: CSFDCTZB.pls 120.1 2011/02/22 05:24:37 ramchint ship $ */
3 
4   -------------------------------------------------------------------------
5   -- global package variables
6   -------------------------------------------------------------------------
7   g_server_tz  varchar2(300) := null;
8   g_client_tz  varchar2(300) := null;
9   g_tz_enabled varchar2(1)   ;
10 
11   -------------------------------------------------------------------------
12   -- forward declaration of private functions
13   -------------------------------------------------------------------------
14   PROCEDURE init;
15 
16   -------------------------------------------------------------------------
17   -- public functions
18   -------------------------------------------------------------------------
19 
20   FUNCTION get_server_tz_code return varchar2
21   IS
22   BEGIN
23     return g_server_tz;
24   END get_server_tz_code;
25 
26   FUNCTION get_client_tz_code return varchar2
27   IS
28   BEGIN
29     return g_client_tz;
30   END get_client_tz_code;
31 
32   FUNCTION tz_enabled return varchar2
33   IS
34   BEGIN
35     return g_tz_enabled;
36   END tz_enabled;
37 
38   -- when p_client_tz is set, then user profile will
39   -- be overridden
40   FUNCTION date_to_client_tz_chardt
41   ( p_dateval in date ) return varchar2
42   IS
43   BEGIN
44     return fnd_date.date_to_displaydt(p_dateval,calendar_aware => 1);
45   END date_to_client_tz_chardt;
46 
47   FUNCTION date_to_client_tz_chartime
48   ( p_dateval in date
49   , p_mask    in varchar2 default null ) return varchar2
50   IS
51     l_dateval date := null;
52   BEGIN
53     -- convert server date into client date
54     l_dateval := date_to_client_tz_date(p_dateval);
55     return to_char(l_dateval, nvl(p_mask,'hh24:mi'));
56   END date_to_client_tz_chartime;
57 
58   FUNCTION date_to_client_tz_date
59   ( p_dateval in date ) return date
60   IS
61     l_chardt  varchar2(300) := null;
62   BEGIN
63     -- convert to client time
64     l_chardt := date_to_client_tz_chardt(p_dateval);
65     -- convert back to date value without tz conversion
66     return fnd_date.displaydt_to_date(l_chardt,g_server_tz,calendar_aware => 1);
67   END date_to_client_tz_date;
68 
69   FUNCTION date_to_server_tz_date
70   ( p_dateval in date ) return date
71   IS
72     l_server_cur_time date := null;
73     l_client_cur_time date := null;
74     l_offset          number := null;
75   BEGIN
76     l_server_cur_time := sysdate;
77     l_client_cur_time := date_to_client_tz_date(l_server_cur_time);
78     l_offset := l_server_cur_time - l_client_cur_time;
79     return p_dateval + l_offset;
80   END date_to_server_tz_date;
81 
82   -------------------------------------------------------------------------
83   -- forward declaration of private functions
84   -------------------------------------------------------------------------
85   PROCEDURE init
86   IS
87   BEGIN
88     g_server_tz := fnd_timezones.get_server_timezone_code;
89     g_client_tz := fnd_timezones.get_client_timezone_code;
90     g_tz_enabled := 'N';
91 
92     -- this function is currently not present in fnd_timezones 1158
93     -- copied from AFTZONEB.pls 115.3 and modified
94     if  nvl(fnd_profile.value('ENABLE_TIMEZONE_CONVERSIONS'),'N') = 'Y'
95     and g_server_tz is not null
96     and g_client_tz is not null
97     then
98       -- flag initiated as 'N'
99       g_tz_enabled := 'Y';
100     end if;
101   END init;
102 
103 BEGIN
104   init;
105 END csf_timezones_pvt;