开发者

Parsing date in Pascal

开发者 https://www.devze.com 2022-12-27 04:27 出处:网络
what\'s the better way of parsin开发者_如何学JAVAg date in Pascal than manually parsing character after character?

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

精彩评论

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