Skip to content

DateTime Library API

Brom Bresenham edited this page Apr 7, 2024 · 11 revisions

Date.rogue

class Date [compound]

Description

Uses algorithms from:
  http://www.herongyang.com/year/Program-Gregorian-Calendar-Algorithm.html

January 1, 2000 is stored as year=2000, month=1, day=1

Global Properties

Name Type Description
day_names String[]
month_names String[]
standard_days_in_month Int[]

Global Methods

Signature Return Type Description
create( date:String ) Date
create( year:Int32, month:Int32, day:Int32 ) Date
day_of_year( year:Int32, month:Int32, day:Int32 ) Int32
days_in_month( year:Int32, month:Int32 ) Int32
days_in_year( year:Int32 ) Int32
is_leap_year( year:Int32 ) Logical
mdy( month:Int32, day:Int32, year:Int32 ) Date
month_name_to_index( month_name:String ) Int32 January->1, December->12
 Accepts partial month names e.g. "Jan"
today() Date
ymd( year:Int32, month:Int32, day:Int32 ) Date

Properties

Name Type Description
day Int32
month Int32
year Int32

Methods

Signature Return Type Description
day_name() String
day_of_week() Int32 Returns a value 0..6
day_of_year() Int32 Returns a day 0..364/365
days_in_month() Int32
days_in_year() Int32
decremented() Date
description() String
hashcode() Int
incremented() Date
month_name() String
operator+( days:Int32 ) Date
operator+( interval:DateInterval ) Date
operator-( days:Int32 ) Date
operator-( interval:DateInterval ) Date
operator-( other:Date ) Int32 Returns the number of days between the two dates
operator<>( other:Date ) Int For Dates the hash code contains all necessary info so we can use it to compare safely
operator==( other:Date ) Logical
print_to( buffer:PrintWriter )
to<<Object>>() Boxed<<Date>>
to<<String>>() String
to<<String>>( [format="yyyy-mm-dd":String], &verbose ) String Format:
  yyyy - 4-digit year
  yy - 2-digit year
  mm - Month with leading 0 if necessary
  m - Month without any leading 0
  month - Month name spelled out
  mon - 3-letter month name
  dd - Day with leading 0 if necessary
  d - Day without any leading 0
verbose() String

class DateInterval [compound]

Global Methods

Signature Return Type Description
create( years:Int32, months:Int32, days:Int32 ) DateInterval
days( n:Int32 ) DateInterval
months( n:Int32 ) DateInterval
years( n:Int32 ) DateInterval

Properties

Name Type Description
days Int32
months Int32
years Int32

Methods

Signature Return Type Description
description() String
operator+( date:Date ) Date
operator+( other:DateInterval ) DateInterval
operator-( other:DateInterval ) DateInterval
operator==( other:DateInterval ) Logical
print_to( buffer:PrintWriter )
to<<Object>>() Boxed<<DateInterval>>
to<<String>>() String

Time.rogue

class Time [compound]

Global Methods

Signature Return Type Description
create( hour:Int32, minute:Int32, [second=0:Int32], [millisecond=0:Int32] ) Time
create( text:String ) Time
create( total_ms:Int64 ) Time
from_timestamp( timestamp:Timestamp ) Time
now() Time

Properties

Name Type Description
total_ms Int64

Methods

Signature Return Type Description
days() Int32
description() String
hour() Int32
is_am() Logical
is_pm() Logical
millisecond() Int32
minute() Int32
operator+( other:Time ) Time
operator-( other:Time ) Time
operator<>( other:Time ) Int64
operator==( other:Time ) Logical
print_to( buffer:PrintWriter )
second() Int32
to<<Object>>() Boxed<<Time>>
to<<String>>() String
to<<String>>( format:String ) String format
  hh24 - hour in 24-hour format with possible leading 0
  hh12 - hour in 12-hour format with possible leading 0
  hh - same as hh24
  h24 - hour in 24-hour format without any leading 0
  h12 - hour in 12-hour format without any leading 0
  h - same as h24
  mm - minutes with possible leading 0
  m - minutes without any leading 0
  ss - seconds with possible leading 0
  s - seconds without any leading 0
  ms - 3-digit milliseconds with possible leading 0's
  ampm - replaced with 'am' or 'pm' as appropriate
  AMPM - replaced with 'AM' or 'PM' as appropriate
  am/pm - replaced with 'am' or 'pm' as appropriate
  AM/PM - replaced with 'AM' or 'PM' as appropriate
  am - same as ampm
  pm - same as ampm
  AM - same as AMPM
  PM - same as AMPM
total_days() Real
total_hours() Real
total_minutes() Real

TimeInterval.rogue

class TimeInterval [compound]

Description

This time interval can be broken down into days, hours, minutes, seconds, and milliseconds. Those values are all independent and precise.

Global Methods

Signature Return Type Description
create( [flag=true:Logical], [days=0:Int64], [hours=0:Int64], [minutes=0:Int64], [seconds=0:Int64], [milliseconds=0:Int64] ) TimeInterval 'flag' is ignored and is a kludge to disambiguate the compound initializers from this global create method.
create( total_ms:Int64 ) TimeInterval
hms( hours:Real, minutes:Real, seconds:Real, [ms=0:Real] ) TimeInterval

Properties

Name Type Description
total_ms Int64

Methods

Signature Return Type Description
days() Int32
description() String
hours() Int32
is_negative() Logical
milliseconds() Int32
minutes() Int32
operator<>( other:TimeInterval ) Int64
operator==( other:TimeInterval ) Logical
print_to( buffer:PrintWriter )
seconds() Int32
to<<Object>>() Boxed<<TimeInterval>>
to<<String>>() String
total_days() Real
total_hours() Real

Timestamp.rogue

class Timestamp [compound]

Global Properties

Name Type Description
month_names String[]
weekday_names String[]

Global Methods

Signature Return Type Description
create( [value=System.time:Real64] ) Timestamp
create( date:Date, time:Time ) Timestamp
create( date:String ) Timestamp
create( year:Int32, month:Int32, day:Int32, [hour=12:Int32], [minute=0:Int32], [second=0:Int32], [millisecond=0:Int32] ) Timestamp A year earlier than 1970 will result a date of 1969-12-31 on Mac at least. Therefore take the opportunity to adjust years < 100 to be prefixed with the current century, e.g. 19 -> 2019.
gmt_time_zone_offset() Int32 From: https://stackoverflow.com/a/44063597/135791
month_name_to_index( month_name:String ) Int32 January->1, December->12 Accepts partial month names e.g. "Jan"
now() Timestamp
ymd( year:Int32, month:Int32, day:Int32 ) Timestamp Use hour 12 instead of hour 0 as a default so that time change won't mess up the result of adding 24 hours to date

Properties

Name Type Description
value Real64

Methods

Signature Return Type Description
day() Int32
description() String
hashcode() Int
hour() Int32
hour12() Int32
is_am() Logical
is_pm() Logical
millisecond() Int32
minute() Int32
month() Int32
month_name() String
operator+( other:TimeInterval ) Timestamp
operator-( other:TimeInterval ) Timestamp
operator-( other:Timestamp ) TimeInterval
operator<>( other:Timestamp ) Int64
operator==( other:Timestamp ) Logical
print_to( buffer:PrintWriter )
second() Int32
to<<Date>>() Date
to<<Object>>() Boxed<<Timestamp>>
to<<String>>() String
to<<Time>>() Time
to<<String>>( &ymd, &hms, &ms, &format=24, &mdy ) String
weekday() Int32
weekday_name() String
year() Int32
Clone this wiki locally