RosettaCodeData/Task/Long-year/Terraform/long-year-3.terraform
2023-07-01 13:44:08 -04:00

16 lines
417 B
Text

variable year {
type = string
default = ""
}
locals {
ystr = var.year != "" ? var.year : split("-",timestamp())[0]
y = tonumber(local.ystr)
e = local.y - 1
dec31 = local.y * 365 + floor(local.y/4) - floor(local.y/100) + floor(local.y/400)
jan1 = local.e * 365 + floor(local.e/4) - floor(local.e/100) + floor(local.e/400) + 1
}
output isLong {
value = (local.dec31 % 7 == 4 || local.jan1 % 7 == 4)
}