HP-41 Date to Week / Week to Date conversion



#9

Here's a program that converts a date to the ISO week number and a week number to the starting date of that week (monday as specified by ISO). It takes the date in the normal format. The week number to be converted to the date (monday) can be WW for the current year or WW,YYYY for any year.

D-W obviously converts a date to the ISO week number while W-D naturally does the reverse.


001 *LBL "D-W"
002 ENTER
003 ENTER
004 XEQ 01
005 X<>Y
006 DDAYS
007 7
008 /
009 2,1
010 +
011 INT
012 RTN
013 *LBL "W-D"
014 ENTER
015 INT
016 X NE Y?
017 SF 05
018 2
019 -
020 7
021 *
022 FS?C 05
023 GTO 02
024 DATE
025 LBL 03
026 XEQ 01
027 X<>Y
028 DATE+
029 RTN
030 LBL 01
031 100
032 *
033 FRC
034 100
035 /
036 4,01
037 +
038 ENTER
039 DOW
040 8
041 -
042 CHS
043 +
044 RTN
045 LBL 02
046 X<>Y
047 FRC
048 100
049 /
050 1,1
051 +
052 GTO 03
053 END

#10

Geir --

Thank you for the contribution, but I think it needs some more work before it is ready for the MoHPC HP-41 Software Library.

You should mention that the program requires an HP-41CX or an HP-41C/CV with Time Module.

What is "date in the normal format"? We use MM.DDYYYY in the US, but Europe uses DD.MMYYYY. The Time Module and the HP-41CX support both. (Flag 31 clear = MDY; Flag 31 set = DMY).

Also, several examples would be helpful.

I get -12 as the answer, running "D-W" for MM.DDYYYY = 12.182006. That doesn't seem correct, but the program was entered correctly.

Regards,

-- KS



#11

I'd encourage people developing programs intended for release to the community to use the old HP program library submission forms.

Look in any "Users's library solutions book" in the MoHPC DVD for the format.

-----------------------


Karl Schneider wrote:

> I get -12 as the answer, running "D-W" for MM.DDYYYY = 12.182006.
> That doesn't seem correct, but the program was entered
correctly.

The program assumes dates in the European format (DD.MMYYYY). As Karl suggested, the program should check flag 31 and behave accordingly.

**vp


#12

Quote:
I'd encourage people developing programs intended for release to the community to use the old HP program library submission forms.

Releasing it here makes it possible to get feedback on it (like the flag 31). Thanks.


#13

Geir Isene wrote:
> Releasing it here makes it possible to get feedback on it (like the flag 31).

By all means.

My comment was not about posting here. In fact I think this is the best place to post new programs.

I was talking about the format of the submission. Specifically, that by following the HP User Library layout you are helped to provide all the info that users will require.

For example, the forms include a section describing the input, another with examples of use, etc. A lot of the programs in the Solution books were submitted to the program library by the user community.

Best Regards

**vp


#14

Ah, point taken. I do that on more involved programs. Had the idea that this little conversion needed no such "overhead". But at the same time I am a "standardization maniac", so I'll adopt it for all my programs.

#15

Quote:
What is "date in the normal format"? We use MM.DDYYYY in the US, but Europe uses DD.MMYYYY. The Time Module and the HP-41CX support both. (Flag 31 clear = MDY; Flag 31 set = DMY).

The program now supports both date conventions. Bear in mind that it does however show the first monday of the week when you enter the week number and execute "W-D". This is according to the ISO week number specification.

Quote:
Also, several examples would be helpful.

Enter (in DMY mode):

2,012006
XEQ'D-W
and you get:
1

Enter (in MDY mode):

11,2007
XEQ'W-D
and you get:
3,122007

Enter (in MDY mode):

11
XEQ'W-D
and you get:
3,132006

Quote:
I get -12 as the answer, running "D-W" for MM.DDYYYY = 12.182006. That doesn't seem correct, but the program was entered correctly.

Fixed:


001 *LBL "D-W"
002 ENTER
003 ENTER
004 XEQ 01
005 X<>Y
006 DDAYS
007 7
008 /
009 2,1
010 +
011 INT
012 RTN
013 *LBL "W-D"
014 ENTER
015 INT
016 X NE Y?
017 SF 05
018 2
019 -
020 7
021 *
022 FS?C 05
023 GTO 02
024 DATE
025 LBL 03
026 XEQ 01
027 X<>Y
028 DATE+
029 RTN
030 LBL 01
031 100
032 *
033 FRC
034 100
035 /
036 FC? 31
037 1,04
038 FS? 31
039 4,01
040 +
041 ENTER
042 DOW
043 8
044 -
045 CHS
046 DATE+
047 RTN
048 LBL 02
049 X<>Y
050 FRC
051 100
052 /
053 1,1
054 +
055 GTO 03
056 END

#16

Geir --

Thank you for the improvements to your program. If you submit it to the MoHPC HP-41 Software Library, you could pick one of the a better templates for formatting the posting.

-- KS


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP-41(CL): The easiest way to transfer FOCAL programs from a Linux PC to the HP-41 Geir Isene 13 5,610 12-05-2013, 02:40 AM
Last Post: Hans Brueggemann
  Prime: how to detect date format giancarlo 1 1,467 12-02-2013, 11:21 AM
Last Post: Michael de Estrada
  HP 35s polar/rectangular conversion CD Dodds 6 2,621 11-28-2013, 02:39 PM
Last Post: Dieter
  [WP 34s] Pressure Conversion Factors Timothy Roche 8 3,106 11-04-2013, 07:17 PM
Last Post: Dave Shaffer (Arizona)
  More programs for polar-rectangular conversion on HP Prime Michael de Estrada 4 1,953 11-04-2013, 12:43 AM
Last Post: Michael de Estrada
  Date/time formats R. Pienne 4 2,187 11-01-2013, 12:43 PM
Last Post: Marcus von Cube, Germany
  How to set the Date.Time etc on a WP34S Harold A Climer 4 1,878 10-29-2013, 09:32 PM
Last Post: FORTIN Pascal
  Date/time programs for the HP 35s R. Pienne 0 1,071 10-03-2013, 02:37 PM
Last Post: R. Pienne
  Flash Flood Warning: 9/16/2013 (One Week from HHC13) Eddie W. Shore 8 2,838 09-17-2013, 09:20 PM
Last Post: Craig Ruff
  HHC 2013: One Week To Go Eddie W. Shore 2 1,463 09-13-2013, 05:32 PM
Last Post: Craig Ruff

Forum Jump: