Archive-name: tpdate01.pas
Quote:
> What I need to do is to be able to rename a file based on the current
> date....ie: if todays date is 15/5/96 I need to rename a file to be
> 960515.txt
stripping out code from my GENERICF.PAS :
function rightjustify(s: string; width: integer; c: char): string;
var
result: string;
begin
result := s;
while length(result)<width do
result := c+result;
rightjustify := result;
end;
function wordtozstring(w: word; width: integer): string;
var
result: string;
begin
str(w,result);
wordtozstring := rightjustify(result,width,'0');
end;
function ymdtostring(year, month, day: word): string;
begin
ymdtostring := wordtozstring(year,2) {+'-'} +
wordtozstring(month,2) {+'-'} +wordtozstring(day,2);
end;
function currentdatestring: string;
var
year, month, day, dayofweek: word;
begin
getdate(year,month,day,dayofweek);
currentdatestring := ymdtostring(year,month,day);
end;
then you would rename your old file to "currentdatestring+'.txt'"
from that package (part of rnr*.zip, ftp- and http-able), see also
function dateformatted(y,m,d: word; dateformat: string): string;
which does some fairly cool things -- allowing
mmm dd, yy => Jun 7, 96
www, yy-mm-dd => Fri, 96-06-07
and similar things. (as a bonus, it calculates the day of week for
any date (those past 1980, anyway)).
--