1: package body hr_gcc_hijrah_functions as
2: /* $Header: pegcchjf.pkb 120.0 2005/05/31 09:16:13 appldev noship $ */
3:
4: function hijrah_to_gregorian
5: (p_input_date in varchar2)
24: l_date date;
25: l_input_date varchar2(10);
26: begin
27: if p_input_date is not null then
28: hr_gcc_hijrah_functions.validate_date(p_input_date,l_input_date);
29: l_hij_year := to_number(substr(l_input_date,1,4)) - 1;
30: l_hij_month := to_number(substr(l_input_date,6,2)) - 1;
31: l_hij_day := to_number(substr(l_input_date,9,2)) ;
32: l_cnt1 := floor(l_hij_year * 354.36887);
119: l_new_greg_date date;
120: l_new_hij_date varchar2(10);
121: l_input_date varchar2(10);
122: begin
123: hr_gcc_hijrah_functions.validate_date(p_input_date,l_input_date);
124: l_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_input_date),'YYYY/MM/DD');
125: l_new_greg_date := l_greg_date + p_num;
126: l_new_hij_date := hr_gcc_hijrah_functions.gregorian_to_hijrah(l_new_greg_date);
127: return (l_new_hij_date);
120: l_new_hij_date varchar2(10);
121: l_input_date varchar2(10);
122: begin
123: hr_gcc_hijrah_functions.validate_date(p_input_date,l_input_date);
124: l_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_input_date),'YYYY/MM/DD');
125: l_new_greg_date := l_greg_date + p_num;
126: l_new_hij_date := hr_gcc_hijrah_functions.gregorian_to_hijrah(l_new_greg_date);
127: return (l_new_hij_date);
128: end add_days;
122: begin
123: hr_gcc_hijrah_functions.validate_date(p_input_date,l_input_date);
124: l_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_input_date),'YYYY/MM/DD');
125: l_new_greg_date := l_greg_date + p_num;
126: l_new_hij_date := hr_gcc_hijrah_functions.gregorian_to_hijrah(l_new_greg_date);
127: return (l_new_hij_date);
128: end add_days;
129:
130: function days_between
136: l_diff number;
137: l_high_date varchar2(10);
138: l_low_date varchar2(10);
139: begin
140: hr_gcc_hijrah_functions.validate_date(p_high_date,l_high_date);
141: hr_gcc_hijrah_functions.validate_date(p_low_date,l_low_date);
142: l_high_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_high_date),'YYYY/MM/DD');
143: l_low_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_low_date),'YYYY/MM/DD');
144: l_diff := l_high_greg_date - l_low_greg_date;
137: l_high_date varchar2(10);
138: l_low_date varchar2(10);
139: begin
140: hr_gcc_hijrah_functions.validate_date(p_high_date,l_high_date);
141: hr_gcc_hijrah_functions.validate_date(p_low_date,l_low_date);
142: l_high_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_high_date),'YYYY/MM/DD');
143: l_low_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_low_date),'YYYY/MM/DD');
144: l_diff := l_high_greg_date - l_low_greg_date;
145: return(l_diff);
138: l_low_date varchar2(10);
139: begin
140: hr_gcc_hijrah_functions.validate_date(p_high_date,l_high_date);
141: hr_gcc_hijrah_functions.validate_date(p_low_date,l_low_date);
142: l_high_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_high_date),'YYYY/MM/DD');
143: l_low_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_low_date),'YYYY/MM/DD');
144: l_diff := l_high_greg_date - l_low_greg_date;
145: return(l_diff);
146: end days_between;
139: begin
140: hr_gcc_hijrah_functions.validate_date(p_high_date,l_high_date);
141: hr_gcc_hijrah_functions.validate_date(p_low_date,l_low_date);
142: l_high_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_high_date),'YYYY/MM/DD');
143: l_low_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_low_date),'YYYY/MM/DD');
144: l_diff := l_high_greg_date - l_low_greg_date;
145: return(l_diff);
146: end days_between;
147:
151: l_day varchar2(30);
152: l_greg_date date;
153: l_input_date varchar2(10);
154: begin
155: hr_gcc_hijrah_functions.validate_date(p_input_date,l_input_date);
156: l_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_input_date),'YYYY/MM/DD');
157: select ltrim(rtrim(to_char(l_greg_date,'D')))
158: into l_day
159: from dual;
152: l_greg_date date;
153: l_input_date varchar2(10);
154: begin
155: hr_gcc_hijrah_functions.validate_date(p_input_date,l_input_date);
156: l_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_input_date),'YYYY/MM/DD');
157: select ltrim(rtrim(to_char(l_greg_date,'D')))
158: into l_day
159: from dual;
160: return(hr_general.decode_lookup('GCC_HIJRAH_DAYS',l_day));
166: l_month number;
167: l_greg_date date;
168: l_input_date varchar2(10);
169: begin
170: hr_gcc_hijrah_functions.validate_date(p_input_date,l_input_date);
171: l_month := to_number(substr(l_input_date,6,2));
172: return(hr_general.decode_lookup('GCC_HIJRAH_MONTHS',l_month));
173: end get_month;
174:
178: l_day varchar2(10);
179: l_greg_date date;
180: l_input_date varchar2(10);
181: begin
182: hr_gcc_hijrah_functions.validate_date(p_input_date,l_input_date);
183: l_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_input_date),'YYYY/MM/DD');
184: select ltrim(rtrim(to_char(l_greg_date,'D')))
185: into l_day
186: from dual;
179: l_greg_date date;
180: l_input_date varchar2(10);
181: begin
182: hr_gcc_hijrah_functions.validate_date(p_input_date,l_input_date);
183: l_greg_date := to_date(hr_gcc_hijrah_functions.hijrah_to_gregorian(l_input_date),'YYYY/MM/DD');
184: select ltrim(rtrim(to_char(l_greg_date,'D')))
185: into l_day
186: from dual;
187: return(l_day);
192: return number as
193: l_first_date varchar2(10);
194: l_input_date varchar2(10);
195: begin
196: hr_gcc_hijrah_functions.validate_date(p_input_date,l_input_date);
197: l_first_date := substr(l_input_date,1,4)||'/01/01';
198: return(days_between(l_input_date,l_first_date));
199: end get_yearday;
200:
319: end if;
320:
321: end validate_date;
322:
323: end hr_gcc_hijrah_functions;