UPDATE ::: The functions could be even further simplified to just ::
function longMonth(_) { return _%2~_<8 }
1 3 5 7 8 10 12
function shortMonth(_) { return _%2~7<_ }
2 4 6 9 11
if you already have the month number (1-12)
, here's an easy way to determine whether it's a short- or long-month without regex
too much hard-coding :
jot 12 | {m,g,n}awk '
function shortMonth_v1(_) { return \
(_ % 2) != (+_ < 8) }
function shortMonth_v2(_) { return \
(_ + (+_ < 8)) % 2 }'
2
4
6
9
11
function longMonth_v1(_) { return \
(_ % 2) == (+_ < 8) }
function longMonth_v2(_) { return \
(_ + (7 < +_)) % 2 }
1
3
5
7
8
10
12
...v1()
and ...v2()
for both groups basically identical, reshuffling things around, so which one you prefer is just a matter of taste and personal preference
assuming if you really wanna match it by string-regex
of first-3 letters, June
is by far the hardest on
tolower($0) ~ /[fpv]|un/
/[bpv]|un/ # these 2 work as long as the input isn't all-caps
/[bpo]|un/
/^F|p|un|v/ # assuming first letter capitalized, others lower-case
/[FNp]|un/
Fe[b] b # can't use [e] to match
# since that'll grab in D[e]cember
A[p]r p
J[u][n] un
Se[p] p
No[v] v
/[acgl]/ # my favorite, by far
J[a]n a
M[a]r a
M[a]y a
Ju[l] l
Au[g] g
O[c]t c
De[c] c
/^M|an|[cgl]/ # alternatives
/[Mc]|an|u[^n]/