-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
591d468
commit ca77384
Showing
7 changed files
with
122 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package avro | ||
|
||
import "github.com/hamba/avro" | ||
|
||
type Marshaller struct { | ||
Schema avro.Schema | ||
} | ||
|
||
func NewMarshaller(schema avro.Schema) *Marshaller { | ||
return &Marshaller{Schema: schema} | ||
} | ||
func (c *Marshaller) Unmarshal(data []byte, v interface{}) error { | ||
return avro.Unmarshal(c.Schema, data, v) | ||
} | ||
func (c *Marshaller) Marshal(v interface{}) ([]byte, error) { | ||
return avro.Marshal(c.Schema, v) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package converter | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
) | ||
|
||
func TimeToMilliseconds(time string) (int64, error) { | ||
var h, m, s int | ||
_, err := fmt.Sscanf(time, "%02d:%02d:%02d", &h, &m, &s) | ||
if err != nil { | ||
return 0, err | ||
} | ||
return int64(h * 3600000 + m * 60000 + s * 1000), nil | ||
} | ||
func DateToUnixTime(s string) (int64, error) { | ||
layout := "2006-01-02" | ||
date, err := time.Parse(layout, s) | ||
if err != nil { | ||
return 0, err | ||
} | ||
return date.Unix() * 1000, nil | ||
} | ||
func DateToUnixNano(s string) (int64, error) { | ||
layout := "2006-01-02" | ||
date, err := time.Parse(layout, s) | ||
if err != nil { | ||
return 0, err | ||
} | ||
return date.UnixNano(), nil | ||
} | ||
func UnixTime(m int64) string { | ||
dateUtc := time.Unix(0, m* 1000000) | ||
return dateUtc.Format("2006-01-02") | ||
} | ||
func MillisecondsToTimeString(milliseconds int) string { | ||
hourUint := 3600000 //60 * 60 * 1000 = 3600000 | ||
minuteUint := 60000 //60 * 1000 = 60000 | ||
secondUint := 1000 | ||
hour := milliseconds / hourUint | ||
milliseconds = milliseconds % hourUint | ||
minute := milliseconds / minuteUint | ||
milliseconds = milliseconds % minuteUint | ||
second := milliseconds / secondUint | ||
return fmt.Sprintf("%02d:%02d:%02d", hour, minute, second) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters