Post Reply 
HP Prime: Day Number of the Year
01-21-2014, 03:31 PM (This post was last modified: 01-21-2014 09:21 PM by Damien.)
Post: #2
RE: HP Prime: Day Number of the Year
Hi everyone,

For any gregorian date (year>1582). The Nth day of the year can be calculated with the formulas:

For non leap year:
For leap year:
With Month from 1 to 12, Day from 1 to 31.
(Taken from a book about astronomical calculation written by Jean MEEUS)

For the Prime something like that should work fine:

EXPORT Date2Days(date)
LOCAL b,a,m,j;
// date : [YYYY].[MM][DD]
 IP(date)▶a; // YYYY
 IP(FP(date)*100)▶m; // MM
 IP(FP(FP(date)*100)*100)▶j; // DD
// gregorian leap year ?
 IF (NOT(a MOD 4) AND a MOD 100)  
     OR (NOT (a MOD 400)) THEN 
  b:=1; // leap year 
  b:=2; //ordinary year
 RETURN IP(275*m/9)-b*IP((m+9)/12)+j-30;

Enter dates in HP Prime format : YYYY.MMDD

Example: 1970 june 9th (1970.0609) gives N=160.


Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: HP Prime: Day Number of the Year - Damien - 01-21-2014 03:31 PM

User(s) browsing this thread: 1 Guest(s)