Hello TieUpYourCamel,
it is a nice question and you posted nice code and had back interesting and wise answers.. but when I see so simple tasks I cannot resist to try a oneliner solution ;)
perl -e "while($ARGV[0]<=$ARGV[1]){$t=scalar localtime($ARGV[0]);print
+ $t.$/ if $t=~/\s1\s/;$ARGV[0]+=86400}" 1580500427 1591220427
Sat Feb 1 20:53:47 2020
Sun Mar 1 20:53:47 2020
Wed Apr 1 21:53:47 2020
Fri May 1 21:53:47 2020
Mon Jun 1 21:53:47 2020
it is not bugged for year 1 ;)
L*
PS shorter
perl -e "$t=shift;while($t<=$ARGV[0]){print gmtime($t)=~/(.*\w 1)/?$1
+.$/:'';$t+=86400}"
# or
perl -e "$t=shift;while($t<=$ARGV[0]){print gmtime($t)=~/(.* 1)/?$1.$
+/:'';$t+=86400}"
# or
perl -le "$t=shift;while($t<=$ARGV[0]){gmtime($t)=~/(.* 1)/?print$1:0
+;$t+=86400}"
1580500427 1591220427
Sat Feb 1
Sun Mar 1
Wed Apr 1
Fri May 1
Mon Jun 1
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|