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
Parsing AM/PM #101
Comments
You probably want to use |
Oh wait - that's not in yet. I've been working on a major overhaul to formatting/parsing. There's no field associated with any of the other types of hours beyond the hour of the day. Might be able to add a quick workaround in the next patch release. |
No problem. I'll just add a workaround to my code for now. I'll just go ahead and close this then since you're working on an overhaul. |
Workaround: instead of using wholeNumber(2) {
onParsed { value ->
val hourOfAmPm = value % 12
fields[DateTimeField.HOUR_OF_DAY] = if (hourOfAmPm == 0) 12 else hourOfAmPm
}
} |
Thanks. This does the opposite though, right? I need to convert clock-hour-of-am-pm to hour-of-day based on am-pm-of-day. My ugly workaround is to use different parsers based on whether the string contains "AM" or "PM". The PM parser adds 12 to hour-of-day. |
Bah -- I ripped the code for formatting instead of parsing, so that obviously doesn't work. What you're doing sounds right -- at least until the derived fields are handled better as part of the resolving process. |
Thanks for this useful library! I'm trying to parse a string with AM/PM, but
amPm()
doesn't seem to have any effect.I expected
hour
to be 15, but it's 3. Is this a bug or am I missing something?The text was updated successfully, but these errors were encountered: