Created
April 6, 2023 15:53
-
-
Save emibcn/452b47bfdacbede971ee3f0aa157ee24 to your computer and use it in GitHub Desktop.
Revisions
-
emibcn created this gist
Apr 6, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ # This module transforms the time variable into an # RFC 3339 formated date in UTC timezone locals { time_ZZZZZ = formatdate( "YYYY-MM-DD'T'hh:mm:ssZZZZZ", var.time) time_zoneless = formatdate( "YYYY-MM-DD'T'hh:mm:ss", var.time) time_zone_sign = substr( local.time_ZZZZZ, length(local.time_zoneless), 1) time_zone = substr( local.time_ZZZZZ, length(local.time_zoneless) + 1, -1) time_diff = "${ replace(local.time_zone, ":", "h") }m" time_UTC = timeadd( "${local.time_zoneless}+00:00", "${ local.time_zone_sign == "+" ? "-" : "+" }${local.time_diff}") } output "utc" { description = "Time converted to UTC" value = local.time_UTC } variable "time" { description = "Time to be converted to UTC" }