Loading...
Searching...
No Matches
Date

Definition

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

  1. Expand standard predefined macros (as done internally):
    type(datetime) :: dt
    dt = now()
    print *, '__DATE__ >> ', dt%to_string('MMM-dd-yyyy') ! __DATE__ >> 'Aug-12-2025'
    print *, '__TIME__ >> ', dt%to_string('HH:mm:ss') ! '__TIME__ >> 14:35:27'
    print *, '__TIMESTAMP__ >> ', dt%to_string('ddd-MMM-yyyy HH:mm:ss') ! '__TIMESTAMP__ >> Tue 12-Aug-2025 14:35:27'
  2. 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')
  3. Get current time for logging:
    type(datetime) :: dt
    dt = now()
    print *, 'Preprocessing started at ', dt%to_string('HH:mm:ss')

Data Types

interface  datetime
 Compact representation of date and time Stores all components in minimal integer kinds to reduce memory usage. All fields are public for easy access. More...

Methods

◆ now()

type(datetime) function, public now

Return current local date and time Uses intrinsic date_and_time() and populates all fields including milliseconds.

Returns
the datetime object corresponding to the current time

Remarks

Definition at line 164 of file date.f90.