Post Reply 
Deltadays and date functions.
05-14-2017, 05:21 PM (This post was last modified: 05-14-2017 05:29 PM by Dieter.)
Post: #29
RE: Deltadays and date functions.
(05-12-2017 11:15 PM)Paul Dale Wrote:  It won't work back until 1 March 0000.

There were some differences in the Julian calendar early on. I also understand that there wasn't a year zero.

On the 34S we only claimed that dates before year 8AD can be incorrect.

Of course Pauli is right regarding the first AD years. Also the Julian calendar was introduced as late as 46 BC, and JDN calculations for all dates before this assume that the calendar's final form was used even centuries and millenniums before. But this assumption is common practice (proleptic calendar), just as the astronomical year numbering where e.g. 333 BC equals year –332. All this is also the way the 34s works.

So here finally is another program version for the 15C (and most other classic RPN HPs) that – with the mentioned caveats – works down to 1 Jan –4712, i.e. 1 Jan 4713 BC, which is considered day 0 of the Julian day number system. Using a small trick, the missing floor() function for negative years was replaced with the 15C's int().

Code:
001  LBL D
002  STO 0
003  R↓
004  3
005  x≤y?
006  GTO 0
007  +
008  9
009  +
010  1
011  STO-0
012  LBL 0
013  R↓
014  1
015  +
016  3
017  0
018  ,
019  6
020  x
021  INT
022  +
023  RCL 0
024  4
025  7
026  1
027  6
028  +
029  3
030  6
031  5
032  ,
033  2
034  5
035  x
036  INT
037  +
038  1
039  5
040  2
041  4
042  -
043  2
044  2
045  9
046  9
047  1
048  6
049  1     ' 2299161 is JDN of first day of Gregorian calendar, 15 Oct 1582
050  x>y?  ' TEST 7 on 15C
051  GTO 1
052  R↓
053  RCL 0
054  EEX
055  2
056  /
057  INT
058  -
059  LSTx
060  4
061  /
062  INT
063  +
064  2
065  +
066  ENTER
067  LBL 1
068  CLX
069  +
070  RTN

Check:
  1 [ENTER]  1  [ENTER] -4712  f[D] → 0
  4 [ENTER] 10 [ENTER]  1582  f[D] → 2299160
15 [ENTER] 10 [ENTER]  1582  f[D] → 2299161
  4 [ENTER]  7  [ENTER]  1979  f[D] → 2444059

As usual, the program does the transition between Julian and Gregorian calendar on the official switch date, i.e. from 4 to 15 Oct 1582 (cf. example above). You may adjust this date by changing the hardcoded constant 2299161 (JDN of 15 Oct 1582) to another value that reflects your local situation. This value is obtained by determining the JDN of the first Gregorian date (using the unmodified program). For instance in Great Britain and its colonies, including the US, 2 Sep 1752 was followed by 14 Sep 1752. So enter 14 Sep 1752 and get 2361222, which then is the value to code in line 043...049.

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


Messages In This Thread
Deltadays and date functions. - Vtile - 05-10-2017, 01:28 PM
RE: Deltadays and date functions. - Vtile - 05-10-2017, 01:50 PM
RE: Deltadays and date functions. - Vtile - 05-10-2017, 03:02 PM
RE: Deltadays and date functions. - Vtile - 05-10-2017, 07:55 PM
RE: Deltadays and date functions. - Dieter - 05-10-2017, 08:30 PM
RE: Deltadays and date functions. - KeithB - 05-10-2017, 04:30 PM
RE: Deltadays and date functions. - Dieter - 05-10-2017, 05:01 PM
RE: Deltadays and date functions. - Vtile - 05-10-2017, 07:16 PM
RE: Deltadays and date functions. - Dieter - 05-10-2017, 08:17 PM
RE: Deltadays and date functions. - Vtile - 05-10-2017, 05:12 PM
RE: Deltadays and date functions. - Dieter - 05-10-2017, 06:17 PM
RE: Deltadays and date functions. - Vtile - 05-11-2017, 11:33 AM
RE: Deltadays and date functions. - Dieter - 05-11-2017, 05:03 PM
RE: Deltadays and date functions. - Vtile - 05-11-2017, 04:17 PM
RE: Deltadays and date functions. - Dieter - 05-12-2017, 08:04 PM
RE: Deltadays and date functions. - Dieter - 05-13-2017, 01:32 PM
RE: Deltadays and date functions. - Dieter - 05-14-2017 05:21 PM
RE: Deltadays and date functions. - Vtile - 05-12-2017, 11:58 PM
RE: Deltadays and date functions. - Dieter - 05-13-2017, 01:33 PM
RE: Deltadays and date functions. - Vtile - 05-13-2017, 07:15 PM
RE: Deltadays and date functions. - Dieter - 05-13-2017, 08:57 PM
RE: Deltadays and date functions. - Vtile - 05-13-2017, 10:30 PM



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