secret
Last active

Moment 2.1.0 Changelog

  • Download Gist
changelog.md
Markdown

New Languages

  • Breton (br)
  • Modern Greek (el)
  • Hindi (hi)
  • Georgian (ka)
  • Norwegian Nyorsk (nn)
  • Slovak (sk)

Better Week Support

Week Years

Added moment#weekYear to get/set the localized week year.

Added moment#isoWeekYear to get/set the iso week year.

Added gg gggg ggggg tokens for localized week year and GG GGGG GGGGG tokens for iso week year.

Weekdays

Added moment#weekday to get/set the localized weekday.

Added moment#isoWeekday to get/set the iso weekday.

Added e token for the localized weekday number and E for the iso weekday.

Iso Week

Added moment#isoWeek to get/set the iso week.

Added ability to set offset with moment#zone.

It is now possible to set the offset by passing in the number of minutes offset from GMT.

moment().zone(120);

If the input is less than 16 and greater than -16, it will interpret your input as hours instead.

// these are equivalent
moment().zone(480);
moment().zone(8);

It is also possible to set the zone from a string.

moment().zone("-08:00");

moment#zone will search the string for the first match of +00:00 +0000 -00:00 -0000, so you can even pass an ISO8601 formatted string and the moment will be changed to that zone.

moment().zone("2013-03-07T07:00:00-08:00");

Added hooks for timezone name and timezone abbreviation.

Libraries like moment-timezone can add support for timezone names by overriding moment#zoneAbbr and moment#zoneName. The z zz tokens are added back in to render the output of those methods.

Customization

The ordinal callback method now passes the token that is being ordinalized.

// From the Chinese language file
function ordinal(number, token) {
    switch (token) {
    case "d" :
    case "D" :
    case "DDD" :
        return number + "日";
    case "M" :
        return number + "月";
    case "w" :
    case "W" :
        return number + "周";
    default :
        return number;
    }
}

Parsing Weekdays

Added the ability to set the weekday from a string. The string will be parsed in the moment's language.

moment().day("Sunday");

Parsing Months

Added the ability to set the month from a string. The string will be parsed in the moment's language.

moment().month("January");

Parsing AM / PM

Added the ability for a language to handle parsing AM/PM tokens.

It is now possible for a language to define how their am/pm tokens are parsed.

This involves setting a meridiemParse regex property to define what should be considered a am/pm string and an isPm callback function to return a boolean from an am/pm string.

See the docs for more details.

Added parsing of ASP.NET time span into a duration

Added support for parsing ASP.NET style time spans. The following formats are supported.

The format is an hour, minute, second string separated by colons like 23:59:59. The number of days can be prefixed with a dot separator like so 7.23:59:59. Partial seconds are supported as well 23:59:59.999.

moment.duration('23:59:59');
moment.duration('23:59:59.999');
moment.duration('7.23:59:59');
moment.duration('7.23:59:59.999');

moment#startOf and moment#endOf now use localized weekday.

moment().startOf('week'); // will use the locale's starting weekday

Added moment#min and moment#max.

Set the maximum value for a moment.

Sometimes, server clocks are not quite in sync with client clocks. This ends up displaying humanized strings such as "in a few seconds" rather than "a few seconds ago".

moment#max was added to allow you to set the maximum value for a moment.

var momentFromServer = moment(input);
var now = moment();
var clampedMoment = momentFromServer.max(now);

moment#min is the counterpart for moment#max.

Added moment#toISOString

This is essentially a proxy to this.utc().format('YYYY-MM-DD[T]HH:mm:ss.SSS[Z]').

moment#toJSON is now an alias to moment#toISOString.

Added duration#add and duration#subtract

This method signature is the same as moment#add and moment#subtract, but operates on durations.

var a = moment.duration(1, 'day');
a.add(2, 'days').days(); // 3

Added duration#get and duration#as

Rather than using duration#minutes, you can now also use duration#get('minutes').

Likewise, duration#as('minutes') is equivalent to duration#asMinutes.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.