New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Date behavior #163

Closed
danawoodman opened this Issue Jan 2, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@danawoodman
Copy link
Contributor

danawoodman commented Jan 2, 2014

I have a section for "posts". I have a layout/posts/single.html layout file that calls date like so:

{{ .Date.Format "March 1, 2010" }}

The fontmatter of my posts are like (found in content/posts/my-post.md):

---
title: "Post title here"
date: "2014-01-02"

---

And when I build my site I get the following date: March 1, 2010

On another post, I'm getting March 1, 1010 which is even weirder.

What's going on? Is there some config I'm missing? Why is it using the Format string value and not the actual date?

@spf13

This comment has been minimized.

Copy link
Contributor

spf13 commented Jan 2, 2014

You misunderstand how Date.Format works. The go documentation on this isn’t very clear IMO.
You need to provide the format you want to use with a specific date. 

Mon Jan 2 15:04:05 -0700 MST 2006

It kinda looks like M 1 2 3:4:5 6 7 which I believe is why they picked it.

Right now you are just providing a string which it is copying unaltered.

See more at:
http://golang.org/pkg/time/#example_Time_Format

Best,
Steve

-- 
Steve Francia
http://stevefrancia.com
http://spf13.com
http://twitter.com/spf13

On January 2, 2014 at 3:46:12 PM, Dana Woodman (notifications@github.com) wrote:

I have a section for "posts". I have a layout/posts/single.html layout file that calls date like so:

{{ .Date.Format "March 1, 2010" }}
The fontmatter of my posts are like (found in content/posts/my-post.md):


title: "Post title here"

date: "2014-01-02"

And when I build my site I get the following date: March 1, 2010

On another post, I'm getting March 1, 1010 which is even weirder.

What's going on? Is there some config I'm missing? Why is it using the Format string value and not the actual date?


Reply to this email directly or view it on GitHub.

@danawoodman

This comment has been minimized.

Copy link
Contributor

danawoodman commented Jan 2, 2014

Doh… You're absolutely right, it wasn't clear at all. Thanks for the tip, working now 👍

On Thursday, January 2, 2014 at 1:04 PM, Steve Francia wrote:

You misunderstand how Date.Format works. The go documentation on this isn’t very clear IMO.
You need to provide the format you want to use with a specific date.

Mon Jan 2 15:04:05 -0700 MST 2006

It kinda looks like M 1 2 3:4:5 6 7 which I believe is why they picked it.

Right now you are just providing a string which it is copying unaltered.

See more at:
http://golang.org/pkg/time/#example_Time_Format

Best,
Steve

Steve Francia
http://stevefrancia.com
http://spf13.com
http://twitter.com/spf13

On January 2, 2014 at 3:46:12 PM, Dana Woodman (notifications@github.com (mailto:notifications@github.com)) wrote:

I have a section for "posts". I have a layout/posts/single.html layout file that calls date like so:

{{ .Date.Format "March 1, 2010" }}
The fontmatter of my posts are like (found in content/posts/my-post.md (http://my-post.md)):


title: "Post title here"

date: "2014-01-02"

And when I build my site I get the following date: March 1, 2010

On another post, I'm getting March 1, 1010 which is even weirder.

What's going on? Is there some config I'm missing? Why is it using the Format string value and not the actual date?


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub (#163 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment