Permalink
Browse files

Merge pull request #1 from darkliquid/master

Fixed typos
  • Loading branch information...
2 parents b52b082 + 2a2f310 commit ff2eda8159632e06b5e557740a4b6f8034664ba2 @tebeka committed Mar 5, 2014
Showing with 8 additions and 8 deletions.
  1. +6 −6 jtime.go
  2. +2 −2 jtime_test.go
View
@@ -28,18 +28,18 @@ func SetMarshaler(m Marshaler) {
marshaler = m
}
-// FormatMashaler uses time.Time format strings
-type FormatMashaler struct {
+// FormatMarshaler uses time.Time format strings
+type FormatMarshaler struct {
Format string
}
// Marshal will marshal to JSON string in Format
-func (fm *FormatMashaler) Marshal(t Time) ([]byte, error) {
+func (fm *FormatMarshaler) Marshal(t Time) ([]byte, error) {
return []byte(`"` + t.Format(fm.Format) + `"`), nil
}
// Unmarshal from JSON string in Format
-func (fm *FormatMashaler) Unmarshal(data []byte) (Time, error) {
+func (fm *FormatMarshaler) Unmarshal(data []byte) (Time, error) {
if len(data) < 2 {
return Time{}, fmt.Errorf("data too short - %v", data)
}
@@ -92,7 +92,7 @@ func validJSONTime(t Time) bool {
// MarshalJSON implements the json.Marshaler interface.
func (t Time) MarshalJSON() ([]byte, error) {
if !validJSONTime(t) {
- return nil, fmt.Errorf("vtime.Time.MarshalJson: year outside of range [0,9999]")
+ return nil, fmt.Errorf("jtime.Time.MarshalJson: year outside of range [0,9999]")
}
return marshaler.Marshal(t)
}
@@ -105,5 +105,5 @@ func (t *Time) UnmarshalJSON(data []byte) (err error) {
func init() {
// Default behaviour
- SetMarshaler(&FormatMashaler{time.RFC3339Nano})
+ SetMarshaler(&FormatMarshaler{time.RFC3339Nano})
}
View
@@ -24,7 +24,7 @@ func testTime() Time {
func TestFormatMarshaller(t *testing.T) {
tm := testTime()
- fm := &FormatMashaler{"2006"}
+ fm := &FormatMarshaler{"2006"}
data, err := fm.Marshal(tm)
if err != nil {
t.Fatalf("can't marshal: %s", err)
@@ -57,7 +57,7 @@ func checkUnmarshal(data []byte, t *testing.T) {
}
func TestJSON(t *testing.T) {
- SetMarshaler(&FormatMashaler{"2006"})
+ SetMarshaler(&FormatMarshaler{"2006"})
ts := TestStruct{testTime()}
data, err := json.Marshal(ts)

0 comments on commit ff2eda8

Please sign in to comment.