Skip to content

Commit

Permalink
Rename ParseTime -> ParseDate
Browse files Browse the repository at this point in the history
  • Loading branch information
osteele committed Jul 10, 2017
1 parent bfad047 commit a3a3473
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<!-- TOC -->

- [Go Liquid Template Parser](#go-liquid-template-parser)
- [Status](#status)
- [Differences from Liquid](#differences-from-liquid)
- [Stability Guarantees](#stability-guarantees)
- [Install](#install)
- [Usage](#usage)
- [Command-Line tool](#command-line-tool)
Expand All @@ -24,11 +24,6 @@

<!-- /TOC -->

## Status

This library is at an early stage of development.
It has been mostly used by its author.

### Differences from Liquid

Refer to the [feature parity board](https://github.com/osteele/liquid/projects/1) for a list of differences from Liquid.
Expand All @@ -42,9 +37,18 @@ In brief, these aren't implemented:
- Error modes
- Whitespace control

## Stability Guarantees

This library is at an early stage of development.
It has been mostly used by its author.

Until it reaches 1.0, breaking changes will accompanied by a bump in the minor version, not the major version. For example, use `go get gopkg.in/osteele/liquid.v0.2` to stay at versions that are compatible with the v0.2 API. The v0.3 release will not in general be compatible with version 0.2.

Even within these parameters, only the liquid package itself, and the sub-package APIs that it documents, are guaranteed stable. For example, `render.Context` is documented as the parameter type for tag definitions; it therefore has the same stability guarantees as `liquid.Engine` and `liquid.Template`. Other "public" definitions in `render` and other sub-packages are public only to the implementation of packages in the repo; they are not generally stable.

## Install

`go get gopkg.in/osteele/liquid.v0.1`-- latest snapshot
`go get gopkg.in/osteele/liquid.v0.2`-- latest snapshot

`go get -u github.com/osteele/goliquid` -- development version

Expand Down
2 changes: 1 addition & 1 deletion evaluator/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func Convert(value interface{}, typ reflect.Type) (interface{}, error) { // noli
// convert int.Convert(string) yields "\x01" not "1"
return r.Convert(typ).Interface(), nil
case typ == timeType && r.Kind() == reflect.String:
return ParseTime(value.(string))
return ParseDate(value.(string))
// case reflect.PtrTo(r.Type()) == typ:
// return &value, nil
}
Expand Down
4 changes: 2 additions & 2 deletions evaluator/time.go → evaluator/parsedate.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ var dateLayouts = []string{
"Jan 2 2006",
}

// ParseTime tries a few heuristics to parse a date from a string
func ParseTime(s string) (time.Time, error) {
// ParseDate tries a few heuristics to parse a date from a string
func ParseDate(s string) (time.Time, error) {
if s == "now" {
return time.Now(), nil
}
Expand Down
6 changes: 3 additions & 3 deletions evaluator/time_test.go → evaluator/parsedate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (
)

func TestConstant(t *testing.T) {
dt, err := ParseTime("now")
dt, err := ParseDate("now")
require.NoError(t, err)
require.True(t, dt.After(timeMustParse("1970-01-01T00:00:00Z")))

dt, err = ParseTime("2017-07-09 10:40:00 UTC")
dt, err = ParseDate("2017-07-09 10:40:00 UTC")
require.NoError(t, err)
require.Equal(t, timeMustParse("2017-07-09T10:40:00Z"), dt)

// FIXME this actually ignores the tz. It's at least in the right ballpark;
// IMO better for content rendering than total failure.
dt, err = ParseTime("2017-07-09 15:30:00 -4")
dt, err = ParseDate("2017-07-09 15:30:00 -4")
require.NoError(t, err)
// require.Equal(t, timeMustParse("2017-07-09T15:30:00Z"), dt)
}

0 comments on commit a3a3473

Please sign in to comment.