Parsing date in Pascal
what's the better way of parsin开发者_如何学JAVAg date in Pascal than manually parsing character after character?
Date should be in mm.dd.yyyy format.
Depends on the compiler used. If you use Delphi have a look at trystrtodate, or (if with a recent Free Pascal) try dateutils.scandatetime
If you're using Turbo Pascal, then the only thing you can do is check the string character by character. Or, you can create a record:
type
dater = Record
month: byte;
day : byte;
year: integer;
End;
var mydate: dater;
Thus, knowing the format (mm.dd.yyyy) you can easily validate it. Access the values easily mydate.month, mydate.day, mydate.year.
精彩评论