Showing with 46 additions and 10 deletions.
  1. +3 −3 README.md
  2. +9 −7 src/date.js
  3. +18 −0 src/number/expand-pattern.js
  4. +16 −0 src/number/format.js
@@ -127,8 +127,8 @@ Dry tests show Globalize also works on the following browsers:

If you find any bugs, please just [let us
know](https://github.com/jquery/globalize/issues). We'll be glad to fix them for
the officially supported browsers, or at least update the documentation for the
unsupported ones.
the officially supported browsers, or at least to update the documentation for
the unsupported ones.


<a name="usage"></a>
@@ -348,7 +348,7 @@ Globalize.format( new Date( 2010, 10, 30, 17, 55 ), { datetime: "short" }, "de"

Comparison between different locales.

| locale | `Globalize.format( new Date( 2010, 10, 1, 17, 55 ), { datetime: "short" }` |
| locale | `Globalize.format( new Date( 2010, 10, 1, 17, 55 ), { datetime: "short" } )` |
| --- | --- |
| **en** | `"11/1/10, 5:55 PM"` |
| **en_GB** | `"01/11/2010 17:55"` |
@@ -10,32 +10,34 @@ define([
"./util/array/some"
], function( Cldr, commonGetLocale, Globalize, dateAllPresets, dateExpandPattern, dateFormat, dateParse, alwaysArray, arraySome ) {

var formatSuper;

/**
* Globalize.format( value, pattern, locale )
*
* @value [Date or Number]
* @value [Date]
*
* @pattern [String or Object] see date/expand_pattern for more info.
*
* @locale [String]
*
* Formats a date or number according to the given pattern string and the given locale (or the default locale if not specified).
*/
formatSuper = Globalize.format;
Globalize.format = function( value, pattern, locale ) {
locale = commonGetLocale( locale );
if ( formatSuper ) {
value = formatSuper.apply( Globalize, arguments );
}

if ( value instanceof Date ) {
locale = commonGetLocale( locale );

if ( !pattern ) {
throw new Error( "Missing pattern" );
}
pattern = dateExpandPattern( pattern, locale );

value = dateFormat( value, pattern, locale );

} else if ( typeof value === "number" ) {
// TODO value = numberFormat( value, pattern, locale );
throw new Error( "Number Format not implemented yet" );
}

return value;
@@ -44,7 +46,7 @@ Globalize.format = function( value, pattern, locale ) {
/**
* Globalize.parseDate( value, patterns, locale )
*
* @value [Date]
* @value [String]
*
* @patterns [Array] Optional. See date/expand_pattern for more info about each pattern. Defaults to the list of all presets defined in the locale (see date/all_presets for more info).
*
@@ -0,0 +1,18 @@
define(function() {

/**
* expandPattern( pattern, cldr )
*
* @pattern [TBD]
*
* @cldr [Cldr instance].
*
* Return the corresponding pattern.
* Eg for "en":
* - TBD
*/
return function( pattern, cldr ) {
return result;
};

});
@@ -0,0 +1,16 @@
define(function() {

/**
* format( number, pattern, cldr )
*
* @number [Number].
*
* @pattern [String] raw pattern.
*
* @cldr [Cldr instance].
*/
return function( number, pattern, cldr ) {
return null;
};

});