-
Notifications
You must be signed in to change notification settings - Fork 7
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
Format date helper #882
Format date helper #882
Conversation
Use moment js to easily format dates, by default will use the "LL" format if no format is specified {{format-date invitation.createdAt}} March 9, 2015 {{format-date invitation.createdAt format="L"}} 03/09/2015
I wanna mention that this handlebars helper was created with the ember generator.. I had trouble making the actual syntax to work with the tests To test this handlebars snippets I could create an object view and compile it, because the helper expects 2 parameters, the value and options but I decided to keep it simple and send the second parameter as an object, this issue https://github.com/rwjblue/ember-qunit/issues/5 mentions the addition of moduleForSnippet we could wait for it and keep the bound helpers simple |
@theharq any chance you could find a place in our code where we format a date and use this helper, so we have a use case in core? |
hi @mikem, well after looking the code I did not find a place where you guys are formatting a date at least in the ember templates, the reason I created this helper is because I thought that could be useful to have a consistency in the format we display dates ( a human readable or international format, sometimes I have a hard time when I see american date format hehe ), but I think, maybe we could move the calculation to the client side (is a good practice) for example here: We gain some flexibility of momentjs also, I could update the default format of the helper to use the one use in the serializer:
is equivalent in moment to:
let me know what do you think, if its too specific to be in the tahi core I could leave it in "my" engine ;) |
@theharq there's a date on the profile. Visit I think it's useful to have this in core, that's why I'm trying to find a use for it :-) |
yup it will work, ex: but if change the dates to and leave the default format ( I can use any format that momentjs support) ` {{format-date a.startDate}} - {{format-date a.displayEndDate}} ``
I get A.T. Still University of Health Sciences which I consider more human friendly, so the answer is yes, we could use this helper in parts of the tahi core |
@theharq great! Please update this PR to use |
Add a guard clause that returns the original value if is not valid
I've updated the helper to ignore invalid formats, because the returns in the profile is sometimes "Current" so the helper just ignore this invalid strings to parse let me know any other improvement ;) |
Use moment js to easily format dates, by default will use the "LL" format if is not specified
{{format-date invitation.createdAt}}
March 9, 2015
{{format-date invitation.createdAt format="L"}}
03/09/2015