go ahead... be a heretic | |
PerlMonks |
Re: How to convert a vague time specfier into a concrete timestampby perlsherpa (Novice) |
on Sep 20, 2022 at 19:46 UTC ( [id://11147031]=note: print w/replies, xml ) | Need Help?? |
Here's a good start using static words that do not require you to treat them as a DSL (domain specific language).
Example, shell> perl words2date.pl now Tuesday, September 20, 2022 shell> perl words2date.pl today Tuesday, September 20, 2022 shell> perl words2date.pl tomorrow Wednesday, September 21, 2022 shell> perl words2date.pl yesterday Monday, September 19, 2022The challenge is defining and implementing DSL, then translating that to the "date math" that will need. For example, SQL uses something very primative and structured when what you want is not NOW(), e.g., So my suggestion is to start with static word or phrases, then focus specifically on the challenge to develop a DSL (or implement a well established one) that can then be parsed and then used to get the numbers you need to perform the date math. Hope that helps.
In Section
Seekers of Perl Wisdom
|
|