Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCL function format_date() #689

Open
johakoch opened this issue Jan 31, 2023 · 1 comment
Open

HCL function format_date() #689

johakoch opened this issue Jan 31, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@johakoch
Copy link
Collaborator

johakoch commented Jan 31, 2023

Provide a format_date() function from stdlib (https://pkg.go.dev/github.com/zclconf/go-cty/cty/function/stdlib#FormatDate)

Example (by @afflerbach ):

    add_response_headers = {
      # format_date/date_format
      Last-Modified = format_date("Mon, 2 Jan 2006 15:04:05 MST") # Go
      Expires = format_date("EEE, d MMM yyyy HH:mm:ss z", unixtime() + 3600) # Java
    }

However, the FormatDate from stdlib (as used in https://developer.hashicorp.com/terraform/language/functions/formatdate) is

func FormatDate(format cty.Value, timestamp cty.Value) (cty.Value, error)

FormatDate reformats a timestamp given in RFC3339 syntax into another time syntax defined by a given format string.

@johakoch johakoch added the enhancement New feature or request label Jan 31, 2023
@malud
Copy link
Collaborator

malud commented Feb 3, 2023

For the user we want to simplify the usage with specific parts of a date/timestamp.
Which standard we would prefer? e.g. YYYY-MM vs yyyy-mm ?

Does a go library exist which fulfills this requirements?

Which input formats are valid?
RFC3339 # 2006-01-02T15:04:05Z07:00
Unix
ISO8601
RFC850 = "Monday, 02-Jan-06 15:04:05 MST"
RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST"

should we accept number and string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants