Post Reply 
Date from DOY. (A.Pouplier)
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
Post Reply 


Messages In This Thread
RE: Date from DOY. (A.Pouplier) - Wolfgang - 01-12-2015, 02:57 PM
RE: Date from DOY. (A.Pouplier) - ggauny@live.fr - 01-12-2015 04:50 PM
RE: Date from DOY. (A.Pouplier) - Wolfgang - 01-12-2015, 05:04 PM
RE: Date from DOY. (A.Pouplier) - Han - 01-12-2015, 05:06 PM



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