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:

Features:

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

type  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

◆ datetime_parse()

elemental subroutine datetime_parse ( class(datetime), intent(inout) this,
character(*), intent(in) string,
character(*), intent(in), optional fmt )
private

Parse date/time from string using common formats.

Supports ISO, US, and abbreviated month formats. On error, defaults to Unix epoch (1970-01-01 00:00:00) Perform conversion to ISO string

  • d: Represents the day of the month as a number from 1 through 31.
  • dd: Represents the day of the month as a number from 01 through 31.
  • ddd: Represents the abbreviated name of the day (Mon, Tues, Wed, etc).
  • dddd: Represents the full name of the day (Monday, Tuesday, etc).
  • h: 12-hour clock hour (e.g. 4).
  • hh: 12-hour clock, with a leading 0 (e.g. 06)
  • H: 24-hour clock hour (e.g. 15)
  • HH: 24-hour clock hour, with a leading 0 (e.g. 22)
  • m: Minutes
  • mm: Minutes with a leading zero
  • M: Month number(eg.3)
  • MM: Month number with leading zero(eg.04)
  • MMM: Abbreviated Month Name (e.g. Dec)
  • MMMM: Full month name (e.g. December)
  • s: Seconds
  • ss: Seconds with leading zero
  • t: Abbreviated AM / PM (e.g. A or P)
  • tt: AM / PM (e.g. AM or PM
  • y: Year, no leading zero (e.g. 2015 would be 15)
  • yy: Year, leading zero (e.g. 2015 would be 015)
  • yyy: Year, (e.g. 2015)
  • yyyy: Year, (e.g. 2015)

Remarks

Definition at line 243 of file date.f90.

◆ datetime_to_string()

character(:) function, allocatable datetime_to_string ( class(datetime), intent(in) this,
character(*), intent(in), optional fmt )
private

Format datetime as string using flexible format codes Supports many common patterns including those required for __DATE__ and __TIMESTAMP__. Default format: 'yyyy-MM-ddTHH:mm:ss'.

Remarks

Definition at line 357 of file date.f90.

◆ 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.

◆ weekday()

pure elemental integer function weekday ( class(datetime), intent(in) this)
private

Returns the day of the week calculated using Zeller's congruence. Returned value is an integer scalar in the range [0-6], such that:

  • 0: Sunday
  • 1: Monday
  • 2: Tuesday
  • 3: Wednesday
  • 4: Thursday
  • 5: Friday
  • 6: Saturday

Remarks

Definition at line 192 of file date.f90.