33 lines
666 B
Go
33 lines
666 B
Go
package date
|
|
|
|
import "time"
|
|
|
|
func Today(offset time.Duration) string {
|
|
location, err := time.LoadLocation("Asia/Novosibirsk")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return time.Now().In(location).Add(offset).Format("2006-01-02")
|
|
}
|
|
|
|
func GetTranslatedWeekday(date time.Time) string {
|
|
switch date.Weekday() {
|
|
case time.Monday:
|
|
return "Понедельник"
|
|
case time.Tuesday:
|
|
return "Вторник"
|
|
case time.Wednesday:
|
|
return "Среда"
|
|
case time.Thursday:
|
|
return "Четверг"
|
|
case time.Friday:
|
|
return "Пятница"
|
|
case time.Saturday:
|
|
return "Суббота"
|
|
case time.Sunday:
|
|
return "Воскресенье"
|
|
default:
|
|
return ""
|
|
}
|
|
}
|