(15C) Julian Day to Day of Week [ISO; 12C Formula]
|
08-26-2016, 01:39 PM
(This post was last modified: 08-27-2016 08:24 PM by Nick.)
Post: #1
|
|||
|
|||
(15C) Julian Day to Day of Week [ISO; 12C Formula]
Formula: ISO Day of Week = JD MOD 7 + 1
- Same formula as 12C [1 = Monday .. 7 = Sunday] Input: X = JD (Julian Day) Output: X = DOW (ISO Day of Week) Size: 15 Bytes Requires: (15C) MM.DDYYYY or DD.MMYYYY to Julian Day [Stack-Only] (or equivalent) Note: The stack is not preserved. Enjoy, Nick Code: 01 LBL 0 Comments: 14 INT(x + .5) ' Rounding per precision loss during MOD |
|||
09-18-2016, 05:39 PM
(This post was last modified: 09-18-2016 05:57 PM by Dieter.)
Post: #2
|
|||
|
|||
RE: (15C) Julian Day to Day of Week [ISO; 12C Formula]
(08-26-2016 01:39 PM)Nick Wrote: Formula: ISO Day of Week = JD MOD 7 + 1 Yes, using FRAC for the mod function will produce roundoff errors. But why don't you simply do it this way? Code: 01 GSB 0 That's shorter and does not require any rounding. BTW, I assume the first step is not LBL 0 but GSB 0 (to call the JDN routine). ;-) While we're at it: may I link to my HP35s calendar programs? They convert from and to JDN, calculate the day of week and implement a ΔDAYS and DATE+ function and more. Dieter |
|||
08-24-2024, 12:26 PM
Post: #3
|
|||
|
|||
RE: (15C) Julian Day to Day of Week [ISO; 12C Formula]
I am not able to get the right number for today: 8.242024 should give 6, not 5!
|
|||
08-26-2024, 02:50 PM
(This post was last modified: 08-26-2024 04:23 PM by ThirdPoliceMan.)
Post: #4
|
|||
|
|||
RE: (15C) Julian Day to Day of Week [ISO; 12C Formula]
A machine translation (DeepL) was used for the English version of this posting.
For this topic I have written somewhat more extensive routines for Day of Week, Day of Year; Week of Year (and Julian Day) for the HP15CE. The simplest form of a calendar. It follows ISO 8601. I used three different subroutines for this, which can also be used for other purposes or on their own. These three routines are part of other programmes in the memory of the HP15CE and have been adapted here for the listing. I am not a mathematician, physicist or programmer by profession, so these routines could certainly be made a little more efficient here and there. If there so, I would be grateful for any helpful suggestions. Label B is the calendar routine (Day of Weak; Day of Year; Week of Year). Note: No check has been programmed for the first and last week of a year (to save memory space), the user must check the correctness himself (it is of course simple). Usage: Day STO 1 Month STO 2 Year STO 3 f 'B'. ------------------------------------------------- LBL B == Day of Week - Day of Year - Week of Year ------------------------------------------------- Input T | Z | Day (R01) Y | Month (R02) X | Year (R03) Output T | Z | Week of Year Y | Day of Year X | Day of Week Label A is an MOD function which also outputs the integer remainder (I often need this for different things; for example: 768 ENTER 60 f 'A' = 12 Hours 48 Minutes): ------------ LBL A == MOD ------------ Input T | Z | Y | numerator X | denominator Output T | numerator Z | denominator Y | Integer ratio X | Integer remainder Label D is a routine that returns the Julian date for a given date. Also applies to dates before 15-10-1582 (1582-10-15). (Usage: Day STO 1 Month STO 2 Year STO 3 f 'D') ---------------------- LBL D == Date => JDate ---------------------- Input T | Z | Day (R01) Y | Month (R02) X | Year (R03) Output T | Z | Y | X | Julian Day 12:00 (Noon) Listing: Code:
Thomas |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)