Skip to content

Commit

Permalink
fix suffixes for days, weeks and months
Browse files Browse the repository at this point in the history
  • Loading branch information
orifn committed Jul 28, 2020
1 parent 23faf6e commit 7b3e1a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
20 changes: 17 additions & 3 deletions src/locale/tg.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,24 @@ export default moment.defineLocale('tg', {
}
},
dayOfMonthOrdinalParse: /\d{1,2}-(ум|юм)/,
ordinal: function (number) {
ordinal: function (number, period) {
var a = number % 10,
b = number >= 100 ? 100 : null;
return number + (suffixes[number] || suffixes[a] || suffixes[b]);
b = number >= 100 ? 100 : null,
output = number + (suffixes[number] || suffixes[a] || suffixes[b]);

switch (period) {
case 'M':
case 'd':
case 'DDD':
return output;
case 'D':
return output + 'и';
case 'w':
case 'W':
return output;
default:
return output;
}
},
week: {
dow: 1, // Monday is the first day of the week.
Expand Down
4 changes: 2 additions & 2 deletions src/test/locale/tg.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ test('format', function (assert) {
var a = [
[
'dddd, Do MMMM YYYY, h:mm:ss',
'якшанбе, 14-ум феврали 2010, 3:25:50',
'якшанбе, 14-уми феврали 2010, 3:25:50',
],
['ddd, h A', 'яшб, 3 рӯз'],
['M Mo MM MMMM MMM', '2 2-юм 02 феврал фев'],
['YYYY YY', '2010 10'],
['D Do DD', '14 14-ум 14'],
['D Do DD', '14 14-уми 14'],
['d do dddd ddd dd', '0 0-ум якшанбе яшб яш'],
['DDD DDDo DDDD', '45 45-ум 045'],
['w wo ww', '7 7-ум 07'],
Expand Down

0 comments on commit 7b3e1a0

Please sign in to comment.