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.119 tracks/go/exercises/clock/example.go
trackler-2.2.1.118 tracks/go/exercises/clock/example.go
trackler-2.2.1.117 tracks/go/exercises/clock/example.go
trackler-2.2.1.116 tracks/go/exercises/clock/example.go
trackler-2.2.1.115 tracks/go/exercises/clock/example.go
trackler-2.2.1.114 tracks/go/exercises/clock/example.go
trackler-2.2.1.113 tracks/go/exercises/clock/example.go
trackler-2.2.1.111 tracks/go/exercises/clock/example.go
trackler-2.2.1.110 tracks/go/exercises/clock/example.go
trackler-2.2.1.109 tracks/go/exercises/clock/example.go
trackler-2.2.1.108 tracks/go/exercises/clock/example.go
trackler-2.2.1.107 tracks/go/exercises/clock/example.go
trackler-2.2.1.106 tracks/go/exercises/clock/example.go
trackler-2.2.1.105 tracks/go/exercises/clock/example.go
trackler-2.2.1.104 tracks/go/exercises/clock/example.go
trackler-2.2.1.103 tracks/go/exercises/clock/example.go
trackler-2.2.1.102 tracks/go/exercises/clock/example.go
trackler-2.2.1.101 tracks/go/exercises/clock/example.go