I decided to give a try to perl6 and I got stuck -- how to parse date in format %Y-%m? Year and month only...?
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
Edit
Let's say I want to check if month is valid. In perl 5 it is so simple:
use Time::Piece; localtime()->strptime(@ARGV[0], "%Y-%m");
I don't care about date parsing, I don't look at string at all -- perl5 does that for me.
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.
What is elegant way to do thatn in perl6?