C ctime / asctime Format
datetime.timestamp.ctimeOutput of C ctime() and asctime() functions, Python datetime.ctime(), Ruby Time#to_s. Day-of-week abbreviation, month abbreviation, space-padded day, 24-hour time, then 4-digit year.
Worked samples
DuckDB 1.5.5 · finetype 0.6.64
| Value | As TIMESTAMP |
|---|---|
| Mon Jan 15 14:30:00 2024 | 2024-01-15 14:30:00 |
| Tue Dec 31 23:59:59 2019 | 2019-12-31 23:59:59 |
| Sat Jun 1 08:15:30 2024 | 2024-06-01 08:15:30 |
- %a
- abbreviated weekday
- %b
- abbreviated month name
- %-d
- day, no padding
- %H
- hour, 24-hour clock
- %M
- minutes
- %S
- seconds
- %Y
- four-digit year
Written by
- Python
datetime.ctime()
Shape
^[A-Z][a-z]{2} [A-Z][a-z]{2} [\s\d]\d \d{2}:\d{2}:\d{2} \d{4}$| Value | Length | Shape |
|---|---|---|
| Mon Jan 15 14:30:00 2024 | 24 | matches |
| Tue Dec 31 23:59:59 2019 | 24 | matches |
| Sat Jun 1 08:15:30 2024 | 24 | matches |
| Mon Jan 15 14:30:00 202 | 23 | rejected: one character short |
Background
Origin
The FreeBSD manual records that the asctime() function first appeared in Version 5 AT&T UNIX.[1] The asctime() and ctime() functions were standardised in C89 and POSIX.1-1988.[2] The Linux manual page states that the call ctime(t) is equivalent to asctime(localtime(t)).[2]
POSIX defines the output of asctime() with the example string Sun Sep 16 01:03:52 1973, followed by a newline and a terminating null character.[3]
asctime() and ctime() were marked obsolescent in C23 and in POSIX.1-2008, which recommend strftime(3) instead.[2] POSIX says the asctime() function is included only for compatibility with older implementations.[3] cppreference notes that the behaviour of asctime() is undefined if the year has more than 4 digits or is less than the year 1000.[4]
Use
Python's documentation says that, unlike the C function of the same name, time.asctime() does not add a trailing newline.[5] Python's documentation says the output of datetime.ctime() will not include time zone information, whether the input is aware or naive.[6]
RFC 9110 requires a recipient that parses a timestamp in an HTTP field to accept all three HTTP-date formats.[7] RFC 9110 says values in the asctime format are assumed to be in UTC.[7]
Sources
- [1]ctime(3) - FreeBSD 15.1-RELEASE and Ports.quarterly Manual Pagesdocumentation
- [2]ctime(3) - Linux manual pagedocumentation
- [3]asctimestandard
- [4]asctime, asctime_s - cppreference.comsecondary source
- [5]time — Time access and conversions — Python 3.15.0 documentationdocumentation
- [6]datetime — Basic date and time types — Python 3.15.0 documentationdocumentation
- [7]RFC 9110: HTTP Semanticsstandard
Detection notes
New in format coverage expansion. Unix tradition format. Day may be space-padded. Python datetime.ctime(), C ctime()/asctime().
Use it
$ finetype infer -i "Mon Jan 15 14:30:00 2024" --mode column
→ datetime.timestamp.ctime
SELECT ft_infer('Mon Jan 15 14:30:00 2024');
-- → 'datetime.timestamp.ctime'strptime({col}, '%a %b %-d %H:%M:%S %Y')
-- Format: %a %b %-d %H:%M:%S %YSchema
https://meridian.online/schemas/datetime.timestamp.ctime · Frictionless type datetime · any
finetype taxonomy datetime.timestamp.ctime -o json-schema