mirror of
https://github.com/ManyakRus/starter.git
synced 2025-11-25 23:02:22 +02:00
сделал HoursMinutesSeconds{}
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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)
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user