I am looking for a library that can parse time from given user input. Proper time formats are: hh:mm, BUT optionally it could be AM or PM at the end to specify if it is 12h or 24h format.
The result I want to achieve is to get the time and merge it with predefined date (without time). Our app should parse time without knowing exact culture of the user. Besides: Are there any other proper time formats?
I tried moment.js, but with no luck. It would be almost fine but I would need to manually check if user entered am/pm or not.
Some more info:
User can enter: "8:36 PM", "8:36", "14:00". All those values should be parsed to store time in 24h format.
When user enters "14:00 PM" parsing should fail (I should display validation error)
I know I could parse this by some regexp or sth, but shouldn't be there any ready to go libraries?