Softanza
DémarrerEnglish
Softanza
Recherche · narration

Time Programming in Softanza: A Gentle Introduction

par Mansour Ayouni · dans le dépôt depuis le 2025-10-02 · essai de paradigme · sans domaine de l'Atlas

Cet article est écrit en anglais, comme la bibliothèque.

Time is everywhere in software. Birthdays, deadlines, business hours, event timestamps—each scenario needs a different lens. Softanza recognizes this with three specialized classes that work together seamlessly.

Meet the Family

stzDate handles pure calendar logic:

Haro
oBirthday = new stzDate("15/06/1990")
? oBirthday.Age()                #--> 35

illustration

stzTime manages clock operations:

Haro
oStart = new stzTime("09:15:00")
? oStart + 75                    #--> 10:30:00 (adds 75 minutes)

illustration

stzDateTime combines both for complete timestamps:

Haro
oMeeting = StzDateTimeQ("2024-03-15 14:30:00")
? oMeeting + "2 days 3 hours"    #--> 2024-03-17 17:30:00

illustration

Why Three Classes?

You don't calculate age with timestamps. You don't schedule meetings with just dates. Separating concerns keeps code clear:

  • Planning a project deadline? → stzDate
  • Measuring task duration? → stzTime
  • Logging user actions? → stzDateTime

Each class focuses on its domain while sharing a common design philosophy.

The Common Language

All three speak the same dialect:

Haro
# Natural arithmetic
oDate + "3 months"
oTime + "45 minutes"
oDateTime + "2 days"

# Intuitive comparisons
? oDate1 < oDate2                #--> TRUE
? oTime1 > "14:30:00"            #--> FALSE

# Human-readable output
? oDate.ToHuman()                #--> tomorrow
? oTime.ToHuman()                #--> Half past 2 PM
? oDateTime.ToRelative()         #--> 2 hours ago

illustration

This consistency means learning one class teaches you patterns for all three.

A Quick Taste

Here's real power in action—calculating when to send event reminders:

Haro
# Event next month
oEvent = StzDateTimeQ("2024-06-20 15:00:00")

# Send email 3 days before
oReminder = oEvent - "3 days"
? oReminder.ToLong()
#--> Monday, June 17, 2024 3:00:00 PM

# Extract just the date for calendar display
oEventDate = oEvent.DateQ()
? oEventDate.DayName()           #--> Thursday

# Calculate event duration
oEnd = oEvent + "2 hours"
? oEvent.HoursTo(oEnd)           #--> 2

illustration

See how they interoperate? DateQ() and TimeQ() methods let you extract components as full-featured objects when you need specialized operations.

Built on Solid Ground

Behind the expressive syntax lies the Softanza Engine (Zig-based). Operations execute in microseconds. You get both elegance and performance.

Dive Deeper

Each class deserves its own exploration:

These guides show the full API with real-world examples and design rationale.

Start Experimenting

Haro
# Try this right now
oToday = TodayQ()
? oToday + "100 days"

oNow = TimeQ()
? oNow.ToHuman()

oTimestamp = StzDateTimeQ("")
? oTimestamp.ToRelative()

illustration

Time programming in Softanza feels less like wrestling an API and more like having a conversation. The three classes are there when you need them, invisible when you don't.

Lectures liées

Citer

Mansour Ayouni. « Time Programming in Softanza: A Gentle Introduction ». Softanza narrations, 2025. https://mayouni.github.io/stzsite/fr/narrations/stz-time-programming-intro.html

Exécuté au nom de Haro le 2026-10-08 20:43 dans la bibliothèque au commit 4a184e6f0, bloc après bloc dans un seul processus : 0 bloc(s) sur 6 ont tenu leur promesse ; les autres sont des illustrations. Le code des articles est du code Haro. Là où un article a été écrit avant que la langue prenne son nom actuel, le nom a été changé et rien d'autre. Genre, domaine et série lus dans le nom du fichier, année tirée du premier commit : dérivés, jusqu'à ce que l'article porte son propre en-tête. Le fichier sur GitHub(s'ouvre dans un nouvel onglet)