Merge pull request #5 from trent-/aws-utc-date

Dynamically fetch the UTC date for AWS
This commit is contained in:
mortenbra 2015-04-26 22:45:28 +02:00
commit c9f70a5b53
2 changed files with 57 additions and 51 deletions

View File

@ -17,7 +17,7 @@ as
g_aws_id varchar2(20) := 'my_aws_id'; -- AWS access key ID
g_aws_key varchar2(40) := 'my_aws_key'; -- AWS secret key
g_gmt_offset number := 0; -- your timezone GMT adjustment
g_gmt_offset number := NULL; -- your timezone GMT adjustment
function get_auth_string (p_string in varchar2) return varchar2
@ -100,6 +100,8 @@ end get_aws_id;
function get_date_string (p_date in date := sysdate) return varchar2
as
l_returnvalue varchar2(255);
l_date_as_time timestamp(6);
l_time_utc timestamp(6);
begin
/*
@ -114,7 +116,13 @@ begin
*/
l_returnvalue := to_char(p_date + g_gmt_offset/24, 'Dy, DD Mon YYYY HH24:MI:SS', 'NLS_DATE_LANGUAGE = AMERICAN') || ' GMT';
if g_gmt_offset is null then
l_date_as_time := cast(p_date as timestamp);
l_time_utc := sys_extract_utc(l_date_as_time);
l_returnvalue := to_char(l_time_utc, 'Dy, DD Mon YYYY HH24:MI:SS', 'NLS_DATE_LANGUAGE = AMERICAN') || ' GMT';
else
l_returnvalue := to_char(p_date + g_gmt_offset/24, 'Dy, DD Mon YYYY HH24:MI:SS', 'NLS_DATE_LANGUAGE = AMERICAN') || ' GMT';
end if;
return l_returnvalue;
@ -211,7 +219,7 @@ end set_gmt_offset;
procedure init (p_aws_id in varchar2,
p_aws_key in varchar2,
p_gmt_offset in number)
p_gmt_offset in number := NULL)
as
begin
@ -229,10 +237,9 @@ begin
g_aws_id := p_aws_id;
g_aws_key := p_aws_key;
g_gmt_offset := nvl(p_gmt_offset, g_gmt_offset);
g_gmt_offset := p_gmt_offset;
end init;
end amazon_aws_auth_pkg;
/

View File

@ -43,8 +43,7 @@ as
-- initialize package for use
procedure init (p_aws_id in varchar2,
p_aws_key in varchar2,
p_gmt_offset in number := null);
p_gmt_offset in number := NULL);
end amazon_aws_auth_pkg;
/