Calendar functions
|
04-01-2017, 10:07 AM
(This post was last modified: 04-02-2017 04:17 PM by JMB.)
Post: #1
|
|||
|
|||
Calendar functions
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 |
|||
04-01-2017, 02:15 PM
Post: #2
|
|||
|
|||
RE: Calendar functions
Hi JMB,
Great and very usefull. This open news ideas for my calendar fonctions. Thanks. Gérard. |
|||
04-02-2017, 08:56 AM
(This post was last modified: 04-02-2017 09:01 AM by ggauny@live.fr.)
Post: #3
|
|||
|
|||
RE: Calendar functions
Hi JMB,
Just corrected a little typo and add Day_of_week and Date of Easter (this one for complete range). Gérard. |
|||
04-02-2017, 10:13 AM
(This post was last modified: 04-02-2017 10:46 AM by JMB.)
Post: #4
|
|||
|
|||
RE: Calendar functions
(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) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)