Loading...
Searching...
No Matches
Date

Definition

Lightweight date and time utilities used by the fpx preprocessor.

This module provides a compact datetime type together with a small set of date/time operations required by fpx. Its primary purpose is to support expansion of the predefined macros:

  • __DATE__
  • __TIME__
  • __TIMESTAMP__

Rather than providing a complete calendaring framework, this module focuses on the functionality required by preprocessing tasks:

  • Retrieval of the current local date and time using date_and_time()
  • Construction of datetime objects from numeric components or strings
  • Parsing of commonly encountered date/time representations
  • Flexible formatting through to_string(fmt)
  • Day-of-week computation using Zeller's congruence

The implementation deliberately remains lightweight and dependency-free. It is not intended to replace dedicated date/time libraries, but instead provides exactly the capabilities required by fpx while remaining portable across standard-conforming Fortran compilers.

Examples

  1. Expanding predefined macros:
    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')
  2. Constructing a datetime from a string:
    type(datetime) :: build_time
    build_time = datetime('2025-08-12 09:30:00')
    print *, build_time%to_string('ddd-MMM-yyyy')
  3. Constructing a datetime from components:
    type(datetime) :: epoch
    epoch = datetime(1970, 1, 1)
    print *, epoch%to_string()
  4. Timestamping preprocessing operations:
    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...