开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜