Lightweight, high-performance date/time handling for the fpx preprocessor This module provides a compact datetime type and essential operations used primarily for expanding the standard predefined macros.
- __DATE__ -> e.g. 'Aug-12-2025'
- __TIME__ -> e.g. '14:35:27'
- __TIMESTAMP__ -> e.g. 'Tue 12-Aug-2025 14:35:27'
Features:
- now() returns current local date/time using date_and_time()
- Flexible string formatting via to_string(fmt)
- Parsing from common string formats (ISO, US, RFC-like)
- Day-of-week calculation via Zeller's congruence
- Elemental and pure functions where possible for performance
- Minimal memory footprint using small integer kinds (int8, int16)
Used internally by fpx_macro during __DATE__, __TIME__, and __TIMESTAMP__ expansion.
Examples
- Expand standard predefined macros (as done internally):
type(datetime) :: dt
dt = now()
print *, '__DATE__ >> ', dt%to_string('MMM-dd-yyyy')
print *, '__TIME__ >> ', dt%to_string('HH:mm:ss')
print *, '__TIMESTAMP__ >> ', dt%to_string('ddd-MMM-yyyy HH:mm:ss')
- Parse date from string:
type(datetime) :: build_time
build_time = datetime('2025-08-12 09:30:00')
print *, 'build on: ', build_time%to_string('ddd-MMM-yyyy')
- Get current time for logging:
type(datetime) :: dt
dt = now()
print *, 'Preprocessing started at ', dt%to_string('HH:mm:ss')