Skip to content
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

Custom date format not being used in format-message #58

Closed
rlivsey opened this issue Feb 23, 2015 · 6 comments · Fixed by #59
Closed

Custom date format not being used in format-message #58

rlivsey opened this issue Feb 23, 2015 · 6 comments · Fixed by #59
Assignees
Labels
bug Something isn't working Hacktoberfest Issue counts towards Hacktoberfest

Comments

@rlivsey
Copy link
Contributor

rlivsey commented Feb 23, 2015

I've added a custom date formatter to simply display the short form of a week-day, but that doesn't seem to be being used in a message. It's working with format-date but not with format-message.

Here's an example repo containing an Ember app with the code below:

Eg:

export default {
  date: {
    shortWeekDay: {
      weekday: "short"
    }
  }
};

This is then used in a message:

import Locale from 'ember-intl/models/locale';

export default Locale.extend({
  locale: 'en',
  messages: {
    test: "should be a week-day initial: {day, date, shortWeekDay}"
  }
});

When displaying this in a template I'd expect the same date format to be shown:

<p>format-date: {{format-date date format="shortWeekDay"}}</p>
<p>format-message: {{format-message (intl-get "messages.test") day=date}}</p>

But instead I get the following:

screenshot 2015-02-23 20 24 41

@rlivsey rlivsey changed the title Custom date format not being used in message-format Custom date format not being used in format-message Feb 23, 2015
@rlivsey
Copy link
Contributor Author

rlivsey commented Feb 23, 2015

FWIW - I'm seeing the same thing happen with time formats too, {{format-time}} works fine, but using the same custom format in {{format-message}} doesn't work.

@jasonmit
Copy link
Member

You're absolutely correct, they should be returning the same results. I'll do some digging tonight as to what is going on.

@jasonmit jasonmit added bug Something isn't working Hacktoberfest Issue counts towards Hacktoberfest labels Feb 23, 2015
@jasonmit jasonmit self-assigned this Feb 23, 2015
@jasonmit
Copy link
Member

Ah, found the problem. So day is more or less a "reserved" format option parameter for format-message, which is a mistake. Format-message should not take any format options as arguments to the helper. The following will work, but I'll also remove the options I have on format-message.

Will work for you:
{{format-message '{dayOfWeek, date, shortWeekDay}' dayOfWeek=yesterday}}

Full list of properties that will be treated as format options:


Format date/time

'localeMatcher', 'timeZone', 'hour12', 'formatMatcher', 'weekday', 'era', 'year', 'month', 'day', 'hour', 'minute', 'second','timeZoneName'

Format relative

'style', 'units'

Format number

'localeMatcher', 'style', 'currency', 'currencyDisplay', 'useGrouping', 'minimumIntegerDigits', 'minimumFractionDigits','maximumFractionDigits', 'minimumSignificantDigits', 'maximumSignificantDigits'

@jasonmit
Copy link
Member

1.1.4 published which will resolve this. Side note, phantom doesn't seem to like the weekday formatter, in case your tests fail phantom but pass in chrome.

@rlivsey
Copy link
Contributor Author

rlivsey commented Feb 24, 2015

Awesome, thanks. Trust me to pick a reserved word for my first experiment!

@rlivsey
Copy link
Contributor Author

rlivsey commented Feb 24, 2015

Just updated to 1.1.4 and can confirm this resolves the issue in my app. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Hacktoberfest Issue counts towards Hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants