aboutsummaryrefslogtreecommitdiffstats
path: root/bin/oxfordshire/open311_services.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2017-05-28 21:31:42 +0200
committerMarius Halden <marius.h@lden.org>2017-05-28 21:31:42 +0200
commit987124b09a32248414faf4d0d6615d43b29ac6f6 (patch)
treea549db8af723c981d3b346e855f25d6fd5ff8aa7 /bin/oxfordshire/open311_services.pm
parentdbf56159e44c1560a413022451bf1a1c4cb22a52 (diff)
parenta085b63ce09f87e83b75cda9b9cd08aadfe75d61 (diff)
Merge tag 'v2.0.4' into fiksgatami-dev
Diffstat (limited to 'bin/oxfordshire/open311_services.pm')
-rw-r--r--bin/oxfordshire/open311_services.pm16
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/oxfordshire/open311_services.pm b/bin/oxfordshire/open311_services.pm
index 12d0754fa..9be598751 100644
--- a/bin/oxfordshire/open311_services.pm
+++ b/bin/oxfordshire/open311_services.pm
@@ -10,6 +10,8 @@ use CGI;
use Encode qw(from_to);
use DBI;
use Time::Piece;
+use Time::Local qw(timelocal);
+use POSIX qw(strftime);
###################################################################
@@ -145,6 +147,20 @@ sub get_date_or_nothing {
return $d;
}
+#------------------------------------------------------------------
+# get_utc_iso8601_string
+# Takes a local date/time string and converts it to UTC, returning
+# a ISO8601-format string.
+# expected format: YYYY-MM-DD HH:MM:SS
+# e.g.: 2016-04-01 13:37:42 -> 2016-04-01T12:37:42Z
+#------------------------------------------------------------------
+sub get_utc_iso8601_string {
+ my $datetime = shift;
+ $datetime =~ s{(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)}{
+ strftime "%Y-%m-%dT%H:%M:%SZ", gmtime(timelocal($6, $5, $4, $3, int($2)-1, int($1)-1900));
+ }e;
+ return $datetime;
+}
1;