Subj : Julian to String Date To : All From : Dan Egli Date : Thu Jan 29 2004 12:02 am Hey all. I need someone to double check my logic here, if you please. I am writing a function that takes a julian date (i.e. 030) and returns the String Date it represents(i.e. 01/30/). I wrote this function to do it. I am sure there is a more elegant way but I can not think of it. Basically I don't care as long as it works. So I want someone to double check it to see if they can see any flaws in my logic (entirely possible!). This is for FreePascal so most Delphi 2.0 types are valid. Thanks! Dan Moderator BBS_SURVIVAL === Begin Code === function JulToDateTime(JulDate : Word) : TDateTime; var Y,M,D,Work : Word; IsLeap : Boolean; WorkDate : string; begin Work := JulDate; DecodeDate(Date, Y, M, D); M := 1; D := 1; if (((Y mod 4) = 0) and (Y mod 100) >0)) or (Y mod 400) = 0) then IsLeap := true else IsLeap := false; if (Work > 31) then begin inc(M); Dec(Work, 31); end; if ((Work > 28) and Not IsLeap) or ((work > 29) and IsLeap) then begin if IsLeap Dec(work, 29) else Dec(work, 28); inc(M); end; if (Work > 31) then Begin Dec(work, 31); Inc(M); end; if (work > 30) then begin Inc(M); Dec(work, 30); end; // april if (Work > 31) then Begin Dec(work, 31); Inc(M); end; if (work > 30) then begin Inc(M); Dec(work, 30); end; // June if (Work > 31) then Begin Dec(work, 31); Inc(M); end; if (work > 31) then begin Inc(M); Dec(work, 31); end; // Aug if (Work > 30) then Begin Dec(work, 30); Inc(M); end; if (work > 31) then begin Inc(M); Dec(work, 31); end; // Oct if (Work > 30) then Begin Dec(work, 30); Inc(M); end; D := Work; JultoDateTime := StrtoDate(Pad(IntToStr(M),2)+'/'+Pad(IntToStr(D), 2)+'/'+IntToStr(Y)); end. === End Code === --- * Origin: Living in interesting times (1:3005/3) .