module JosieHealth::Utils::Timestamp

Defined in:

timestamp.cr

Class Method Summary

Class Method Detail

def self.format_display(rfc3339 : String) : String #

Format RFC3339 timestamp for display Shows time only if today, otherwise shows date and time


def self.now_rfc3339 : String #

Get current time as RFC3339


def self.parse_ago(ago_str : String) : Time | Nil #

Parse HHMM format (e.g., "0130" = 1 hour 30 minutes ago) to Time Supports formats: HHMM, HMM, MM (pads with zeros) Returns nil if invalid format or out of range


def self.parse_ago_rfc3339(ago_str : String) : String #

Parse HHMM format to RFC3339 string Returns current time as RFC3339 if parsing fails


def self.parse_timestamp(ts : String) : String | Nil #

Parse various timestamp formats to RFC3339 Supports:

  • Full ISO: 2025-01-15T14:30:00 or 2025-01-15T14:30
  • Time with colon: HH:MM (assumes today)
  • Time without colon: HHMM (assumes today) Returns nil if invalid format