Open capi1O opened 5 years ago
Hi,
I do not know if this is somehow language specific but in my case it does work fine with "de".
import moment from 'moment';
import 'moment/locale/de'
import 'moment-duration-format';
moment.locale('de');
moment.updateLocale('de ', {
durationLabelsStandard: {
S: 'Millisekunde',
SS: 'Millisekunden',
s: 'Sekunde',
ss: 'Sekunden',
m: 'Minute',
mm: 'Minuten',
h: 'Stunde',
hh: 'Stunden',
d: 'Tag',
dd: 'Tage',
w: 'Woche',
ww: 'Wochen',
M: 'Monat',
MM: 'Monate',
y: 'Jahr',
yy: 'Jahre'
},
});
const start = moment('2020-01-30', 'YYYY-MM-DD');
const end = moment('2020-01-31', 'YYYY-MM-DD');
const difference = moment.duration(end.diff(start));
const duration = difference.format();
console.info(duration); // --> outputs 1 Tag
Versions:
Maybe it has already been fixed in the meantime.
Hi,
I do not know if this is somehow language specific but in my case it does work fine with "de".
import moment from 'moment'; import 'moment/locale/de' import 'moment-duration-format'; moment.locale('de'); moment.updateLocale('de ', { durationLabelsStandard: { S: 'Millisekunde', SS: 'Millisekunden', s: 'Sekunde', ss: 'Sekunden', m: 'Minute', mm: 'Minuten', h: 'Stunde', hh: 'Stunden', d: 'Tag', dd: 'Tage', w: 'Woche', ww: 'Wochen', M: 'Monat', MM: 'Monate', y: 'Jahr', yy: 'Jahre' }, }); const start = moment('2020-01-30', 'YYYY-MM-DD'); const end = moment('2020-01-31', 'YYYY-MM-DD'); const difference = moment.duration(end.diff(start)); const duration = difference.format(); console.info(duration); // --> outputs 1 Tag
Versions:
* "moment": "^2.24.0", * "moment-duration-format": "^2.3.2",
Maybe it has already been fixed in the meantime.
Can confirm that localization works on these versions.
Anyhow, I doesn't work with Unit labels like this
y [years], M [months]
With underscore or double underscores it works perfectly:
m __
The Problem seems to be caused by momentDurationFormatSetup
.
I just deleted this method from my code an it worked:
import moment from 'moment'
import 'moment-duration-format'
import 'moment/locale/de'
this does not work for me
Exactly the same problem with latest versions (moment.js 2.25.3 + moment.duration-format 2.2.2) I also tried the versions around Dec 2017, still the same bug. (moment.js 2.19.3 + moment.duration-format 2.1.0)
Any updates ????
Would be nice to have locale switching working - any solutions?
Project is dead
https://github.com/jsmreese/moment-duration-format/issues/124#issuecomment-770070357
... you have to import
moment-duration-format
before changing the locale.
It's working for me
momentDurationFormatSetup(moment);
moment.locale("id");
console.log(moment.localeData('es'));
=> durationLabels* keys are presentconsole.log(moment(1316116057189).fromNow());
=> spanish outputconsole.log(moment.duration(60, 's').format('s __'));
=> 60 secondsversions :