Datejs icon indicating copy to clipboard operation
Datejs copied to clipboard

Some improvements

Open mastropinguino opened this issue 11 years ago • 0 comments

Hello, I'm using this library and I made some changes to library for my needs. In this PR you will find these changes:

  1. Added support for multiple locale loading. I needs to load all/some locales and switch between at runtime.
  2. Added support to switch between locale at runtime (globally or on instance). Eg.
// require('globalization/en-US');
// require('globalization/it-IT');
// Set global date locale to en-US, this call will set Data.CultureInfo also.
// When no default locale is set, Data.CultureInfo will be same of first locale file loaded.
// In this way my changes are backward compatible.
Date.setLocale('en-US');

var d1 = new Date(2013, 0, 1);
var d2 = new Date(2013, 0, 1);
console.debug(d1.toString('m')); // => "January 01"
console.debug(d2.toString('m')); // => "January 01"

d2.setLocale('it-IT');
console.debug(d1.toString('m')); // => "January 01"
console.debug(d2.toString('m')); // => "01 gennaio"

  1. Updated nodeunit to latest version which run on nodejs v0.10.3

I hope my work could be useful.

mastropinguino avatar Apr 26 '13 14:04 mastropinguino