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.159 tracks/go/exercises/clock/example.go
trackler-2.2.1.158 tracks/go/exercises/clock/example.go
trackler-2.2.1.157 tracks/go/exercises/clock/example.go
trackler-2.2.1.156 tracks/go/exercises/clock/example.go
trackler-2.2.1.155 tracks/go/exercises/clock/example.go
trackler-2.2.1.154 tracks/go/exercises/clock/example.go
trackler-2.2.1.153 tracks/go/exercises/clock/example.go
trackler-2.2.1.152 tracks/go/exercises/clock/example.go
trackler-2.2.1.151 tracks/go/exercises/clock/example.go
trackler-2.2.1.150 tracks/go/exercises/clock/example.go
trackler-2.2.1.149 tracks/go/exercises/clock/example.go
trackler-2.2.1.148 tracks/go/exercises/clock/example.go
trackler-2.2.1.147 tracks/go/exercises/clock/example.go
trackler-2.2.1.146 tracks/go/exercises/clock/example.go
trackler-2.2.1.145 tracks/go/exercises/clock/example.go
trackler-2.2.1.144 tracks/go/exercises/clock/example.go
trackler-2.2.1.143 tracks/go/exercises/clock/example.go
trackler-2.2.1.142 tracks/go/exercises/clock/example.go
trackler-2.2.1.141 tracks/go/exercises/clock/example.go
trackler-2.2.1.140 tracks/go/exercises/clock/example.go