From 454f544bf38d5c5d88acb90b4ef48e8c4b0d76e5 Mon Sep 17 00:00:00 2001 From: "k.ukolov" Date: Fri, 10 Feb 2023 14:47:09 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20weekday?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- date/date.go | 30 +++++++++++++++++++++++++++++- messages/messages.go | 3 ++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/date/date.go b/date/date.go index 43551b4..634193b 100644 --- a/date/date.go +++ b/date/date.go @@ -7,5 +7,33 @@ func Today(offset time.Duration) string { if err != nil { panic(err) } - return time.Now().In(location).Add(offset).Format("2006-01-02") + 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 "" + } } diff --git a/messages/messages.go b/messages/messages.go index ec45b5f..c1e8f8d 100644 --- a/messages/messages.go +++ b/messages/messages.go @@ -5,6 +5,7 @@ import ( "math/rand" "strconv" "strings" + "student_bot/date" "student_bot/new_year_service" "student_bot/parser" "time" @@ -60,7 +61,7 @@ func LessonsMessage(schedule []parser.Lesson, prefix, emptyText string) string { s += "\n" } endDate = l.TimeStart.Format("02.01") - s += endDate + "\n" + s += endDate + " " + date.GetTranslatedWeekday(l.TimeStart) + "\n" } if strings.Contains(l.User, "Ярных В.В.") { s += "⭐️ "