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

сделал HoursMinutesSeconds{}

This commit is contained in:
Nikitin Aleksandr
2025-02-12 15:17:19 +03:00
parent cf70289689
commit 6613a2145f
4 changed files with 6 additions and 6 deletions

View File

@@ -70,8 +70,8 @@ func IsWorkDay(Date time.Time) bool {
return Otvet
}
// UnmarshalByte - преобразует байты время в HoursMinutesSeconds{}
func (d *HoursMinutesSeconds) UnmarshalByte(b []byte) error {
// UnmarshalJSON - преобразует байты время в HoursMinutesSeconds{}
func (d *HoursMinutesSeconds) UnmarshalJSON(b []byte) error {
str := string(b)
err := d.UnmarshalString(str)

View File

@@ -27,7 +27,7 @@ func TestIsWorkDay(t *testing.T) {
func TestHoursMinutesSeconds_UnmarshalByte(t *testing.T) {
Otvet := HoursMinutesSeconds{}
Otvet.UnmarshalByte([]byte("01:02:03"))
Otvet.UnmarshalJSON([]byte("01:02:03"))
if Otvet.Hours != 1 || Otvet.Minutes != 2 || Otvet.Seconds != 3 {
t.Error("TestHoursMinutesSeconds_UnmarshalByte error")
}

View File

@@ -1452,8 +1452,8 @@ func StringFromBool(value bool) string {
return Otvet
}
//// UnmarshalByte - преобразует строку время в time.Time
//func (d *Time) UnmarshalByte(b []byte) error {
//// UnmarshalJSON - преобразует строку время в time.Time
//func (d *Time) UnmarshalJSON(b []byte) error {
// str := string(b)
// if str != "" && str[0] == '"' && str[len(str)-1] == '"' {
// str = str[1 : len(str)-1]

View File

@@ -1356,7 +1356,7 @@ func TestStringFromBool(t *testing.T) {
//func TestTime_UnmarshalByte(t *testing.T) {
// var Otvet Time
// Test := []byte("10:05:01")
// err := (&Otvet).UnmarshalByte(Test)
// err := (&Otvet).UnmarshalJSON(Test)
// if err != nil {
// t.Errorf("TestTime_UnmarshalByte() error: %v", err)
// }