Calendar functions - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Calendar functions (/thread-8085.html) |
Calendar functions - JMB - 04-01-2017 10:07 AM The input syntax used for dates in these calendar functions that I have coded, is the same used by the HP Prime built-in functions: YYYY.MMDD. The valid range of dates is also the range used by the HP Prime built-in functions: from 1582.1015 (Julian day 2299161) to 9999.1231 (Julian day 5373484). Most functions have a very short coding, because they take avantatge of the HP Prime functions DAYOFWEEK, DDAYS and DATEADD. Listing [Updated. I corrected a typo found by ggauny@live.fr] PHP Code: // Calendar functions Here are some examples: Is_Date_Valid(2017.0401) → 1 Is_Date_Valid(2017.0229) → 0 Is_Leap_Year(2017.0401) → 0 Is_Leap_Year(2017) → 0 Is_Leap_Year(2016.0401) → 1 Is_Leap_Year(2016) → 1 Century(2017.0401) → 21 Century(2017) → 21 Year(2017.0401) → 2017 Month(2017.0401) → 4 Day(2017.0401) → 1 Date_to_Julian_Day(2017.0401) → 2457845 Julian_Day_to_Date(2457845) → 2017.0401 Week_Number(2017.0401) → 13 RE: Calendar functions - ggauny@live.fr - 04-01-2017 02:15 PM Hi JMB, Great and very usefull. This open news ideas for my calendar fonctions. Thanks. RE: Calendar functions - ggauny@live.fr - 04-02-2017 08:56 AM Hi JMB, Just corrected a little typo and add Day_of_week and Date of Easter (this one for complete range). RE: Calendar functions - JMB - 04-02-2017 10:13 AM (04-02-2017 08:56 AM)ggauny@live.fr Wrote: Hi JMB, Thanks for your comments and additions. Just one thing, your function Day_of_week does the same as the built-in function DAYOFWEEK with the difference that it returns 0 for Sunday, while DAYOFFWEEK returns 7. If you want to keep the name "Day_of_Week", it's easier: PHP Code: Day_of_Week(d) PHP Code: Day_of_Week(d) |