Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function date_val(date : datestr) : longint;
- var d,m,y,f : longint;
- e : integer;
- begin
- IF DATE=' / / ' THEN DATE:=FAR_AWAY_DATE;
- val(copy(date,1,2),d,e);
- val(copy(date,4,2),m,e);
- val(copy(date,7,2),y,e);
- if y>century_mark then y:=y+century1 else y:=y+century2;
- f:=(365*y) + d + (31*(m-1));
- if m<3 then begin
- f:=f + trunc((y-1)/4) - trunc(0.75*(trunc((y-1)/100)+1));
- end
- else begin
- f:=f - trunc(0.4*m+2.3) + trunc(y/4) - trunc(0.75*(trunc(y/100)+1));
- end;
- date_val:=f;
- end;
- { ------------------------------------------------------------------------- }
- (******************************************)
- (*** CONVERT numeric DATE TO string date *)
- (******************************************)
- Function Date_Str (DateNum: longint) : Str8;
- var
- day,mon,year,temp,e : longint;
- Dstr, Mstr, Ystr : String [2];
- TempA, TempB, TempC: longint;
- begin
- TempA := DateNum + 68569;
- TempB := 4 * TempA div 146097;
- TempA := TempA - (146097 * TempB + 3) div 4;
- Year := 4000 * (TempA + 1) div 1461001;
- TempC := Year;
- TempA := TempA - (1461 * TempC div 4) + 31;
- Mon := 80 * TempA div 2447;
- TempC := Mon;
- Day := TempA - (2447 * TempC div 80);
- TempA := Mon div 11;
- Mon := Mon + 2 - (12 * TempA);
- Year := 100 * (TempB - 49) + Year + TempA;
- Str (Day :2,Dstr);
- Str (Mon :2,Mstr);
- If Year <= 1999
- then Dec (Year,1900)
- else Dec (Year,2000);
- Str (Year:2,Ystr);
- if Dstr [1] = ' ' then Dstr [1] := '0';
- if Mstr [1] = ' ' then Mstr [1] := '0';
- if Ystr [1] = ' ' then Ystr [1] := '0';
- {if Ystr='0' then Ystr:='00';}
- Date_Str := Dstr + '/' + Mstr + '/' + Ystr;
- { handle blank field }
- if datenum = 0 then Date_Str := ' / / ';
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement