-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmonth.go
52 lines (49 loc) · 1.48 KB
/
month.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package dateparse
import (
"strings"
"time"
)
var (
january = `января|янв|january|jan`
february = `февраля|фев|february|feb`
march = `марта|мар|march|mar`
april = `апреля|апрель|апр|april|apr`
may = `мая|май|may`
june = `июня|июнь|june|jun`
july = `июля|июль|july|jul`
august = `августа|август|august|aug`
september = `сентября|сентябрь|сент|september|sep`
october = `октября|октябрь|october|oct`
november = `ноября|ноябрь|november|nov`
december = `декабря|дек|december|dec`
months = strings.Join([]string{january, february, march, april, may, june, july, august, september, october, november, december}, "|")
)
func parseMonth(monthStr string) time.Month {
switch {
case strings.Contains(january, monthStr):
return 1
case strings.Contains(february, monthStr):
return 2
case strings.Contains(march, monthStr):
return 3
case strings.Contains(april, monthStr):
return 4
case strings.Contains(may, monthStr):
return 5
case strings.Contains(june, monthStr):
return 6
case strings.Contains(july, monthStr):
return 7
case strings.Contains(august, monthStr):
return 8
case strings.Contains(september, monthStr):
return 9
case strings.Contains(october, monthStr):
return 10
case strings.Contains(november, monthStr):
return 11
case strings.Contains(december, monthStr):
return 12
}
return 0
}