<?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: convert number string to date format in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387319#M865151</link>
    <description>Hi MuthuKumar,&lt;BR /&gt;&lt;BR /&gt;Thanks. It is a good one. But there is a little bug. &lt;BR /&gt;&lt;BR /&gt;I got the output like this after I run the script.&lt;BR /&gt;&lt;BR /&gt;Thu Sep 27 15:14:21 SST 2004&lt;BR /&gt;&lt;BR /&gt;But it is suppose to be&lt;BR /&gt;&lt;BR /&gt;Mon Sep 27 15:14:21 SST 2004&lt;BR /&gt;&lt;BR /&gt;i.e the weekday goes wrong.&lt;BR /&gt;</description>
    <pubDate>Mon, 27 Sep 2004 04:56:37 GMT</pubDate>
    <dc:creator>Selvamuthu Kumaran</dc:creator>
    <dc:date>2004-09-27T04:56:37Z</dc:date>
    <item>
      <title>convert number string to date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387317#M865149</link>
      <description>I need to combine a date string of format YYMMDD and time string of format HHMMSS into a date description with day, month and time&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;The input strings are&lt;BR /&gt;DATESTR=040927&lt;BR /&gt;TIMESTR=151421&lt;BR /&gt;&lt;BR /&gt;I need to convert it to:&lt;BR /&gt;&lt;BR /&gt;Mon Sep 27 15:14:21 SST 2004&lt;BR /&gt;&lt;BR /&gt;Could anyone help on this. Thanks.</description>
      <pubDate>Mon, 27 Sep 2004 04:10:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387317#M865149</guid>
      <dc:creator>Selvamuthu Kumaran</dc:creator>
      <dc:date>2004-09-27T04:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: convert number string to date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387318#M865150</link>
      <description>We can do this with script as,&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;# time.ksh&lt;BR /&gt;&lt;BR /&gt;### input ####&lt;BR /&gt;DATE=$1&lt;BR /&gt;TIME=$2&lt;BR /&gt;&lt;BR /&gt;####&lt;BR /&gt;&lt;BR /&gt;day=$(echo $DATE | cut -c 1,2)&lt;BR /&gt;mon=$(echo $DATE | cut -c 3,4)&lt;BR /&gt;date=$(echo $DATE | cut -c 5,6)&lt;BR /&gt;&lt;BR /&gt;####&lt;BR /&gt;&lt;BR /&gt;hour=$(echo $TIME | cut -c 1,2)&lt;BR /&gt;min=$(echo $TIME | cut -c 3,4)&lt;BR /&gt;sec=$(echo $TIME | cut -c 5,6)&lt;BR /&gt;&lt;BR /&gt;####&lt;BR /&gt;&lt;BR /&gt;DAY="Sun Mon Tue Wed Thur Fri Sat"&lt;BR /&gt;MON="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"&lt;BR /&gt;&lt;BR /&gt;# Array #&lt;BR /&gt;set -A DARR $DAY&lt;BR /&gt;set -A MARR $MON&lt;BR /&gt;&lt;BR /&gt;year=$(date +"%Y")&lt;BR /&gt;zone=$(date +"%Z")&lt;BR /&gt;&lt;BR /&gt;DD=${DARR[$day]}&lt;BR /&gt;MM=${MARR[$((mon-1))]}&lt;BR /&gt;echo "$DD $MM $date $hour:$min:$sec $zone $year"&lt;BR /&gt;&lt;BR /&gt;# End #&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;Save as, &lt;BR /&gt;&lt;BR /&gt; time.ksh&lt;BR /&gt; $ksh time.ksh 040927 151421&lt;BR /&gt;&lt;BR /&gt; You will get your desired output</description>
      <pubDate>Mon, 27 Sep 2004 04:28:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387318#M865150</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-09-27T04:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: convert number string to date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387319#M865151</link>
      <description>Hi MuthuKumar,&lt;BR /&gt;&lt;BR /&gt;Thanks. It is a good one. But there is a little bug. &lt;BR /&gt;&lt;BR /&gt;I got the output like this after I run the script.&lt;BR /&gt;&lt;BR /&gt;Thu Sep 27 15:14:21 SST 2004&lt;BR /&gt;&lt;BR /&gt;But it is suppose to be&lt;BR /&gt;&lt;BR /&gt;Mon Sep 27 15:14:21 SST 2004&lt;BR /&gt;&lt;BR /&gt;i.e the weekday goes wrong.&lt;BR /&gt;</description>
      <pubDate>Mon, 27 Sep 2004 04:56:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387319#M865151</guid>
      <dc:creator>Selvamuthu Kumaran</dc:creator>
      <dc:date>2004-09-27T04:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: convert number string to date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387320#M865152</link>
      <description>As standard, &lt;BR /&gt;&lt;BR /&gt;date is followed as,&lt;BR /&gt;&lt;BR /&gt; DAY="Sun Mon Tue Wed Thur Fri Sat"&lt;BR /&gt;       00  01  02  03  04   05  06&lt;BR /&gt;&lt;BR /&gt; IF you want to make that to Mon=04 then change it accordingly there in the DAY array.</description>
      <pubDate>Mon, 27 Sep 2004 05:19:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387320#M865152</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-09-27T05:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: convert number string to date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387321#M865153</link>
      <description>Hi Selvamuthu/Muthukumar,&lt;BR /&gt;&lt;BR /&gt;Muthukumar, your script looks good but I hope you don't mind if I take it and correct some errors. Getting the day of the week is tricky. This is the best I have so far and its very convoluted. I'm sure there's a perl guru out there who could do this in 1 or 2 lines.&lt;BR /&gt;&lt;BR /&gt;# The first 2 chars of DATESTR are the year, not the day.&lt;BR /&gt;# To get the day of week, you have to use a starting date.&lt;BR /&gt;# and proceed forward year by year, day by day to the date specified.&lt;BR /&gt;# Let's use Jan 1, 1900 which was a Monday  &lt;BR /&gt;&lt;BR /&gt;year=$(echo $DATESTR | cut -c 1,2)&lt;BR /&gt;mon=$(echo $DATESTR | cut -c 3,4)&lt;BR /&gt;dayofmonth=$(echo $DATESTR | cut -c 5,6)&lt;BR /&gt;&lt;BR /&gt;if [[ $year -lt 5 ]]&lt;BR /&gt;then&lt;BR /&gt;   # Assume that 00 thru 04 is 21st century, not 20th&lt;BR /&gt;   year=20$year&lt;BR /&gt;else&lt;BR /&gt;   year=19$year&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;numyears=$(($year - 1900))&lt;BR /&gt;numleapdays=$((($year - 1900) / 4))&lt;BR /&gt;&lt;BR /&gt;# Now adjust number of leap days for dates before March 1 of a leap year&lt;BR /&gt;if [[ $(($numyears % 4)) -eq 0 ]]&lt;BR /&gt;then&lt;BR /&gt;   if [[ $mon -lt 3 ]]&lt;BR /&gt;   then&lt;BR /&gt;      numleapdays=$(($numleapdays - 1))&lt;BR /&gt;   fi&lt;BR /&gt;fi&lt;BR /&gt;# Number of days to Jan 1 of the year&lt;BR /&gt;numdays=$((($numyears * 365) + $numleapdays))&lt;BR /&gt;&lt;BR /&gt;set -A dayspermonth 0 31 59 90 120 151 181 212 243 273 304 334&lt;BR /&gt;&lt;BR /&gt;numdays=$(($numdays + ${dayspermonth[$((mon-1))]} + $dayofmonth - 1))&lt;BR /&gt;&lt;BR /&gt;DAY="Sun Mon Tue Wed Thur Fri Sat"&lt;BR /&gt;&lt;BR /&gt;# Array #&lt;BR /&gt;set -A DARR $DAY&lt;BR /&gt;&lt;BR /&gt;DD=${DARR[$((numdays % 7))]}&lt;BR /&gt;&lt;BR /&gt;Mike D'.&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Sep 2004 10:59:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387321#M865153</guid>
      <dc:creator>Michael D'Aulerio</dc:creator>
      <dc:date>2004-09-28T10:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: convert number string to date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387322#M865154</link>
      <description>Micheal,&lt;BR /&gt;&lt;BR /&gt; It is good to have review on script and&lt;BR /&gt;&lt;BR /&gt; 1&amp;gt; We are asked to format as like "Mon Sep 27 15:14:21 SST 2004" from input's there DATESTR=040927&lt;BR /&gt;TIMESTR=151421&lt;BR /&gt;&lt;BR /&gt; so that we have to calculate with normal command date +"%Y" for year 2004 and for time zone date +"%Z"&lt;BR /&gt;&lt;BR /&gt;DATESTR=04 09 27&lt;BR /&gt; Day management is as like Sun Mon... etc.&lt;BR /&gt; Month as like in the month array Jan..&lt;BR /&gt; day is as like given in the ouptut&lt;BR /&gt;&lt;BR /&gt;TIMESTR=151421 &lt;BR /&gt; &lt;BR /&gt;Just put : as 15:14:21&lt;BR /&gt;&lt;BR /&gt; And required script has not be used to set more time here :-) It is just to display formation of "date" command there.&lt;BR /&gt;&lt;BR /&gt; 2&amp;gt; It is good to see your analysis on time and date. It is helpful.&lt;BR /&gt;&lt;BR /&gt;-Best Regards-&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Sep 2004 11:17:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387322#M865154</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-09-28T11:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: convert number string to date format</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387323#M865155</link>
      <description>Hi Mike/Muthukumar,&lt;BR /&gt;&lt;BR /&gt;Thanks for your help.&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Sep 2004 23:24:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/convert-number-string-to-date-format/m-p/3387323#M865155</guid>
      <dc:creator>Selvamuthu Kumaran</dc:creator>
      <dc:date>2004-09-28T23:24:37Z</dc:date>
    </item>
  </channel>
</rss>

