Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
* @copyright (c) 2016, Philipp Thuerwaechter & Pattrick Hueper
* @license BSD-3-Clause (see LICENSE.md in the root directory of this source tree)
*/
/* eslint-disable no-console, no-var */
var joda = require('@js-joda/core');
var jodaExtra = require('../dist/js-joda-extra');
var startInstant = joda.ZonedDateTime.of(2016, 11, 7, 0, 0, 0, 0, joda.ZoneOffset.UTC).toInstant();
var innerInstant = startInstant.plus(1, joda.ChronoUnit.DAYS);
var endInstant = startInstant.plus(2, joda.ChronoUnit.DAYS);
var outerInstant = startInstant.plus(3, joda.ChronoUnit.DAYS);
var interval = new jodaExtra.Interval(startInstant, endInstant);
console.log('toString:', interval.toString());
console.log('contains inner:', interval.contains(innerInstant));
console.log('contains outer:', interval.contains(outerInstant));
console.log('fr_FR formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(Locale.FRANCE)));
console.log('es_ES formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new Locale('es', 'ES', 'es'))));
console.log('ru_RU formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new Locale('ru', 'RU', 'ru'))));
console.log('zh_CN formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new Locale('zh', 'CN', 'zh'))));
console.log('hi_IN formatted string:', zdt.format(joda.DateTimeFormatter.ofPattern('eeee MMMM dd yyyy GGGG, hh:mm:ss a zzzz, zz, OOOO \'Week: \' ww, \'Quarter: \' QQQ').withLocale(new Locale('hi', 'IN', 'hi'))));
console.log('-------------------------------------------------------------------');
console.log('');
}
try {
var { Locale } = require('./build/js-joda-locale');
console.log('locale', Locale);
console.log('availableLocales:' + JSON.stringify(Locale.getAvailableLocales(), null, 4));
var zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('Europe/Berlin'));
outputDateInDifferentLocales(zdt);
zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('America/Chicago'));
outputDateInDifferentLocales(zdt);
zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('America/New_York'));
outputDateInDifferentLocales(zdt);
zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('Asia/Hong_Kong'));
outputDateInDifferentLocales(zdt);
} catch (e) {
console.error(e);
console.error('--------------------------------------------------------------------');
console.error('');
console.error('');
console.error('NOTE: if you see errors about missing modules/locales, you may need to run `npm run build-examples` before using this example.');
process.exit(1);
}
console.log('');
}
try {
var { Locale } = require('./build/js-joda-locale');
console.log('locale', Locale);
console.log('availableLocales:' + JSON.stringify(Locale.getAvailableLocales(), null, 4));
var zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('Europe/Berlin'));
outputDateInDifferentLocales(zdt);
zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('America/Chicago'));
outputDateInDifferentLocales(zdt);
zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('America/New_York'));
outputDateInDifferentLocales(zdt);
zdt = joda.ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, joda.ZoneId.of('Asia/Hong_Kong'));
outputDateInDifferentLocales(zdt);
} catch (e) {
console.error(e);
console.error('--------------------------------------------------------------------');
console.error('');
console.error('');
console.error('NOTE: if you see errors about missing modules/locales, you may need to run `npm run build-examples` before using this example.');
process.exit(1);
}