close
Skip to content

DateFormatToLayout doesn't support escape character and uppercase "PM" in the output #45

@irsath

Description

@irsath

Hey,

I noticed the DateFormatToLayout doesn't fully support the java RFC as stated in the code documentation.

The java RFC says:

Text can be quoted using single quotes (') to avoid interpretation.
....
....

Date and Time Pattern Result
"yyyy.MM.dd G 'at' HH:mm:ss z" 2001.07.04 AD at 12:08:56 PDT

Or this exact date time pattern will not give the same result as instead of having the literal at, it will be converted to pmt because of dateFormat = strings.Replace(dateFormat, "a", "pm", 1) (source)

I also noticed while writing this issue that it's impossible to have uppercase PM in the output as the code replace a first and then look for aa in the format pattern (source):

dateFormat = strings.Replace(dateFormat, "a", "pm", 1)
dateFormat = strings.Replace(dateFormat, "aa", "PM", 1)

The G pattern is also not supported (thanks to @fridgepoet to have noticed it)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions