@@ -841,44 +841,44 @@ dateToLower(){
841
841
#
842
842
# @CalledBy formatDate
843
843
# ###############################################################################
844
- getMonthInEnglish (){
844
+ convertOrShortenMonth (){
845
845
local numericMonth=${1}
846
846
847
847
case ${numericMonth} in
848
- 1|01)
848
+ 1|01|January )
849
849
month=' jan'
850
850
;;
851
- 2|02)
851
+ 2|02|February )
852
852
month=' feb'
853
853
;;
854
- 3|03)
854
+ 3|03|March )
855
855
month=' mar'
856
856
;;
857
- 4|04)
857
+ 4|04|April )
858
858
month=' apr'
859
859
;;
860
- 5|05)
860
+ 5|05|May )
861
861
month=' may'
862
862
;;
863
- 6|06)
863
+ 6|06|June )
864
864
month=' jun'
865
865
;;
866
- 7|07)
866
+ 7|07|July )
867
867
month=' jul'
868
868
;;
869
- 8|08)
869
+ 8|08|August )
870
870
month=' aug'
871
871
;;
872
- 9|09)
872
+ 9|09|September )
873
873
month=' sep'
874
874
;;
875
- 10)
875
+ 10|October )
876
876
month=' oct'
877
877
;;
878
- 11)
878
+ 11|November )
879
879
month=' nov'
880
880
;;
881
- 12)
881
+ 12|December )
882
882
month=' dec'
883
883
;;
884
884
* )
@@ -982,6 +982,8 @@ formatDate()
982
982
local regex27=' [0-9]{2}\.[0-9]{1}\.[0-9]{4}'
983
983
# Date in format: 02 Jan 2017
984
984
local regex28=' [0-9]\s[A-Z]{1}[a-z]{2}\s[0-9]{4}'
985
+ # Date in format: 02-January-2017
986
+ local regex29=' [0-9]{2}-[A-Z]{1}[a-z]*-[0-9]{4}'
985
987
986
988
if [[ " ${expirationDate} " =~ ${regex1} || " ${expirationDate} " =~ ${regex26} ]]
987
989
then
@@ -995,6 +997,19 @@ formatDate()
995
997
996
998
# We convert it to lower case
997
999
dateToLower
1000
+ elif [[ " ${expirationDate} " =~ ${regex29} ]]
1001
+ then
1002
+ # We split the date
1003
+ local day=$( echo " ${expirationDate} " | tr -cd ' [[:digit:]]' | head -c2)
1004
+ local year=$( echo " ${expirationDate} " | tr -cd ' [[:digit:]]' | tail -c4)
1005
+ local month=$( echo " ${expirationDate} " | tr -cd ' [[:alpha:]]' )
1006
+
1007
+ # We convert the month
1008
+ convertOrShortenMonth " ${month} "
1009
+
1010
+ # We assign the expiration date
1011
+ expirationDate=${day} ' -' ${month} ' -' ${year}
1012
+
998
1013
elif [[ " ${expirationDate} " =~ ${regex11} ]]
999
1014
then
1000
1015
# We split the date
@@ -1015,7 +1030,7 @@ formatDate()
1015
1030
local year=$( echo " ${expirationDate} " | tr -cd ' [[:digit:]]' | head -c8 | tail -c4)
1016
1031
1017
1032
# We convert the month
1018
- getMonthInEnglish " ${month} "
1033
+ convertOrShortenMonth " ${month} "
1019
1034
1020
1035
# We assign the expiration date
1021
1036
expirationDate=${day} ' -' ${month} ' -' ${year}
@@ -1027,7 +1042,7 @@ formatDate()
1027
1042
local day=$( echo " ${expirationDate} " | tr -cd ' [[:digit:]]' | head -c8 | tail -c2)
1028
1043
1029
1044
# We convert the month
1030
- getMonthInEnglish " ${month} "
1045
+ convertOrShortenMonth " ${month} "
1031
1046
1032
1047
# We assign the expiration date
1033
1048
expirationDate=${day} ' -' ${month} ' -' ${year}
@@ -1054,7 +1069,7 @@ formatDate()
1054
1069
convert1To2digits " ${month} " " month"
1055
1070
1056
1071
# We convert the month to alpha format
1057
- getMonthInEnglish " ${month} "
1072
+ convertOrShortenMonth " ${month} "
1058
1073
1059
1074
# We assign the expiration date
1060
1075
expirationDate=${day} ' -' ${month} ' -' ${year}
0 commit comments