Created
August 11, 2016 08:40
-
-
Save riza/9b4819cf8d7b60dc6fcd9b4ee0eb771c to your computer and use it in GitHub Desktop.
Golang Turkish date parser func.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func turkishDate() string { | |
t := time.Now() | |
theTime := t.Format("02 January 2006") | |
month := strings.Split(theTime," ") | |
switch month[1] { | |
case "January": | |
str := strings.Replace(theTime, "January", "Ocak", -1) | |
return str | |
case "February": | |
str := strings.Replace(theTime, "February", "Şubat", -1) | |
return str | |
case "March": | |
str := strings.Replace(theTime, "March", "Mart", -1) | |
return str | |
case "April": | |
str := strings.Replace(theTime, "April", "Nisan", -1) | |
return str | |
case "May": | |
str := strings.Replace(theTime, "May", "Mayıs", -1) | |
return str | |
case "June": | |
str := strings.Replace(theTime, "June", "Haziran", -1) | |
return str | |
case "August": | |
str := strings.Replace(theTime, "August", "Ağustos", -1) | |
return str | |
case "September": | |
str := strings.Replace(theTime, "September", "Eylül", -1) | |
return str | |
case "October": | |
str := strings.Replace(theTime, "October", "Ekim", -1) | |
return str | |
case "November": | |
str := strings.Replace(theTime, "November", "Kasım", -1) | |
return str | |
case "December": | |
str := strings.Replace(theTime, "December", "Aralık", -1) | |
return str | |
default: | |
return "Date Parse Error" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
func turkishDate() string {
t := time.Now()
theTime := t.Format("02 Kasım 2006")
month := strings.Split(theTime," ")
switch month[1] {
case "Ocak":
str := strings.Replace(theTime, "Ocak", "01", -1)
return str
case "Şubat":
str := strings.Replace(theTime, "Şubat", "02", -1)
return str
case "Mart":
str := strings.Replace(theTime, "Mart", "03", -1)
return str
case "Nisan":
str := strings.Replace(theTime, "Nisan", "04", -1)
return str
case "Mayıs":
str := strings.Replace(theTime, "Mayıs", "05", -1)
return str
case "Haziran":
str := strings.Replace(theTime, "Haziran", "06", -1)
return str
case "Temmuz":
str := strings.Replace(theTime, "Temmuz", "07", -1)
return str
case "Ağustos":
str := strings.Replace(theTime, "Ağustos", "08", -1)
return str
case "Eylül":
str := strings.Replace(theTime, "Eylül", "09", -1)
return str
case "Ekim":
str := strings.Replace(theTime, "Ekim", "10", -1)
return str
case "Kasım":
str := strings.Replace(theTime, "Kasım", "11", -1)
return str
case "Aralık":
str := strings.Replace(theTime, "Aralık", "12", -1)
return str
default:
return "Date Parse Error"
}
}