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.180 tracks/go/exercises/clock/example.go
trackler-2.2.1.179 tracks/go/exercises/clock/example.go
trackler-2.2.1.178 tracks/go/exercises/clock/example.go
trackler-2.2.1.177 tracks/go/exercises/clock/example.go
trackler-2.2.1.176 tracks/go/exercises/clock/example.go
trackler-2.2.1.175 tracks/go/exercises/clock/example.go
trackler-2.2.1.174 tracks/go/exercises/clock/example.go
trackler-2.2.1.173 tracks/go/exercises/clock/example.go
trackler-2.2.1.172 tracks/go/exercises/clock/example.go
trackler-2.2.1.171 tracks/go/exercises/clock/example.go
trackler-2.2.1.170 tracks/go/exercises/clock/example.go
trackler-2.2.1.169 tracks/go/exercises/clock/example.go
trackler-2.2.1.167 tracks/go/exercises/clock/example.go
trackler-2.2.1.166 tracks/go/exercises/clock/example.go
trackler-2.2.1.165 tracks/go/exercises/clock/example.go
trackler-2.2.1.164 tracks/go/exercises/clock/example.go
trackler-2.2.1.163 tracks/go/exercises/clock/example.go
trackler-2.2.1.162 tracks/go/exercises/clock/example.go
trackler-2.2.1.161 tracks/go/exercises/clock/example.go
trackler-2.2.1.160 tracks/go/exercises/clock/example.go