Post Reply 
Date from DOY. (A.Pouplier)
01-11-2015, 07:08 PM
Post: #1
Date from DOY. (A.Pouplier)
Code:
(              1 D A T E _ D U _ D O Y     2  E X P O R T   D A T E _ D U _ D O Y ( N , A N ) 
 B E G I N 
 L O C A L   K : = 2 , M , J , J D , J U L : = 0 , C R ; 
 C A S E 
 I F   ( A N > 1 5 8 2 )   A N D   ( N O T ( A N   M O D   4 )   A N D   A N   M O D   1 0 0 )   
 O R   ( N O T ( A N   M O D   4 0 0 ) )   T H E N   K : = 1   E N D ; 
 
 I F   ( A N < 1 5 8 2 )   A N D   i r e m ( A N , 4 ) = = 0   T H E N 
         K : = 1 ; E N D ; 
 E N D ; 
 
 M : = I P [ ( 9 * ( K + N ) / 2 7 5 ) + . 9 8 ] ; 
 I F   N < 3 2   T H E N   1 ¶%M   E N D ; 
 J : = N - I P ( ( 2 7 5 * M ) / 9 ) + K * I P ( ( M + 9 ) / 1 2 ) + 3 0 ; 
 
 / / A : = I P ( A N / 1 0 0 ) ; C R : = 2 - A + I P ( A / 4 ) ; 
 
 / / I F ( A N + M / 1 0 0 + J / 1 0 0 0 0 ) < 1 5 8 2 . 1 0 1 4 5 
     / / T H E N   1 ¶%J U L ; 
 
 / / I F   J U L = = 1   T H E N   0 ¶%C R   E N D ; 
 / / J D : = I P ( 3 6 5 . 2 5 * ( A N + 4 7 1 6 ) ) + I P ( 3 0 . 6 0 0 1 * ( M + 1 ) ) 
         / / + J + C R - 1 5 2 4 . 5 ; 
 / / J D : = J D + 1 . 5 ; 
 / / J D : = i r e m ( J D , 7 ) ; 
 
   
 R E T U R N ( J + " / " + M + " / " + A N ) ; 
 
 
 E N D ;

For exemple : 291....0732 give 17/10/732 LEAP
290....0733 give 17/10/733

245....1948 give 1/9/1948 LEAP
244....1947 give 1/9/1947

Cheers

Gérard.
Find all posts by this user
Quote this message in a reply
01-11-2015, 08:15 PM
Post: #2
RE: Date from DOY. (A.Pouplier)
You somehow messed up the code. How did you paste it into the forum?

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
01-12-2015, 02:11 AM
Post: #3
RE: Date from DOY. (A.Pouplier)
This looks like UTF-16.
Maybe try pasting it into another editor first, like notepad or wordpad, and from there to the forum?
Find all posts by this user
Quote this message in a reply
01-12-2015, 02:57 PM
Post: #4
RE: Date from DOY. (A.Pouplier)
... And here is number date to day number...

@at this time i've about 15 date functions in one program, this and other will be published next time...

Wolfgang


Code:


// DT2DN Date to Day Number
// nd numberdate (dd.mmyyyy), Leafyear y/n? (0 or 1)
// example DT2DN(29.112014,0) returns 333
// WMWK 2014-11-12
//
EXPORT DT2DN(nd,L)
BEGIN
LOCAL D,M;
   
   D:=IP(nd);
   M:=IP(((nd-D)*100));
//   Y:=((FP(((nd-D)*100))*10000));
CASE
      IF M <3 THEN RETURN IP((M-1)*(63-L)/2)+D;END;
      IF M >2 THEN RETURN  D+(IP((M+1)*30.6)-(63-L)); END;
END;
END;

[code]
[code]

HP 33C 34C 11C 41CX 12C 15C HP71B 35s 50g Prime Rev. A, C, D. DM 41X, 42. TI 58C, 59, 74, 92-II, Voyage 200, nspire CX II-T, Sanyo ICC 82D and more
Find all posts by this user
Quote this message in a reply
01-12-2015, 04:07 PM
Post: #5
RE: Date from DOY. (A.Pouplier)
(01-11-2015 08:15 PM)Marcus von Cube Wrote:  You somehow messed up the code. How did you paste it into the forum?

Hi, i have done as you me said. My code compressed in a zip.file, after i open
the file, it is marked xxx.hppgm. I open that file et copy it on #icon. Am i wrong ?

Gérard.
Find all posts by this user
Quote this message in a reply
01-12-2015, 04:50 PM
Post: #6
RE: Date from DOY. (A.Pouplier)
(01-12-2015 02:57 PM)Wolfgang Wrote:  ... And here is number date to day number...

@at this time i've about 15 date functions in one program, this and other will be published next time...

Wolfgang


Code:


// DT2DN Date to Day Number
// nd numberdate (dd.mmyyyy), Leafyear y/n? (0 or 1)
// example DT2DN(29.112014,0) returns 333
// WMWK 2014-11-12
//
EXPORT DT2DN(nd,L)
BEGIN
LOCAL D,M;
   
   D:=IP(nd);
   M:=IP(((nd-D)*100));
//   Y:=((FP(((nd-D)*100))*10000));
CASE
      IF M <3 THEN RETURN IP((M-1)*(63-L)/2)+D;END;
      IF M >2 THEN RETURN  D+(IP((M+1)*30.6)-(63-L)); END;
END;
END;

[code]
[code]

Hi,
For me i use this code because all is automatic, leap year or not, grégorian or julian. I hope pasting will be correct, i discovery only the forum. [/code] 1 D O Y | E X P O R T D O Y ( D A T E )
B E G I N
L O C A L B : = 2 , A N , M , J ;
I P ( D A T E ) ¶%J ;
I P ( F P ( D A T E ) * 1 0 0 ) ¶%M ;
I P ( F P ( F P ( D A T E ) * 1 0 0 ) * 1 0 0 0 0 ) ¶%A N ;
/ / L E A P Y E A R ?
C A S E
I F ( N O T ( A N M O D 4 ) A N D A N M O D 1 0 0 )
O R ( N O T ( A N M O D 4 0 0 ) )
T H E N B : = 1 ; / / L E A P
E N D ;

I F A N < 1 5 8 2 A N D i r e m ( A N , 4 ) = = 0
T H E N B : = 1 ; / / L E A P
E N D ;
E N D ;

R E T U R N I P ( 2 7 5 * M / 9 ) - B * I P ( ( M + 9 ) / 1 2 ) + J - 3 0 ;
E N D ;
[code]


By the occasion, how doyou do to paste a code into forum.
Please explain step by step. Thank you.

Gérard.

Gérard.
Find all posts by this user
Quote this message in a reply
01-12-2015, 05:04 PM (This post was last modified: 01-12-2015 05:14 PM by Wolfgang.)
Post: #7
RE: Date from DOY. (A.Pouplier)
Dear Gerard,

danke for your quick response with another code which is automatic detecting leaf year! Nice! I have to analyze it asap!

:-)


I use the sharp-code '#' - meaning "inserting formatted code" to the begin and twice to the end of my source. I don't know, if this action is the very correct doing. but it still works!

bonne soirée de Berlin
Wolfgang

edit: i use notepad++ , http://notepad-plus-plus.org/

HP 33C 34C 11C 41CX 12C 15C HP71B 35s 50g Prime Rev. A, C, D. DM 41X, 42. TI 58C, 59, 74, 92-II, Voyage 200, nspire CX II-T, Sanyo ICC 82D and more
Find all posts by this user
Quote this message in a reply
01-12-2015, 05:06 PM (This post was last modified: 01-12-2015 05:07 PM by Han.)
Post: #8
RE: Date from DOY. (A.Pouplier)
I think what the other people are referring to is the additional space inserted between each character in your code. It may be a browser or text editor issue. For example, your code appears like this: w o r d. Normally, it should appear as: word (without spaces between w,o,r, and d).

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
01-12-2015, 05:12 PM (This post was last modified: 01-12-2015 05:13 PM by Didier Lachieze.)
Post: #9
RE: Date from DOY. (A.Pouplier)
(01-12-2015 04:50 PM)ggauny@live.fr Wrote:  By the occasion, how doyou do to paste a code into forum.
Please explain step by step. Thank you.

First open the Connectivity kit and the Prime Emulator or connect your physical Prime, select your program on the left, and then in the windows on the right you should see your code:

[Image: a0newp]

Then select your code and Copy it (Ctrl C or right click/Copy), go to your post in the forum and click on the "#" icon, this will open the Code tag :

[Image: a0newo]

Then Paste your code (Ctrl V or right click Paste), and click again on the "#" icon to close the Code tag:

[Image: a0nefb]

Click Preview Post to view the code:

[Image: a0newq]
Find all posts by this user
Quote this message in a reply
01-12-2015, 05:44 PM
Post: #10
RE: Date from DOY. (A.Pouplier)
Code:
EXPORT DOY(DATE)
BEGIN
LOCAL B:=2,AN,M,J;
IP(DATE)▶J;
IP(FP(DATE)*100)▶M;
IP(FP(FP(DATE)*100)*10000)▶AN;
//LEAP YEAR ?
CASE
IF (NOT(AN MOD 4) AND AN MOD 100)
 OR(NOT(AN MOD 400))
  THEN B:=1; // LEAP
  END;

IF AN<1582 AND irem(AN,4)==0
   THEN B:=1; //LEAP
   END;
END;

RETURN IP(275*M/9)-B*IP((M+9)/12)+J-30;
END;

I thing i have finded a way to paste correctely codes, yes i hope...
Gérard.

Gérard.
Find all posts by this user
Quote this message in a reply
01-12-2015, 05:54 PM
Post: #11
RE: Date from DOY. (A.Pouplier)
Hello,

I really thank you all for the help, with you i progress. My first hp was HP25 not C !
So i am not really "new in box" ! And my brain not too...

Thank you again Friends.
Gérard.

Gérard.
Find all posts by this user
Quote this message in a reply
01-12-2015, 07:58 PM
Post: #12
RE: Date from DOY. (A.Pouplier)
(01-12-2015 04:07 PM)ggauny@live.fr Wrote:  
(01-11-2015 08:15 PM)Marcus von Cube Wrote:  You somehow messed up the code. How did you paste it into the forum?

Hi, i have done as you me said. My code compressed in a zip.file, after i open
the file, it is marked xxx.hppgm. I open that file et copy it on #icon. Am i wrong ?

I was referring to the "Attach file" option of the forum where you can add a file to your post for downloading by other forum members. Only a few file formats are allowed here, amongst them ZIP. Just put everything you want to share in a ZIP archive and attach the file as is to your post.

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
01-13-2015, 12:07 PM
Post: #13
RE: Date from DOY. (A.Pouplier)
(01-12-2015 07:58 PM)Marcus von Cube Wrote:  
(01-12-2015 04:07 PM)ggauny@live.fr Wrote:  Hi, i have done as you me said. My code compressed in a zip.file, after i open
the file, it is marked xxx.hppgm. I open that file et copy it on #icon. Am i wrong ?

I was referring to the "Attach file" option of the forum where you can add a file to your post for downloading by other forum members. Only a few file formats are allowed here, amongst them ZIP. Just put everything you want to share in a ZIP archive and attach the file as is to your post.

Guten Tag,
Oh, Verzeihung ! Untschuldigen Sie, Jetzt Versteheich.
Bis bald. Viele liebe GrüBe.
Gérard.

Gérard.
Find all posts by this user
Quote this message in a reply
Post Reply 




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