mirror of
https://github.com/ManyakRus/starter.git
synced 2025-11-29 23:38:14 +02:00
сделал StringDatePeriod_rus()
This commit is contained in:
@@ -1659,3 +1659,18 @@ func DateFromToToday_rus() (time.Time, time.Time) {
|
|||||||
|
|
||||||
return Date1, Date2
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -1479,3 +1479,10 @@ func TestDateFromToToday_rus(t *testing.T) {
|
|||||||
t.Errorf("error: DateFrom == DateTo")
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user