File 'base/date.tcl' (part of 'Pool_Base')

Description (short)
Additional date/time functionality
Written by
Andreas Kupries
Description
Additional date/time functionality
Depends on
Tcl
Keywords
date operations, operations on dates and times, time operations, data conversion


::pool::date::2month (date)

Extract the month information from a date.
Argument: date The date to look at.
Returns: A month in the form mm/yyyy.

::pool::date::StripLeadingZeros (x)

Strips leading zeros from a number, preventing octal interpretation
Notes: This implementation is significantly faster than 'regsub {^0*((1-90-9*)|0)$} $x {\1} x'. The regsub averages 160 microsecs in all cases. This realization however requires only ~142 microsecs in the worst case and goes down to ~128 or ~85 microsecs (0-series, {}).
Note, '0 != string compare "" $x' is definitely faster than '$x != {}'. The same holds for the second comparison.
All timings done using tcl 8.0
Argument: x Number forced into decimal interpretation
Returns: a decimal number

::pool::date::eq (a b)

Are the dates a and b equal?
Argument: a first date to compare
Argument: b second date to compare
Returns: 1, if answer is yes, 0 else.

::pool::date::ge (a b)

Is date a greater than or equal to date b?
Argument: a first date to compare
Argument: b second date to compare
Returns: 1, if answer is yes, 0 else.

::pool::date::gt (a b)

Is date a greater than date b?
Argument: a first date to compare
Argument: b second date to compare
Returns: 1, if answer is yes, 0 else.

::pool::date::index (date)

Convert given date into index of day (01/01/year is mapped onto day 1).
Argument: date The date to convert.
Returns: Index of date into its year.

::pool::date::intervalIsMonth (a b)

Checks wether the interval defined by dates a and b covers a single month.
Argument: a Start of interval, inclusive
Argument: b End of interval, inclusive
Returns: 1, if answer is yes, 0 else.

::pool::date::intervalIsYear (a b)

Checks wether the interval defined by dates a and b covers a single year.
Argument: a Start of interval, inclusive
Argument: b End of interval, inclusive
Returns: 1, if answer is yes, 0 else.

::pool::date::isYearStart (date)

Checks wether the given date is the first of january or not.
Argument: date The date to look at.
Returns: 1, if answer is yes, 0 else.

::pool::date::join (y m d)

compose a date from single components
Argument: y The year to use in the composed date
Argument: m The month to use in the composed date
Argument: d The day to use in the composed date
Returns: A date in the form mm/dd/yyyy

::pool::date::joinMonth (y m)

compose a month from single components
Argument: y The year to use in the composed date
Argument: m The month to use in the composed date
Returns: A month in the form mm/yyyy

::pool::date::joinMonthDay (month day)

merge month and day into a complete date
Argument: month The month (mm/yyyy) to use in the composition
Argument: day The day to use in the composition
Returns: A date in the form mm/dd/yyyy

::pool::date::le (a b)

Is date a smaller than or equal to date b?
Argument: a first date to compare
Argument: b second date to compare
Returns: 1, if answer is yes, 0 else.

::pool::date::leMonth (a b)

Is month a smaller than or equal to month b?
Argument: a first month to compare
Argument: b second month to compare
Returns: 1, if answer is yes, 0 else.

::pool::date::leapYear (y)

Determines wether the given year is a leap year or not. The gregorian rule is used, i.e.: Every 4th is a leap year, with the exception of every 100th, but every 400th is one nevertheless.
Argument: y The year to check
Returns: 1 for a leap year, 0 else.

::pool::date::lt (a b)

Is date a smaller than date b?
Argument: a first date to compare
Argument: b second date to compare
Returns: 1, if answer is yes, 0 else.

::pool::date::monthFirstDay (month)

Argument: month month to look at.
Returns: The date for the first day of the given month.

::pool::date::monthLastDay (month)

Argument: month month to look at.
Returns: The date for the last day of the given month.

::pool::date::monthLength (month)

Computes the length of the specified month, in days
Argument: month The month whose length shall be determined.
Returns: The length of month, in days.

::pool::date::monthName (m)

Map a month-number m to an english name.
Argument: m The index to convert (range 01..12)
Returns: The english name of the month m

::pool::date::monthNumber (monthname)

Map the english name of a month (monthname) to its number (range 1..12).
Argument: monthname The name to convert into an number.
Returns: The month number associated to the name.

::pool::date::ne (a b)

Are the dates a and b different?
Argument: a first date to compare
Argument: b second date to compare
Returns: 1, if answer is yes, 0 else.

::pool::date::next (date)

Step from date to next day.
Dangers: A hack is used to get Normal/DST switches (+26 hours instead auf +24). A gregorian calendar is assumed. Entirely missing days are not handled.
Argument: date The date to look at.
Returns: The day after date.

::pool::date::nextMonth (month)

step from specified month to the month after that
Argument: month The month to look at.
Returns: The month after month.

::pool::date::now ()

Determines current date
Returns: The current date in the form mm/dd/yyyy

::pool::date::nowTime ()

Determines current date and time, default format
Returns: The current date and time.

::pool::date::prev (date)

Step from date to previous day.
Dangers: A hack is used to get Normal/DST switches (-22 hours instead of -24). A gregorian calendar is assumed. Entirely missing days are not handled.
Argument: date The date to look at.
Returns: The day before date.

::pool::date::prevMonth (month)

step from specified month to the month before that
Argument: month The month to look at.
Returns: The month before month.

::pool::date::printCalendar (month year chan)

by Ric Klaren <
Prints a formatted calendar (like from the 'cal' application) to the specified channel.
Argument: month Month of the year to print the calendar for.
Argument: year Year to print the calendar for.
Argument: chan (= stdout) The channel to print the calendar to.

::pool::date::split (date y m d)

Split a date into its components, strip away leading zeros to avoid misintepretation as octal numbers.
Argument: date The date to decompose
Argument: y Name of the variable to store the year into.
Argument: m Name of the variable to store the month into.
Argument: d Name of the variable to store the day into.

::pool::date::splitMonth (month y m)

Split a month into its components, strip away leading zeros to avoid misintepretation as octal numbers.
Argument: month The month to decompose.
Argument: y Name of the variable to store the year into.
Argument: m Name of the variable to store the month into.

::pool::date::weekday (date)

Determines day index in a week of a given date
Argument: date The date to calculate the day index from.

::pool::date::weekdayName (weekday)

Map a weekday index (0..6, 0 = sunday) to the english name of the weekday. To obtain a short version do something like (string range (date weekdayName ..) 1 2).
Argument: weekday The index to convert.

::pool::date::yearLength (year)

Computes the length of the given year, in days.
Argument: year Year whose length shall be determined
Returns: The length of year, in days.


Generated by AutoDoc 2.4 at 09/14/2000, invoked by Andreas Kupries