-
Notifications
You must be signed in to change notification settings - Fork 37
/
types.go
47 lines (40 loc) · 935 Bytes
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// GoMySQL - A MySQL client library for Go
//
// Copyright 2010-2011 Phil Bayfield. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mysql
import "fmt"
// Date struct
type Date struct {
Year uint16
Month uint8
Day uint8
}
// Get date as string
func (d *Date) String() string {
return fmt.Sprintf("%d-%02d-%02d", d.Year, d.Month, d.Day)
}
// Time struct
type Time struct {
Hour uint8
Minute uint8
Second uint8
}
// Get time as string
func (t *Time) String() string {
return fmt.Sprintf("%02d:%02d:%02d", t.Hour, t.Minute, t.Second)
}
// DateTime struct
type DateTime struct {
Year uint16
Month uint8
Day uint8
Hour uint8
Minute uint8
Second uint8
}
// Get date/time as string
func (d *DateTime) String() string {
return fmt.Sprintf("%d-%02d-%02d %02d:%02d:%02d", d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second)
}