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 at -e line 1 #### use Time::Piece; localtime()->strptime(@ARGV[0], "%Y-%m"); #### 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.pm line 481.