#!/bin/bash
#
# $LastChangedDate: 2021-05-24 23:05:38 +0200 (Mon, 24 May 2021) $
# $Revision: 3127 $
#
#Usage:# Provides the [date]'s week number. If [date] is not left empty,
#Usage:# the current week number is provided.
#
#--long# Will provide the (ISO 8601) long output (adding the 4 digit year)
#

#

_help_show_args="[date]"
. `dirname $0`/_option_processor

if [ "$1" != "" ]
then
   d_='-d'
   if echo $1 | grep -q '[-]'
   then
      Date=`echo $1 | awk -F- '
      {
         if ($3=="") 
         {
            print $2 "/" $1
         }
         else
         {
            print $2 "/" $1 "/" $3
         }
      }'`
   else
      Date=$1
   fi
fi

# ISO 8601 week
if [ "$__long" = "yes" ] || [ "$_l" = "yes" ]
then
   date $d_ $Date +%G%V
else
   date $d_ $Date +%V
fi

