How to use the globalize.loadTimeZone function in globalize

To help you get started, we’ve selected a few globalize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github globalizejs / globalize / examples / node-npm / main.js View on Github external
require( "cldr-data/main/en/ca-gregorian" ),
	require( "cldr-data/main/en/currencies" ),
	require( "cldr-data/main/en/dateFields" ),
	require( "cldr-data/main/en/numbers" ),
	require( "cldr-data/main/en/timeZoneNames" ),
	require( "cldr-data/main/en/units" ),
	require( "cldr-data/supplemental/currencyData" ),
	require( "cldr-data/supplemental/likelySubtags" ),
	require( "cldr-data/supplemental/metaZones" ),
	require( "cldr-data/supplemental/plurals" ),
	require( "cldr-data/supplemental/timeData" ),
	require( "cldr-data/supplemental/weekData" )
);
Globalize.loadMessages( require( "./messages/en" ) );

Globalize.loadTimeZone( require( "iana-tz-data" ) );

// Set "en" as our default locale.
Globalize.locale( "en" );

// Use Globalize to format dates.
console.log( Globalize.formatDate( new Date(), { datetime: "medium" } ) );

// Use Globalize to format dates in specific time zones.
console.log( Globalize.formatDate( new Date(), {
	datetime: "full",
	timeZone: "America/Sao_Paulo"
}));

// Use Globalize to format dates to parts.
console.log( Globalize.formatDateToParts( new Date(), { datetime: "medium" } ) );
github globalizejs / globalize-compiler / lib / compile-extracts.js View on Github external
return require( "iana-tz-data" );
	};
	if ( typeof timeZone === "object" ) {
		timeZoneObject = timeZone;
		timeZone = function() {
			return timeZoneObject;
		};
	}

	// TODO
	//assert( defaultLocale )
	//assert( extracts )

	Globalize.load( cldr( defaultLocale ) );
	Globalize.loadMessages( messages( defaultLocale ) );
	Globalize.loadTimeZone( timeZone() );
	Globalize.locale( defaultLocale );
	formattersAndParsers = alwaysArray( extracts ).reduce(function( sum, extract ) {
		[].push.apply( sum, extract( Globalize ) );
		return sum;
	}, [] );

	return compile( formattersAndParsers, compilerOptions );
}
github globalizejs / globalize-compiler / lib / compile-extracts.js View on Github external
return require( "iana-tz-data" );
	};
	if ( typeof timeZoneData === "object" ) {
		timeZoneDataObject = timeZoneData;
		timeZoneData = function() {
			return timeZoneDataObject;
		};
	}

	// TODO
	//assert( defaultLocale )
	//assert( extracts )

	Globalize.load( cldr( defaultLocale ) );
	Globalize.loadMessages( messages( defaultLocale ) );
	Globalize.loadTimeZone( timeZoneData() );
	Globalize.locale( defaultLocale );
	formattersAndParsers = alwaysArray( extracts ).reduce(function( sum, extract ) {
		[].push.apply( sum, extract( Globalize ) );
		return sum;
	}, [] );

	return compile( formattersAndParsers, compilerOptions );
}