[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.

=> current_time : calendar.time := calendar.clock
=> ? calendar.year( current_time )
 2011
=> ? calendar.month( current_time )
 11
=> ? calendar.month( current_time ) in 1..6
false
=> ? calendar.month( current_time ) > 6
true
=> one_minute_from_now : calendar.time := calendar.clock + 60
 
 
Example: Using the calendar package

t := calendar.clock

 

Return the current time (that is, the calendar date and clock time, or the timestamp for this moment in time) as a calendar.time value.

Example

current_time := clock;

Parameters

Param Mode Type Default Description
t return value calendar.time required the current time

Exceptions

-

See Also

-

Compare With

Ada: Ada.Calendar.Clock
PHP: time

d := calendar.day( t )

 

Return the day of the given time as a number between 1 and 31.

Example

the_year := calendar.day( current_time );

Parameters

Param Mode Type Default Description
d return value calendar.day_number required the day value
t in calendar.time required the time

Exceptions

-

See Also

-

Compare With

Ada: Ada.Calendar.Day
PHP: date

d := calendar.day_of_week( t )

 

Return the day of the week of the given time as a number of days since Sunday, an integer between 0 and 6.

Example

the_dow := calendar.day_of_week( current_time );

Parameters

Param Mode Type Default Description
d return value integer required the day value
t in calendar.time required the time

Exceptions

-

See Also

-

Compare With

PHP: date

m := calendar.month( t )

 

Return the month of the given time between 1 and 12.

Example

the_month := calendar.month( current_time );

Parameters

Param Mode Type Default Description
m return value calendar.month_number required the month value
t in calendar.time required the time

Exceptions

-

See Also

-

Compare With

Ada: Ada.Calendar.Month
PHP: date

y := calendar.seconds( t )

 

Return the seconds into the day of the given time as a floating point number between 0.0 and 86,400.0.

Example

the_seconds := calendar.seconds( current_time );

Parameters

Param Mode Type Default Description
y return value calendar.day_duration required the seconds of the day
t in calendar.time required the time

Exceptions

-

See Also

-

Compare With

Ada: Ada.Calendar.Seconds
PHP: date

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

 

Return the year, month, day and seconds value for the given time.

Example

calendar.split( current_time, year, month, day, secs );

Parameters

Param Mode Type Default Description
t in calendar.time required the time
y out calendar.year_number required the year value (1901..2099)
m out calendar.month_number required the month value (1..12)
d out calendar.day_number required the day value (1..31)
s out calendar.day_duration required the seconds of the day (float)

Exceptions

-

See Also

calendar.time_of

Compare With

Ada: Ada.Calendar.Split
PHP: date

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 );

Parameters

Param Mode Type Default Description
t return value calendar.time required the time
y in calendar.year_number required the year value (1901..2099)
m in calendar.month_number required the month value (1..12)
d in calendar.day_number required the day value (1..31)
s in calendar.day_duration required the seconds of the day (float)

Exceptions

-

See Also

calendar.split

Compare With

Ada: Ada.Calendar.Time_Of
PHP: mktime

t := calendar.to_time( j )

Incomplete function for julian dates.

y := calendar.year( t )

 

Return the year value of the given time as a number between 1901 and 2099.

Example

the_year := calendar.year( current_time );

Parameters

Param Mode Type Default Description
y return value calendar.year_number required the year value
t in calendar.time required the time

Exceptions

-

See Also

-

Compare With

Ada: Ada.Calendar.Year
PHP: date

[Right Submenu]

 Summary

 arrays

 btree_io

 calendar

 cgi

 chains

 command_line

 db/ postgresql

 dbm

 directory_operations

 doubly_linked...

 dynamic_hash_...

 enums

 exceptions

 files

 gnat.cgi

 gnat.crc32

 hash_io

 lock_files

 memcache

 memcache.highread

 mysql

 mysqlm

 numerics

 os

 pen

 pen (OpenGL)

 records

 sound

 source_info

 stats

 strings

 System

 teams

 text_io

 templates

 units

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