The Museum of HP Calculators

HP Forum Archive 15

[ Return to Index | Top of Index ]

HP-41 Date to Week / Week to Date conversion
Message #1 Posted by Geir Isene on 18 Feb 2006, 6:29 p.m.

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
      
Re: HP-41 Date to Week / Week to Date conversion
Message #2 Posted by Karl Schneider on 18 Feb 2006, 10:18 p.m.,
in response to message #1 by Geir Isene

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

            
Program submissions
Message #3 Posted by Vassilis Prevelakis on 19 Feb 2006, 12:19 a.m.,
in response to message #2 by Karl Schneider

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

                  
Re: Program submissions
Message #4 Posted by Geir Isene on 19 Feb 2006, 3:55 a.m.,
in response to message #3 by Vassilis Prevelakis

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.

                        
Re: Program submissions
Message #5 Posted by Vassilis Prevelakis on 19 Feb 2006, 7:20 a.m.,
in response to message #4 by Geir Isene

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

                              
Re: Program submissions
Message #6 Posted by Geir Isene on 19 Feb 2006, 9:03 a.m.,
in response to message #5 by Vassilis Prevelakis

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.

            
Re: HP-41 Date to Week / Week to Date conversion
Message #7 Posted by Geir Isene on 19 Feb 2006, 2:22 p.m.,
in response to message #2 by Karl Schneider

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
                  
Re: HP-41 Date to Week / Week to Date conversion
Message #8 Posted by Karl Schneider on 23 Feb 2006, 10:51 p.m.,
in response to message #7 by Geir Isene

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


[ Return to Index | Top of Index ]

Go back to the main exhibit hall