Skip to content
This repository was archived by the owner on Apr 3, 2018. It is now read-only.

Commit 70434a2

Browse files
committed
Rename getMonthInEnglish() to convertOrShortenMonth + Fix #48
1 parent e249646 commit 70434a2

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

Diff for: funceble

+31-16
Original file line numberDiff line numberDiff line change
@@ -841,44 +841,44 @@ dateToLower(){
841841
#
842842
# @CalledBy formatDate
843843
################################################################################
844-
getMonthInEnglish(){
844+
convertOrShortenMonth(){
845845
local numericMonth=${1}
846846

847847
case ${numericMonth} in
848-
1|01)
848+
1|01|January)
849849
month='jan'
850850
;;
851-
2|02)
851+
2|02|February)
852852
month='feb'
853853
;;
854-
3|03)
854+
3|03|March)
855855
month='mar'
856856
;;
857-
4|04)
857+
4|04|April)
858858
month='apr'
859859
;;
860-
5|05)
860+
5|05|May)
861861
month='may'
862862
;;
863-
6|06)
863+
6|06|June)
864864
month='jun'
865865
;;
866-
7|07)
866+
7|07|July)
867867
month='jul'
868868
;;
869-
8|08)
869+
8|08|August)
870870
month='aug'
871871
;;
872-
9|09)
872+
9|09|September)
873873
month='sep'
874874
;;
875-
10)
875+
10|October)
876876
month='oct'
877877
;;
878-
11)
878+
11|November)
879879
month='nov'
880880
;;
881-
12)
881+
12|December)
882882
month='dec'
883883
;;
884884
*)
@@ -982,6 +982,8 @@ formatDate()
982982
local regex27='[0-9]{2}\.[0-9]{1}\.[0-9]{4}'
983983
# Date in format: 02 Jan 2017
984984
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}'
985987

986988
if [[ "${expirationDate}" =~ ${regex1} || "${expirationDate}" =~ ${regex26} ]]
987989
then
@@ -995,6 +997,19 @@ formatDate()
995997

996998
# We convert it to lower case
997999
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+
9981013
elif [[ "${expirationDate}" =~ ${regex11} ]]
9991014
then
10001015
# We split the date
@@ -1015,7 +1030,7 @@ formatDate()
10151030
local year=$(echo "${expirationDate}" | tr -cd '[[:digit:]]' | head -c8 | tail -c4)
10161031

10171032
# We convert the month
1018-
getMonthInEnglish "${month}"
1033+
convertOrShortenMonth "${month}"
10191034

10201035
# We assign the expiration date
10211036
expirationDate=${day}'-'${month}'-'${year}
@@ -1027,7 +1042,7 @@ formatDate()
10271042
local day=$(echo "${expirationDate}" | tr -cd '[[:digit:]]' | head -c8 | tail -c2)
10281043

10291044
# We convert the month
1030-
getMonthInEnglish "${month}"
1045+
convertOrShortenMonth "${month}"
10311046

10321047
# We assign the expiration date
10331048
expirationDate=${day}'-'${month}'-'${year}
@@ -1054,7 +1069,7 @@ formatDate()
10541069
convert1To2digits "${month}" "month"
10551070

10561071
# We convert the month to alpha format
1057-
getMonthInEnglish "${month}"
1072+
convertOrShortenMonth "${month}"
10581073

10591074
# We assign the expiration date
10601075
expirationDate=${day}'-'${month}'-'${year}

0 commit comments

Comments
 (0)