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

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

Open
irsath opened this issue Nov 28, 2022 · 0 comments

Comments

@irsath
Copy link

irsath commented Nov 28, 2022

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)

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

No branches or pull requests

1 participant