1
0
mirror of https://github.com/ManyakRus/starter.git synced 2025-11-29 23:38:14 +02:00

сделал StringDatePeriod_rus()

This commit is contained in:
Nikitin Aleksandr
2025-04-23 15:04:24 +03:00
parent e6ae1aecf5
commit 145513a877
2 changed files with 22 additions and 0 deletions

View File

@@ -1659,3 +1659,18 @@ func DateFromToToday_rus() (time.Time, time.Time) {
return Date1, Date2
}
// StringDatePeriod_rus - возвращает строку с периодом дат
func StringDatePeriod_rus(Date1, Date2 time.Time) string {
Otvet := ""
Date1_00 := carbon.CreateFromStdTime(Date1).StartOfDay().StdTime()
Date2_00 := carbon.CreateFromStdTime(Date2).StartOfDay().StdTime()
if Date1_00 == Date2_00 {
Otvet = "на дату: " + StringDate(Date1_00)
} else {
Otvet = fmt.Sprintf("с %s по %s", StringDate(Date1_00), StringDate(Date2_00))
}
return Otvet
}

View File

@@ -1479,3 +1479,10 @@ func TestDateFromToToday_rus(t *testing.T) {
t.Errorf("error: DateFrom == DateTo")
}
}
func TestStringDatePeriod_rus(t *testing.T) {
Otvet := StringDatePeriod_rus(time.Now(), time.Now())
if Otvet == "" {
t.Errorf("error: Expected not empty string, but got %s", Otvet)
}
}