<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Three-Digit Day of Year in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923206#M104611</link>
    <description>Sounds like a job for Clay's caljd.sh (attached).  Invoke as "caljd.sh -u" for usage details.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
    <pubDate>Fri, 02 Sep 2005 11:56:41 GMT</pubDate>
    <dc:creator>Pete Randall</dc:creator>
    <dc:date>2005-09-02T11:56:41Z</dc:date>
    <item>
      <title>Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923205#M104610</link>
      <description>I need help with a unix shell script (prefer K-shell) that will convert a given date in the format yyyymmdd into yyddd. (Input format is negotiable, output format needs to be yyddd or yy seperated from ddd.)  For example, I put in 20050831 it would output 05243 because August 31 was the 243 day of 2005.  I'm familiar with date '+%y%j' that provides that for todays date, but I need to be able to declare any reasonable given date in the past or future.  I don't want the true julian date (number of days since 4713BC), just the number of days a given date is into its year. Any help is appreciated.</description>
      <pubDate>Fri, 02 Sep 2005 11:50:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923205#M104610</guid>
      <dc:creator>Michael Leis</dc:creator>
      <dc:date>2005-09-02T11:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923206#M104611</link>
      <description>Sounds like a job for Clay's caljd.sh (attached).  Invoke as "caljd.sh -u" for usage details.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Fri, 02 Sep 2005 11:56:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923206#M104611</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2005-09-02T11:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923207#M104612</link>
      <description>Michael,&lt;BR /&gt;&lt;BR /&gt;I apologise - I assumed that Clay's script would handle such a thing but, going through the usage notes myself, I don't see an option for 3 digit output.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Fri, 02 Sep 2005 11:59:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923207#M104612</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2005-09-02T11:59:30Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923208#M104613</link>
      <description>Of course you could use caljd to determine the julian day of January 1 and subtract that from the current julian day.  That ought to work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Fri, 02 Sep 2005 12:05:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923208#M104613</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2005-09-02T12:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923209#M104614</link>
      <description>I whipped this up quick.  Its a script that asks for the month and day and then tdells you the day of the year it is.  Note that it does not calculate leap year, so Feb was hard-coded to 28 days.  That could be programmed in though.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;#&lt;BR /&gt;print - n "Enter the month and day: "&lt;BR /&gt;read month day &lt;BR /&gt;&lt;BR /&gt;set -A days 31 28 31 30 31 30 31 31 30 31 30 31&lt;BR /&gt;((n = 0))&lt;BR /&gt;((j_days = 0))&lt;BR /&gt;&lt;BR /&gt;((month = month - 1))&lt;BR /&gt;&lt;BR /&gt;while ((n &amp;lt; $month))&lt;BR /&gt;do&lt;BR /&gt;        ((j_days = j_days + ${days[$n]}))&lt;BR /&gt;        ((n = n + 1))&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;((j_days = j_days + $day))&lt;BR /&gt;echo $j_days&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Sep 2005 12:38:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923209#M104614</guid>
      <dc:creator>Pat Lieberg</dc:creator>
      <dc:date>2005-09-02T12:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923210#M104615</link>
      <description>I forgot your desired result was inthe format dddyy, but you can add this to the end of the script:&lt;BR /&gt;&lt;BR /&gt;year=$(date +%y)&lt;BR /&gt;result="$j_days$year"&lt;BR /&gt;echo $result&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Sep 2005 12:45:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923210#M104615</guid>
      <dc:creator>Pat Lieberg</dc:creator>
      <dc:date>2005-09-02T12:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923211#M104616</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;In Perl:&lt;BR /&gt;&lt;BR /&gt;---- julian.p ----&lt;BR /&gt;use Time::Local;&lt;BR /&gt;($y,$m,$d) = unpack "a4 a2 a2", shift @ARGV;&lt;BR /&gt;$s1 = timelocal(0,0,1,$d,$m-1,$y-1900);&lt;BR /&gt;$s2 = timelocal(0,0,0,1,0,$y-1900);&lt;BR /&gt;$u = 1 + ($s1 - $s2)/86400;&lt;BR /&gt;printf "%02d%03d\n", $y-2000, $u;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I used the $U = 1 + ... because jan-1 is day 1.&lt;BR /&gt;I used the hour 1 in $s1 to deal with integer truncation.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Sep 2005 12:50:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923211#M104616</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-09-02T12:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923212#M104617</link>
      <description>Hi Michael:&lt;BR /&gt;&lt;BR /&gt;A small perl script would easily help:&lt;BR /&gt;&lt;BR /&gt;You an embed this in your shell and pass the Month Day Year as agruments.  I've let it output a three-digit year and a three-digit day of year.  THus 1999 outputs as 099 while 2005 appears as 105.&lt;BR /&gt;&lt;BR /&gt;perl -e 'use Time::Local;$time=timelocal(0,0,0,$ARGV[1],$ARGV[0]-1,$ARGV[2]);($y,$d)=(localtime($time))[5,7];$d++;printf "%03d%03d\n"' 8 31 2005&lt;BR /&gt;&lt;BR /&gt;...returns 105243&lt;BR /&gt;&lt;BR /&gt;Obviously, you can use this in your shell like this:&lt;BR /&gt;&lt;BR /&gt;RESULT=`perl -e `...`` $M $D $Y&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 02 Sep 2005 12:58:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923212#M104617</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-09-02T12:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923213#M104618</link>
      <description>&lt;BR /&gt;Ah yes, I forgot about the $yday = 8th field in the localtime result. Using that my script could change to:&lt;BR /&gt;&lt;BR /&gt;----  cat julian.p -----&lt;BR /&gt;use Time::Local;&lt;BR /&gt;($y,$m,$d) = unpack "a4 a2 a2", shift @ARGV;&lt;BR /&gt;$u = 1 + (localtime(timelocal(0,0,1,$d,$m-1,$y-1900)))[7];&lt;BR /&gt;printf "%02d%03d\n", $y-2000, $u;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;There is a minor typo / cut&amp;amp;paste error in the JRF solution.&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# perl -e 'use Time::Local;$time=timelocal(0,0,0,$ARGV[1],$ARGV[0]-1,$ARGV[2]);($y,$d)=(localtime($time))[5,7];$d++;printf "%03d%03d\n", $y,$d' 8 31 2005&lt;BR /&gt;&lt;BR /&gt;105243&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Sep 2005 13:17:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923213#M104618</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-09-02T13:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923214#M104619</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Yes, Hein, thank you.  The paste I did cut off part of the script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use Time::Local;&lt;BR /&gt;$time=timelocal(0,0,0,$ARGV[1],$ARGV[0]-1,$ARGV[2]);&lt;BR /&gt;($y,$d) = (localtime($time)) [5,7];&lt;BR /&gt;$d++;&lt;BR /&gt;printf "%03d%03d\n",$y,$d;&lt;BR /&gt;&lt;BR /&gt;I like your use of 'unpack'.  It would allow Michael to pass one argument to the perl script instead of three if that suits his needs better.  Thanks for the correction to mine!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 02 Sep 2005 13:25:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923214#M104619</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-09-02T13:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923215#M104620</link>
      <description>Thank you for your help -- sometimes the simple things are the hardest to see.  I ended up using Pat's sample script as it worked well for my purposes, however I can see where the PERL code would work well also.  Thank you everyone!</description>
      <pubDate>Fri, 02 Sep 2005 14:50:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923215#M104620</guid>
      <dc:creator>Michael Leis</dc:creator>
      <dc:date>2005-09-02T14:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Three-Digit Day of Year</title>
      <link>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923216#M104621</link>
      <description>Thank you for your help -- sometimes the simple things are the hardest to see. I ended up using Pat's sample script as it worked well for my purposes, however I can see where the PERL code would work well also. Thank you everyone!</description>
      <pubDate>Fri, 02 Sep 2005 14:51:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/three-digit-day-of-year/m-p/4923216#M104621</guid>
      <dc:creator>Michael Leis</dc:creator>
      <dc:date>2005-09-02T14:51:23Z</dc:date>
    </item>
  </channel>
</rss>

