AngularJS Filter by firefox / safari filter date

I'm having trouble getting the date to display correctly in Firefox and Safari using a custom filter that supports the suffix of the day. I get a UTC date in the format:

yyyy-mm-dd hh-mm-ss

Then I have a custom DateFilterone that replaces the oosuffix, i.e. 2nd:

var suffixes = ["th", "st", "nd", "rd"];

return function(input, format) {
    input = new Date(input).getTime();
    var dtfilter = $filter('date')(input, format);
    var day = parseInt($filter('date')(input, 'dd'));
    var relevantDigits = (day < 30) ? day % 20 : day % 30;
    var suffix = (relevantDigits <= 3) ? suffixes[relevantDigits] : suffixes[0];

    return dtfilter.replace('oo', suffix);
};

This works in Chrome, I pass the following to my template and get the expected date:

{{ date.date_utc | DateFilter:'EEEE MMMM doo yyyy' | uppercase }} = SATURDAY NOVEMBER 1ST 2014

In Firefox / Safari, this returns as:

UNDEFINED UNDEFINED NANTH 0NAN

Research here and here suggest me pass ISO time, or timestamp in my facility Date.

It seems I am already doing this through .getTime(). I also tried .toISOString(), but this does not return anything in Firefox / Safari!

Any ideas?

+4
1

, Firefox/Safari .toISOString() "" ...

input = input.replace(/(.+) (.+)/, "$1T$2Z");
input = new Date(input).getTime();

ISO .

+9

All Articles