I am trying to check if a given time is valid, using any of python's multiple datetime
libraries. This given time would be in 24hr format, and examples of valid inputs are 2359
, 0000
, 1330
, while examples of invalid inputs would be 2400
, 2360
, 2500
.
May I ask if there is a better way to check the validity of the input, without parsing through the strings to check individually?
Preferably using python libraries, if possible
If there are no such libraries, may I instead ask how this should be done in regex?