{"id":120,"date":"2004-03-31T22:54:15","date_gmt":"2004-03-31T20:54:15","guid":{"rendered":"http:\/\/gnu.inter.it\/blogs\/fabu\/?p=120"},"modified":"2004-03-31T22:54:15","modified_gmt":"2004-03-31T20:54:15","slug":"il-mese-scorso","status":"publish","type":"post","link":"https:\/\/fabioinvernizzi.com\/blog\/2004\/03\/31\/il-mese-scorso\/","title":{"rendered":"Il mese scorso"},"content":{"rendered":"<p>Mi sono accorto di un piccolo sminchio nello script che lancia analog.<br \/>\nPer calcolare il nome del mese passato usavo &#8216;1 month ago&#8217; come parametro a &#8220;date&#8221;, ma lanciato oggi mi da&#8217; come risultato marzo:<br \/>\n<code><br \/>\nfabio@gnu:~$ date --date='1 month ago' +'%Y%m'<br \/>\n200403<br \/>\n<\/code><\/p>\n<p>Dopo un primo momento di panico mi sono reso conto di dove fosse il problema&#8230; marzo ha 31 giorni, febbraio no&#8230; il 31 febbraio non esiste&#8230; Il problema \u00e8  che viene contato come marzo!<\/p>\n<p>Cmq, ho trovato la spiegazione in &#8216;info date&#8217;:<br \/>\n<code><br \/>\n   The fuzz in units can cause problems with relative items.  For<br \/>\nexample, `2003-07-31 -1 month' might evaluate to 2003-07-01, because<br \/>\n2003-06-31 is an invalid date.  To determine the previous month more<br \/>\nreliably, you can ask for the month before the 15th of the current<br \/>\nmonth.  For example:<\/code><br \/>\n$ date -R<br \/>\nThu, 31 Jul 2003 13:02:39 -0700<br \/>\n$ date &#8211;date=&#8221;-1 month&#8221; +&#8217;Last month was %B?&#8217;<br \/>\nLast month was July?<br \/>\n$ date &#8211;date=&#8221;$(date +%Y-%m-15) -1 month&#8221; +&#8217;Last month was %B!&#8217;<br \/>\nLast month was June!<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mi sono accorto di un piccolo sminchio nello script che lancia analog. Per calcolare il nome del mese passato usavo &#8216;1 month ago&#8217; come parametro a &#8220;date&#8221;, ma lanciato oggi mi da&#8217; come risultato marzo: fabio@gnu:~$ date &#8211;date=&#8217;1 month ago&#8217; +&#8217;%Y%m&#8217; 200403 Dopo un primo momento di panico mi sono reso conto di dove fosse &hellip; <a href=\"https:\/\/fabioinvernizzi.com\/blog\/2004\/03\/31\/il-mese-scorso\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Il mese scorso<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[2],"tags":[3],"class_list":["post-120","post","type-post","status-publish","format-standard","hentry","category-me","tag-hacking"],"_links":{"self":[{"href":"https:\/\/fabioinvernizzi.com\/blog\/wp-json\/wp\/v2\/posts\/120"}],"collection":[{"href":"https:\/\/fabioinvernizzi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fabioinvernizzi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fabioinvernizzi.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/fabioinvernizzi.com\/blog\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":0,"href":"https:\/\/fabioinvernizzi.com\/blog\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"wp:attachment":[{"href":"https:\/\/fabioinvernizzi.com\/blog\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabioinvernizzi.com\/blog\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabioinvernizzi.com\/blog\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}