leszekdubiel has asked for the wisdom of the Perl Monks concerning the following question:
Edit Let's say I want to check if month is valid. In perl 5 it is so simple:perl6 -e 'say Date.new("2019-01-20"); say Date.new("2019-01"); ' 2019-01-20 Invalid Date string '2019-01'; use yyyy-mm-dd instead in block <unit> at -e line 1
I don't care about date parsing, I don't look at string at all -- perl5 does that for me.use Time::Piece; localtime()->strptime(@ARGV[0], "%Y-%m");
What is elegant way to do thatn in perl6?bash$ perl -e 'use Time::Piece; localtime()->strptime(@ARGV[0], "%Y +-%m"); print "ok\n"; ' "2019-01" ok bash$ perl -e 'use Time::Piece; localtime()->strptime(@ARGV[0], "%Y +-%m"); print "ok\n"; ' "2019-77" Error parsing time at /usr/lib/x86_64-linux-gnu/perl/5.26/Time/Piece.p +m line 481.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: strptime("%Y-%m") in perl6
by choroba (Cardinal) on Feb 05, 2019 at 08:53 UTC | |
|
Re: strptime("%Y-%m") in perl6
by Laurent_R (Canon) on Feb 05, 2019 at 12:22 UTC | |
by leszekdubiel (Scribe) on Feb 05, 2019 at 14:01 UTC | |
by choroba (Cardinal) on Feb 05, 2019 at 14:55 UTC | |
by Laurent_R (Canon) on Feb 05, 2019 at 17:04 UTC | |
by leszekdubiel (Scribe) on Feb 05, 2019 at 17:34 UTC | |
by Laurent_R (Canon) on Feb 05, 2019 at 20:17 UTC |