simple_datetime

Date, Time, Duration, and Age Calculations for Eiffel

v1.0.0 MIT

Overview

simple_datetime provides a fluent API for working with dates, times, durations, ages, and date ranges in Eiffel. Chain operations naturally with Design by Contract validation.

Features

SIMPLE_DATE

Date arithmetic, formatting (ISO/American/European), weekday detection

SIMPLE_TIME

12/24 hour format, AM/PM, time period detection (morning/afternoon)

SIMPLE_DATE_TIME

Combined date+time with ISO 8601 support

SIMPLE_DURATION

Time spans, ISO 8601 durations, human-readable output

SIMPLE_AGE

Age calculation, lifecycle stages (child/teen/adult/senior)

SIMPLE_DATE_RANGE

Periods, overlap detection, business days calculation

Installation

<library name="simple_datetime"
        location="$SIMPLE_DATETIME\simple_datetime.ecf"/>

Quick Start

local
    d: SIMPLE_DATE
    age: SIMPLE_AGE
    dur: SIMPLE_DURATION
do
    -- Date operations
    create d.make (2025, 12, 7)
    print (d.to_iso8601)      -- "2025-12-07"
    print (d.plus_days (7).to_american)  -- "12/14/2025"

    -- Age calculation
    create age.make_from_dates (birth, today)
    print (age.to_string)     -- "25 years, 5 months"
    print (age.is_adult)      -- True

    -- Duration
    create dur.make (2, 3, 30, 0)  -- 2d, 3h, 30m
    print (dur.to_human)      -- "2 days, 3 hours, 30 minutes"
end

API Reference

SIMPLE_DATE

make (year, month, day: INTEGER)
make_from_iso8601 (s: STRING)
plus_days (n): SIMPLE_DATE
plus_months (n): SIMPLE_DATE
to_iso8601, to_american, to_european: STRING
is_weekend, is_weekday: BOOLEAN

SIMPLE_TIME

make (hour, minute, second: INTEGER)
to_24hour, to_12hour: STRING
is_morning, is_afternoon, is_evening: BOOLEAN

SIMPLE_DURATION

make (days, hours, minutes, seconds: INTEGER)
make_from_iso8601 (s: STRING)
to_iso8601: STRING
to_human: STRING
total_seconds: INTEGER_64

SIMPLE_AGE

make_from_dates (birth, reference: SIMPLE_DATE)
years, months, days: INTEGER
is_child, is_teen, is_adult, is_senior: BOOLEAN
is_at_least (years): BOOLEAN

SIMPLE_DATE_RANGE

make (start_date, end_date: SIMPLE_DATE)
make_month (year, month: INTEGER)
contains (date): BOOLEAN
overlaps (other): BOOLEAN
total_days, business_days: INTEGER