Closed rxaviers closed 7 years ago
The below is wrong, it should use "British Summer Time" name instead.
Globalize('en-GB').formatDate(new Date(2017,8,1), {datetime: 'full', timeZone: 'Europe/London'})
'Friday, 1 September 2017 at 04:00:00 GMT+01:00'
Edit: this has been fixed.
To quickly demo what's coming... I hope you like it!
npm install globalize@1.3.0-alpha.0 cldr-data iana-tz-data
var Globalize = require( "globalize" );
Globalize.load( require( "cldr-data" ).entireSupplemental() );
Globalize.load( require( "cldr-data" ).entireMainFor( "en" ) );
Globalize.loadIANATimezone( require( "iana-tz-data" ) );
Globalize( "en" ).formatDate(new Date(), {datetime: "short", timeZone: "America/Los_Angeles"});
// > '3/19/17, 3:19 PM'
Globalize( "en" ).formatDate(new Date(), {datetime: "short", timeZone: "America/New_York"});
// > '3/19/17, 6:19 PM'
Globalize( "en" ).formatDate(new Date(), {datetime: "short", timeZone: "America/Sao_Paulo"});
// > '3/19/17, 7:19 PM'
Globalize( "en" ).formatDate(new Date(), {datetime: "short", timeZone: "Europe/Berlin"});
// > '3/19/17, 11:19 PM'
Globalize( "en" ).formatDate(new Date(), {datetime: "full", timeZone: "America/Los_Angeles"});
// > 'Sunday, March 19, 2017 at 3:19:22 PM Pacific Daylight Time'
Globalize( "en" ).formatDate(new Date(), {datetime: "full", timeZone: "America/New_York"});
// > 'Sunday, March 19, 2017 at 6:19:22 PM Eastern Daylight Time'
Globalize( "en" ).formatDate(new Date(), {datetime: "full", timeZone: "America/Sao_Paulo"});
// > 'Sunday, March 19, 2017 at 7:19:22 PM Brasilia Standard Time'
Globalize( "en" ).formatDate(new Date(), {datetime: "full", timeZone: "Europe/Berlin"});
// > 'Sunday, March 19, 2017 at 11:19:53 PM Central European Standard Time'
@rxaviers I LOVE YOU. We need this.
Any updates on this? We need to add support for timezones in the next few weeks.
Globalize compiler isn't working with the alpha. Versions used:
"globalize": "1.3.0-alpha.3",
"globalize-compiler": "0.3.0-alpha.3",
"iana-tz-data": "2017.1.0",
Here's the script that's failing:
const ianaTzData = require('iana-tz-data');
const Globalize = require("globalize");
const cldrData = require('./vendor/cldr-data.json');
Globalize.loadIANATimeZone(ianaTzData);
Globalize.load(cldrData);
Globalize.locale("en");
const date = new Date();
const d1 = Globalize.dateFormatter({ datetime: "full" })
console.log(d1(date))
const globalizeCompiler = require('globalize-compiler');
const out = globalizeCompiler.compile([d1])
It fails here in the globalize compiler, failing to extract the formatter because it doesn't have the runtimeArgs.
Hi @mattyork, we should have a 1.3.0 soon.
About the issue above, Thanks for reporting it.
For the record, the fix for the dateFormatter runtime issue is here: #724
Rebased and squashed
Merged :man_dancing:
Checklist:
options.timeZone
options.timeZone
options.timeZone
Notes: