Sha256: 68570594638d1d0afeada3d9c961f35b71141152f945331487ff13d1c5614f05

Contents?: true

Size: 352 Bytes

Versions: 78

Compression:

Stored size: 352 Bytes

Contents

package clock

import "fmt"

type Clock int

func New(h, m int) Clock {
	c := Clock((h*60 + m) % 1440)
	if c < 0 {
		c += 1440
	}
	return c
}

func (c Clock) Add(m int) Clock {
	return New(0, int(c)+m)
}

func (c Clock) Subtract(m int) Clock {
	return New(0, int(c)-m)
}

func (c Clock) String() string {
	return fmt.Sprintf("%02d:%02d", c/60, c%60)
}

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/go/exercises/clock/example.go
trackler-2.2.1.138 tracks/go/exercises/clock/example.go
trackler-2.2.1.137 tracks/go/exercises/clock/example.go
trackler-2.2.1.136 tracks/go/exercises/clock/example.go
trackler-2.2.1.135 tracks/go/exercises/clock/example.go
trackler-2.2.1.134 tracks/go/exercises/clock/example.go
trackler-2.2.1.133 tracks/go/exercises/clock/example.go
trackler-2.2.1.132 tracks/go/exercises/clock/example.go
trackler-2.2.1.131 tracks/go/exercises/clock/example.go
trackler-2.2.1.130 tracks/go/exercises/clock/example.go
trackler-2.2.1.129 tracks/go/exercises/clock/example.go
trackler-2.2.1.128 tracks/go/exercises/clock/example.go
trackler-2.2.1.127 tracks/go/exercises/clock/example.go
trackler-2.2.1.126 tracks/go/exercises/clock/example.go
trackler-2.2.1.125 tracks/go/exercises/clock/example.go
trackler-2.2.1.124 tracks/go/exercises/clock/example.go
trackler-2.2.1.123 tracks/go/exercises/clock/example.go
trackler-2.2.1.122 tracks/go/exercises/clock/example.go
trackler-2.2.1.121 tracks/go/exercises/clock/example.go
trackler-2.2.1.120 tracks/go/exercises/clock/example.go