#!/bin/bash

# ------------------------------------------------------------
# RPC Project :
# RPC_encode_datiso : return 2001-09-23T09:17:03.000Z from date
#                     and time given as 2001 09 23  09 17 03 
# syntax : RPC_encode_datiso year month day hour min sec
#      ex: RPC_nday_of_month 2001 09 23  09 17 03
# P. Robert, LPP, 2014-11-14
# ------------------------------------------------------------

appli=`basename $0`
appli36=`echo "$appli                                 " | cut -c1-36`
Narg=6

if( (test $# = 1 ) && (test $1 = -h ) ) ; then hh=1 ; else hh=0 ; fi

if test $# != $Narg || test $hh = 1
   then
   echo "$appli : return ISO_date from year month day hour min sec"
   echo "$appli   require $Narg argument(s)"
   echo "    ex: $appli 2001 09 23  09 17 03"
   echo ""
   if test $hh = 1 ; then exit 0 ; fi
   echo "$appli36 : *** ERROR ! Command aborted." >&2
   exit 1
fi

year=$1
month=$2
day=$3

hour=$4
min=$5
sec=$6

# compute and return ISO date

date_iso=$year"-"$month"-"$day"T"$hour":"$min":"$sec.000Z

echo $date_iso

# ------------------------------------------------------------
