Originally posted by: Satish J L
Hi, I have developed a shell code which will convert CET to UTC that will not affect during the DST schedules. You just modify the logic accordingly from UTC to your timezone using this code's logic, I'm quite busy to change it. If you want I can change it and give.
function RDTCTR
{
if [[ $TIMEZONE == "RDT" ]] #|| [[ $TIMEZONE == "UTC-5" ]] || [[ $TIMEZONE == "UTC-4" ]]
then
ch=0
cm=0
if [[ $(TZ=CET date|awk '{print $5}') == "CEST" ]]
then
echo $1 |sed 's/-/./g'|awk -F'.' '{print $1" "$2" "$3" "$4" "$5" "$6" "$7}'|read ye mo dt ho mi se ze
case $ho in
'00') hou=24
ch=1
cm=0 ;;
'01') hou=25
ch=1
cm=0 ;;
*) hou=$ho
ch=0
cm=0 ;;
esac
hour=$(expr $hou - 2)
else
if [[ $(TZ=CET date|awk '{print $5}') == "CET" ]]
then
echo $1|sed 's/-/./g'|awk -F'.' '{print $1" "$2" "$3" "$4" "$5" "$6" "$7}'|read ye mo dt ho mi se ze
case $ho in
'00') hou=24
ch=1
cm=0 ;;
*) hou=$ho
ch=0
cm=0 ;;
esac
hour=$(expr $hou - 1)
fi
fi
if [[ ch -eq 1 ]]
then
echo "$ho of CET and $hour of UTC falls in midnight"
if [[ $dt == "01" ]]
then
if [[ $mo == "01" ]]
then
yea=`expr $ye - 1 `
mont=12
dat=$(cal $mont $yea|awk 'NF {DAYS = $NF}; END {print DAYS}')
else
mont=`expr $mo - 1`
if [[ `echo $mo | grep -c "^0"` -eq 1 ]] || [[ $mo -eq 10 ]]
then
mont=0${mont}
fi
dat=$(cal $mont $yea|awk 'NF {DAYS = $NF}; END {print DAYS}')
yea=$ye
fi
else
yea=$ye
dat=`expr $dt - 1`
mont=$mo
fi
else
yea=$ye
dat=$dt
mont=$mo
fi
echo "$yea-$mont-$dat-$hour.$mi.$se.$ze"
echo $1
fi
}
You call it by the function:
RDTCTR 2018-01-01-00.57.00.000000