On 17/07/19 22:28, Keith Thompson wrote:
> Öö Tiib <
oot...@hot.ee> writes:
>> On Wednesday, 17 July 2019 16:49:35 UTC+3, Soviet_Mario wrote:
>>> One thing : I'd need an input function smart enough to
>>> support various date and/or time human-readable
>>> representations, possibly ALL of them, a rather variable
>>> scenario (short vs long, localized, UTC, just date, just
>>> time, both, separators ? named day / month ?)
>>> It is the kind of piece of code one would never want to
>>> write by hand.
>>
>> There are 6500 human languages and date is possible to write
>> down in large number of ways in each of those so you should
>> perhaps drop C++ and take AI training courses.
>> In C++ we set either strongly fixed textual format or use GUI
>> "date picker" that provides binary format right away.
>
> Or we could use a parser that accepts a reasonable variety of formats.
+1
many years ago I started to evaluate BOOST ... but was
really huge and didn't get to know it it has "fine grain"
enabling one to pick up just a couple of things needed.
BOOST had some parsin functions ... but it scared me then
(and it scares me now even more)
>
> For example, Perl has a "Date::Parse" module that does this.
> I'd be surprised if there weren't something similar in C++.
normally here on linux I use gambas (a basic dialect).
It has some string and built in DATE/TIME functions.
I've read a program can be made "a demon" (a TSR) so as a
last resort I could willy nilly write a small piece of
string-to-struct program to keep resident.
But I'm far from happy to try an inter-process data exchange.
>
> Supporting *all* date forms is admittedly not possible. Some inputs
> like "7/4/2019" are ambiguous.
>
also I'm beginning to discover if C++ supports RegEx and in
which form. (gambas supports them and also perl-like RegEx)
To discover the format used in a date would be much easier
by RegEx patterns.
For Oo Tiib (sorry for the umlauth) : I have little control
over input formats, I'm collecting some user-filled online
forms and have to mangle them. Recent data are pre-filtered
using google modules/sheets and RegEx, but older data were
rather irregular.