@eclipse-scout/core 22.0.22 → 22.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/file-list CHANGED
@@ -1,5 +1,5 @@
1
- eclipse-scout-core-c4cad26b336b02535421.min.js
2
- eclipse-scout-core-c4cad26b336b02535421.min.js.map
1
+ eclipse-scout-core-a56958ac9954d00cc62a.min.js
2
+ eclipse-scout-core-a56958ac9954d00cc62a.min.js.map
3
3
  eclipse-scout-core-theme-dark-fd0e080c10f65e67b68b.min.css
4
4
  eclipse-scout-core-theme-dark.css
5
5
  eclipse-scout-core-theme-dark.css.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-scout/core",
3
- "version": "22.0.22",
3
+ "version": "22.0.26",
4
4
  "description": "Eclipse Scout runtime",
5
5
  "author": "BSI Business Systems Integration AG",
6
6
  "homepage": "https://www.eclipse.org/scout",
@@ -26,7 +26,7 @@
26
26
  "src"
27
27
  ],
28
28
  "devDependencies": {
29
- "@eclipse-scout/cli": "22.0.22",
29
+ "@eclipse-scout/cli": "22.0.26",
30
30
  "@eclipse-scout/releng": "^22.0.0",
31
31
  "jasmine-core": "3.10.1",
32
32
  "jasmine-ajax": "4.0.0",
package/src/scout.js CHANGED
@@ -85,11 +85,10 @@ export function assertValue(value, msg) {
85
85
  /**
86
86
  * Throws an error if the given value is not an instance of the given type. Otherwise, the value is returned.
87
87
  *
88
- * @template T
89
- * @param {T} value - value to check
88
+ * @param {*} value - value to check
90
89
  * @param {*} type - type to check against with "instanceof"
91
90
  * @param {string} [msg] - optional error message when the assertion fails
92
- * @return {T}
91
+ * @return {*}
93
92
  */
94
93
  export function assertInstance(value, type, msg) {
95
94
  if (!(value instanceof type)) {
@@ -86,11 +86,20 @@ export default class DateFormat {
86
86
  // (e.g. MMMM) to short (e.g. M).
87
87
  this._patternDefinitions = [
88
88
  // --- Year ---
89
+ // This definition can _format_ dates with years with 4 or more digits.
90
+ // See: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
91
+ // chapter 'Date and Time Patterns', paragraph 'Year'
92
+ // We do not allow to _parse_ a date with 5 or more digits. We could allow that in a
93
+ // future release, but it could have an impact on backend logic, databases, etc.
89
94
  new DateFormatPatternDefinition({
90
95
  type: DateFormatPatternType.YEAR,
91
- terms: ['yyyy'],
96
+ terms: ['yyyy'], // meaning: any number of digits is allowed
92
97
  dateFormat: this,
93
- formatFunction: (formatContext, acceptedTerm) => strings.padZeroLeft(formatContext.inputDate.getFullYear(), 4).slice(-4),
98
+ formatFunction: (formatContext, acceptedTerm) => {
99
+ let year = formatContext.inputDate.getFullYear();
100
+ let numDigits = Math.max(4, year.toString().length); // min. digits = 4
101
+ return strings.padZeroLeft(formatContext.inputDate.getFullYear(), numDigits).slice(-numDigits);
102
+ },
94
103
  parseRegExp: /^(\d{4})(.*)$/,
95
104
  applyMatchFunction: (parseContext, match, acceptedTerm) => {
96
105
  parseContext.matchInfo.year = match;
package/src/util/dates.js CHANGED
@@ -181,6 +181,8 @@ export function compareDays(date1, date2) {
181
181
  * are guaranteed to be digits. If the date argument is omitted, the current date is
182
182
  * used. The returned string in in UTC if the argument 'utc' is true, otherwise the
183
183
  * result is in local time (default).
184
+ *
185
+ * @deprecated this function will be deleted in release 23.1. Use DateFormat.js instead
184
186
  */
185
187
  export function timestamp(date, utc) {
186
188
  // (note: month is 0-indexed)
@@ -307,7 +309,7 @@ export function parseJsonDate(jsonDate) {
307
309
  utc = false;
308
310
 
309
311
  // Date + Time
310
- let matches = /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})\.(\d{3})(Z?)$/.exec(jsonDate);
312
+ let matches = /^\+?(\d{4,5})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})\.(\d{3})(Z?)$/.exec(jsonDate);
311
313
  if (matches !== null) {
312
314
  year = matches[1];
313
315
  month = matches[2];
@@ -319,7 +321,7 @@ export function parseJsonDate(jsonDate) {
319
321
  utc = matches[8] === 'Z';
320
322
  } else {
321
323
  // Date only
322
- matches = /^(\d{4})-(\d{2})-(\d{2})(Z?)$/.exec(jsonDate);
324
+ matches = /^\+?(\d{4,5})-(\d{2})-(\d{2})(Z?)$/.exec(jsonDate);
323
325
  if (matches !== null) {
324
326
  year = matches[1];
325
327
  month = matches[2];
@@ -378,7 +380,7 @@ export function toJsonDate(date, utc, includeDate, includeTime) {
378
380
  let datePart, timePart, utcPart;
379
381
  if (utc) {
380
382
  // (note: month is 0-indexed)
381
- datePart = strings.padZeroLeft(date.getUTCFullYear(), 4) + '-' +
383
+ datePart = getYearPart(date) + '-' +
382
384
  strings.padZeroLeft(date.getUTCMonth() + 1, 2) + '-' +
383
385
  strings.padZeroLeft(date.getUTCDate(), 2);
384
386
  timePart = strings.padZeroLeft(date.getUTCHours(), 2) + ':' +
@@ -388,7 +390,7 @@ export function toJsonDate(date, utc, includeDate, includeTime) {
388
390
  utcPart = 'Z';
389
391
  } else {
390
392
  // (note: month is 0-indexed)
391
- datePart = strings.padZeroLeft(date.getFullYear(), 4) + '-' +
393
+ datePart = getYearPart(date) + '-' +
392
394
  strings.padZeroLeft(date.getMonth() + 1, 2) + '-' +
393
395
  strings.padZeroLeft(date.getDate(), 2);
394
396
  timePart = strings.padZeroLeft(date.getHours(), 2) + ':' +
@@ -409,6 +411,14 @@ export function toJsonDate(date, utc, includeDate, includeTime) {
409
411
  }
410
412
  result += utcPart;
411
413
  return result;
414
+
415
+ function getYearPart(date) {
416
+ let year = date.getFullYear();
417
+ if (year > 9999) {
418
+ return '+' + year;
419
+ }
420
+ return strings.padZeroLeft(year, 4);
421
+ }
412
422
  }
413
423
 
414
424
  export function toJsonDateRange(range) {
@@ -424,7 +434,7 @@ export function toJsonDateRange(range) {
424
434
  *
425
435
  * The format is as follows:
426
436
  *
427
- * [Year#4]-[Month#2]-[Day#2] [Hours#2]:[Minutes#2]:[Seconds#2].[Milliseconds#3][Z]
437
+ * [Year#4|5]-[Month#2]-[Day#2] [Hours#2]:[Minutes#2]:[Seconds#2].[Milliseconds#3][Z]
428
438
  *
429
439
  * The year component is mandatory, but all others are optional (starting from the beginning).
430
440
  * The date is constructed using the local time zone. If the last character is 'Z', then
@@ -432,7 +442,7 @@ export function toJsonDateRange(range) {
432
442
  */
433
443
  export function create(dateString) {
434
444
  if (dateString) {
435
- let matches = /^(\d{4})(?:-(\d{2})(?:-(\d{2})(?: (\d{2})(?::(\d{2})(?::(\d{2})(?:\.(\d{3}))?(Z?))?)?)?)?)?/.exec(dateString);
445
+ let matches = /^(\d{4,5})(?:-(\d{2})(?:-(\d{2})(?: (\d{2})(?::(\d{2})(?::(\d{2})(?:\.(\d{3}))?(Z?))?)?)?)?)?/.exec(dateString);
436
446
  if (matches === null) {
437
447
  throw new Error('Unparsable date: ' + dateString);
438
448
  }