[SparForte][Banner]
[Top Main Menu] Intro | Tutorials | Reference | Packages | Examples | Contributors   [Back Page]      [Next Page]  

Calendar Package

The calendar package provides date and time routines for SparForte. These include determining the current date and time, determining the year, performing date arithmetic and more.

GCC Ada equivalent: Ada.Calendar

The calendar package defines 4 special types:

  • calendar.year_number - an integer year number (1901..2099)
  • calendar.month_number - an integer month number (1..12)
  • calendar.day_number - an integer day number (1..31)
  • calendar.day_duration - a floating point number of seconds
  • calendar.time - a point in time

year_number, month_number, day_number are subtypes in Ada, but are declared as types in AdaScript to emphasize that they represent incompatible values.

Limited arithmetic: a duration can be added or subtracted from a calendar.time value. "calendar.clock - 1.0" subtracts 1 second from the current time. "calendar.clock + 2.5" adds 2.5 seconds to the current time.

Comparing times: time values can be compared with >, >=, <, <=, =, /=, in, and not in.


t := calendar.clock

Return the current time.
Example: current_time := clock;
Ada Equivalent: Ada.Calendar.Clock
Parameters:
t return value calendar.time required the current time


y := calendar.year( t )

Return the year of the given time.
Example: the_year := calendar.year( t );
Ada Equivalent: Ada.Calendar.Year
Parameters:
y return value calendar.year_number required the year value for the time (1901..2099)
t in calendar.time required the time


m := calendar.month( t )

Return the year of the given time.
Example: the_month := calendar.month( t );
Ada Equivalent: Ada.Calendar.Month
Parameters:
m return value calendar.month_number required the month value for the time (1..12)
t in calendar.time required the time


d := calendar.day( t )

Return the day of the given time.
Example: the_year := calendar.day( t );
Ada Equivalent: Ada.Calendar.Day
Parameters:
d return value calendar.day_number required the day value for the time (1..31)
t in calendar.time required the time


y := calendar.seconds( t )

Return the seconds of the given time.
Example: the_seconds := calendar.seconds( t );
Ada Equivalent: Ada.Calendar.Seconds
Parameters:
y return value calendar.day_duration required the seconds of the day (floating point value)
t in calendar.time required the time


calendar.split( t, y, m, d, s )

Return the year, month, day and seconds value for the given time.
Example: calendar.split( t, year, month, day, secs );
Ada Equivalent: Ada.Calendar.Split
Parameters:
t in calendar.time required the time
y out calendar.year_number required the year value for the time (1901..2099)
m out calendar.month_number required the month value for the time (1..12)
d out calendar.day_number required the day value for the time (1..31)
s out calendar.day_duration required the seconds of the day (floating point value)


t := calendar.time_of( y, m, d, s )

Create a time from year, month, day and seconds values.
Example: the_time := calendar.time_of( 2002, 3, 15, 125.6 );
Ada Equivalent: Ada.Calendar.Time_Of
Parameters:
t return value calendar.time required the time
y in calendar.year_number required the year value for the time (1901..2099)
m in calendar.month_number required the month value for the time (1..12)
d in calendar.day_number required the day value for the time (1..31)
s in calendar.day_duration required the seconds of the day (floating point value)
=> current_time : calendar.time := calendar.clock
=> ? calendar.year( current_time )

 2002
=> calendar.seconds( current_time )
 8.19477557630540E+04
=> return
 
[Right Submenu]

 Summary

 arrays

 calendar

 cgi

 command_line

 db/ postgresql

 directory_operations

 enums

 files

 lock_files

 mysql

 numerics

 os

 pen

 sound

 source_info

 stats

 strings

 System

 text_io

 units

[Back to Top] Back To Top [Small Forte Symbol]