[fpc-pascal] Parse strings like "day-1" to convert in a time stamp

Marcos Douglas B. Santos md at delfire.net
Mon Oct 15 14:18:53 CEST 2018


On Sun, Oct 14, 2018 at 8:19 PM Michael Van Canneyt
<michael at freepascal.org> wrote:
>
>
>
> On Mon, 15 Oct 2018, Sven Barth via fpc-pascal wrote:
>
> > Marcos Douglas B. Santos <md at delfire.net> schrieb am So., 14. Okt. 2018,
> > 16:15:
> >
> >> Do you know any Pascal lib to parse strings to convert in date/time values?
> >> The user is supposed to type human-friendly values like:
> >> - "day"    => trunc(now)
> >> - "day-2" => trunc(now-2)
> >> - "week" => trunc(now-7)
> >> - "yesterday" => trunc(now-1)
> >> - etc...
> >> But they could type even their computer date format or ISO as well.
> >>
> >> A lib in C, but very complex:
> >> - https://github.com/gagern/gnulib/blob/master/lib/parse-datetime.y
> >>
> >> I would like to start with something simpler, if possible. Thank you.
> >>
> >
> > I don't know a specific library that fulfills your needs, but maybe you can
> > build something atop of FpExprPars:
> > http://wiki.lazarus.freepascal.org/How_To_Use_TFPExpressionParser
> > At least according to the source it also supports datetime handling.

Thanks, Sven.

>
> It does, it's used (amongst other things) in the reporting engine;

Michael,
But does it work using just date values - accordingly with date format
in OS - or also with "day", "tomorrow", etc?
If not, can I extend those classes without change the original ones?

Regards,
Marcos Douglas



More information about the fpc-pascal mailing list