Older Version
Newer Version
harmonv
May 27, 2007
- "Added Zeller's congruence and LBmod function, note for LB3.x users. Many minor edits too."
harmonv
May 27, 2007
- "Added Zeller's congruence and LBmod function, note for LB3.x users. Many minor edits too."
Liberty Basic Day and Date Routines
LB Day-of-Week Conversions
Liberty BASIC is adept at handling various date string formats. It can handle 1- or 2-digit numbers for the month and day. It will also accept fully typed month names or 3-letter abbreviations. Years can be 1, 2, 3 or 4-digit numbers. Years from 0 to 99 are assumed as 2000 to 2099.
Some examples: Jul 4, 06 -- July 04, 2006 -- 7/4/6 -- 07/04/2006
In the LB universe, day 0 was Jan 1, 1901 and dates before 1/1/1901 return negative numbers.
Be aware that negative years are incorrectly handled as positive, so LB's Date$() function can not be relied upon for any date earlier than Jan 1, 100.
Liberty BASIC Day of Week
This routine uses LB's built-in Date$() function.Zeller's Congruence for Day of Week
This version does not use LB's internal Date$() function, so the input parameters must be numbers. This routine might be prefered by LB 3.x users since it does not use the MOD operator.Gregorian Year, Month, Day to Day of Week
Gregorian Year, Month, Day to Julian Day #
Julian Day to Gregorian Year, Month, Day
Note for LB 3.x users
LB 3.x does not have the MOD operator, so you will need to provide one for some of these functions.Example Usage
For the DayofWeek$() function, replace the two lines using MOD with these:
Additional Information
The calculations for the Gregorian date and day routines are from Claus Tøndering's excellent Calendar FAQ page at http://www.tondering.dk/claus/calendar.htmlThey can be freely distributed for all non-commercial uses.