Skip to content

Commit

Permalink
Merge dddcdbb into 0dcaaa6
Browse files Browse the repository at this point in the history
  • Loading branch information
rasidre committed Oct 27, 2020
2 parents 0dcaaa6 + dddcdbb commit 15580c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/locale/bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@

import moment from '../moment';

function processRelativeTime(number, withoutSuffix, key, isFuture) {
switch (key) {
case 'm':
return withoutSuffix
? 'jedna minuta'
: isFuture
? 'jednu minutu'
: 'jedne minute';
}
}

function translate(number, withoutSuffix, key) {
var result = number + ' ';
switch (key) {
Expand All @@ -17,8 +28,6 @@ function translate(number, withoutSuffix, key) {
result += 'sekundi';
}
return result;
case 'm':
return withoutSuffix ? 'jedna minuta' : 'jedne minute';
case 'mm':
if (number === 1) {
result += 'minuta';
Expand All @@ -29,7 +38,7 @@ function translate(number, withoutSuffix, key) {
}
return result;
case 'h':
return withoutSuffix ? 'jedan sat' : 'jednog sata';
return withoutSuffix ? 'jedan sat' : 'jedan sat';
case 'hh':
if (number === 1) {
result += 'sat';
Expand Down Expand Up @@ -129,7 +138,7 @@ export default moment.defineLocale('bs', {
past: 'prije %s',
s: 'par sekundi',
ss: translate,
m: translate,
m: processRelativeTime,
mm: translate,
h: translate,
hh: translate,
Expand Down
11 changes: 11 additions & 0 deletions src/test/locale/bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ test('now from now', function (assert) {
'prije par sekundi',
'now from now should display as in the past'
);
assert.equal(
moment().subtract({ h: 1 }).fromNow(),
'prije jedan sat',
'1 hour ago'
);
});

test('fromNow', function (assert) {
Expand All @@ -308,6 +313,12 @@ test('fromNow', function (assert) {
'za par sekundi',
'in a few seconds'
);
assert.equal(
moment().add({ m: 1 }).fromNow(),
'za jednu minutu',
'in 1 minute'
);
assert.equal(moment().add({ h: 1 }).fromNow(), 'za jedan sat', 'in 1 hour');
assert.equal(moment().add({ d: 5 }).fromNow(), 'za 5 dana', 'in 5 days');
});

Expand Down

0 comments on commit 15580c9

Please sign in to comment.