Post Reply 
WP34s: date functions and negative years
01-17-2015, 06:39 PM (This post was last modified: 01-17-2015 07:07 PM by Dieter.)
Post: #1
WP34s: date functions and negative years
While playing around with some calendar and date algorithms I discovered an unexpected behaviour of some related functions on the 34s. There seems to be an issue, or at least an inconsistency, with some of its date commands. While everything looks fine for dates down to 1 Jan 0000, earlier (i.e. negative) dates are handled as if they were positive.

Example (assuming mode):

 18.032002   D->J  2452352
-18.032002   D->J  2452352
             J->D  18.032002

On the other hand, negative (i.e. BC) dates seem fine for the 34s if this is a returned result:

  989904     J->D -18.032002  Monday  // date correct, but wrong day of week

The returned date (18 Mar 2003 B.C.) is fine, but the displayed day of week is not (should be Sunday). Maybe a final call of the WDAY routine converts the negative date back to positive: 18 March 2002 indeed was a Monday.

The affected functions seem to be D–>J, J–>D, DAYS+, ΔDAYS, DATE–> and maybe others. In all these cases a negative year is changed to positive. Maybe (!) the underlying problem is in the DATE-> function that splits a date into day, month and year. This function generally seems to return a positive year to the stack. If DATE–> is called by other date routines, it's obvious that negative years will produce wrong results:

-2002 ENTER 3 ENTER 18  ->DATE   -18.032002  Monday   // correct negative date, but wrong day of week (cf. previous J->D example)
 DATE->     X:18    Y:3    Z:2002    // year now is positive
 ->DATE     18.032002

According to the manual the date functions are not limited to positive years. If there was such a limitation I would expect an error message ("Domain error") instead of a wrong result. Otherwise lg —100 should return 2 as well. ;-) However, I think negative input should be allowed since the 34s produces such results as valid output and the common date algorithms work down to 1 January –4712 = JD 0. Only years before –4712 should be rejected. Likewise, negative Julian day numbers should be considered invalid, both as input and output.

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

Messages In This Thread
WP34s: date functions and negative years - Dieter - 01-17-2015 06:39 PM

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