Files
BeWoPlaner/BeWoPlanerMobil/node_modules/globalize/doc/api/date/date-parser.md
Lyndon Jetten 5939aef72c Fat-Client:
Es ist möglich, allen Termin-Einladungen auf einmal zuzusagen

MoK:
DevExpress von Version 17.1 auf 21.1 aktualisiert
Reports testweise eingebaut
DevExpress-Scheduler testweise eingebaut
2021-10-13 16:00:33 +02:00

1.7 KiB

.dateParser( [options] ) ➜ function( value )

Return a function that parses a string representing a date into a JavaScript Date object according to the given options. The default parsing assumes numeric year, month, and day (i.e., { skeleton: "yMd" }).

The returned function is invoked with one argument: the String value to be parsed.

Parameters

options

See .dateFormatter() options.

value

String with date to be parsed, eg. "11/1/10, 5:55 PM".

Example

Prior to using any date methods, you must load cldr/main/{locale}/ca-gregorian.json, cldr/main/{locale}/timeZoneNames.json, cldr/supplemental/timeData.json, cldr/supplemental/weekData.json, and the CLDR content required by the number module. Read CLDR content if you need more information.

You can use the static method Globalize.dateParser(), which uses the default locale.

var parser;

Globalize.locale( "en" );
parser = Globalize.dateParser();

parser( "1/2/2013" );
// > Wed Jan 02 2013 00:00:00

Globalize.locale( "es" );
parser = Globalize.dateParser();

parser( "1/2/2013" );
// > Fri Feb 01 2013 00:00:00

You can use the instance method .dateParser(), which uses the instance locale.

var esParser = Globalize( "es" ).dateParser({ date: short });

esParser( "1/2/13" );
// > Fri Feb 01 2013 00:00:00

For improved performance on iterations, first create the parser. Then, reuse it on each loop.

var formattedDates = [ new Date( a ), new Date( b ), ... ];
var parser = Globalize( "en" ).dateParser({ time: "short" });

dates = formattedDates.map(function( formattedDate ) {
  return parser( formattedDate );
});