12-Hour Time (HH:MM AM/PM)
datetime.time.hm_12hHours and minutes with AM/PM, no seconds. Common in US scheduling applications and user interfaces.
Worked samples
DuckDB 1.5.5 · finetype 0.6.64
| Value | As TIME |
|---|---|
| 10:30 AM | 10:30:00 |
| 11:59 PM | 23:59:00 |
- %I
- hour, 12-hour clock
- %M
- minutes
- %p
- AM or PM
Shape
^\d{2}:\d{2} [AP]M$| Value | Length | Shape |
|---|---|---|
| 10:30 AM | 8 | matches |
| 11:59 PM | 8 | matches |
| 10:30 A | 7 | rejected: one character short |
Background
Origin
The 12-hour clock divides the 24 hours of the day into two periods, a.m. and p.m.[1] The abbreviation a.m. comes from the Latin ante meridiem, meaning before midday, and p.m. from post meridiem, meaning after midday.[1] The 12-hour clock can be traced back as far as Mesopotamia and ancient Egypt.[1] Egyptian clocks dating to around 1500 BC divided their times of use into 12 hours each.[1] The 12-hour clock reached its modern form in the 16th century.[1]
Style guides variously write the abbreviations in small capitals, as uppercase AM and PM without periods, as uppercase letters with periods, or in lowercase.[1] The form this type describes, a two-digit hour, a colon, two-digit minutes, a space and an uppercase AM or PM, reads more like software output than the a.m. of printed prose. (Meridian's view)
Use
In Python's datetime module, %p is the locale's equivalent of either AM or PM, such as AM and PM for en_US but am and pm for de_DE.[2] Python's documentation notes that, with strptime, the %p directive only affects the parsed hour if the %I directive is used to parse the hour.[2] DuckDB's documentation shows strftime with %I:%M:%S %p producing 08:32:45 PM for 20:32:45.[3]
Microsoft Excel's TIMEVALUE function accepts a time text in any of Excel's time formats, giving 6:45 PM as an example.[4] Expect to meet unpadded hours such as 6:45 PM alongside padded ones, and decide whether to pad them before you validate a column against this form. (Meridian's view)
NIST's Times of Day FAQs say that 12 a.m. and 12 p.m. are ambiguous and should not be used.[5] By convention, 12 a.m. denotes midnight and 12 p.m. denotes noon.[1] Some authors have used the reverse convention, with 12 a.m. meaning noon and 12 p.m. meaning midnight.[1] NIST suggests specifying an event as occurring on a particular day at 11:59 p.m. or 12:01 a.m.[5] Before converting a column of these times, find out which convention the source system meant by 12:00 AM and 12:00 PM. (Meridian's view)
ISO 8601 uses the 24-hour clock system.[6] When you convert these values, store them as a 24-hour time type and keep the original text if the noon and midnight readings are in any doubt. (Meridian's view)
Sources
- [1]12-hour clocksecondary source
- [2]datetime — Basic date and time typesdocumentation
- [3]Date Format Functionsdocumentation
- [4]TIMEVALUE functiondocumentation
- [5]Times of Day FAQsorganisation
- [6]ISO 8601secondary source
Detection notes
NEW in v2.
Use it
$ finetype infer -i "10:30 AM" --mode column
→ datetime.time.hm_12h
SELECT ft_infer('10:30 AM');
-- → 'datetime.time.hm_12h'strptime({col}, '%I:%M %p')::TIME
-- Format: %I:%M %pSchema
https://meridian.online/schemas/datetime.time.hm_12h · Frictionless type time · %I:%M %p
finetype taxonomy datetime.time.hm_12h -o json-schema