@bbn/bbn 1.0.459 → 1.0.460

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/date.d.ts CHANGED
@@ -43,7 +43,7 @@ declare class bbnDateTool {
43
43
  guessUnit(valueInMs: number): string | null;
44
44
  diff(date: any, unit?: string, abs?: boolean): number;
45
45
  calendar(format: string): string;
46
- getWeekDay(n: 0 | 1 | 2 | 3 | 4 | 5 | 6, mode?: 'long' | 'short' | 'narrow', locale?: string): String;
46
+ getWeekDay(n: 0 | 1 | 2 | 3 | 4 | 5 | 6, mode?: string, locale?: string): any;
47
47
  get daysInMonth(): number;
48
48
  }
49
49
  declare function generatorFunction(value: any, inputFormat?: null | String): bbnDateTool;
package/dist/date.js CHANGED
@@ -496,10 +496,39 @@ class bbnDateTool {
496
496
  return str;
497
497
  }
498
498
  getWeekDay(n, mode = 'long', locale) {
499
+ if (!mode) {
500
+ const letter = this.getWeekDay(n, 'narrow', locale);
501
+ const abbr = this.getWeekDay(n, 'short', locale);
502
+ const full = this.getWeekDay(n, 'long', locale);
503
+ return {
504
+ letter,
505
+ abbr,
506
+ full,
507
+ long: full,
508
+ short: abbr,
509
+ narrow: letter
510
+ };
511
+ }
512
+ let m;
513
+ if (mode === 'letter') {
514
+ m = 'narrow';
515
+ }
516
+ else if (mode === 'abbr') {
517
+ m = 'short';
518
+ }
519
+ else if (mode === 'full') {
520
+ m = 'long';
521
+ }
522
+ else if (!['long', 'short', 'narrow'].includes(mode)) {
523
+ throw new Error('Invalid mode for getWeekDay: ' + mode + '. Allowed values are "long", "short", "narrow", "letter", "abbr", "full".');
524
+ }
525
+ else {
526
+ m = mode;
527
+ }
499
528
  // Create a date with the right weekday
500
529
  // 2023-01-01 was a Sunday → base for offset
501
530
  const base = new Date(2023, 0, 1 + n);
502
- return base.toLocaleDateString([bbn.env.lang, ...navigator.languages], { weekday: mode });
531
+ return base.toLocaleDateString([locale || bbn.env.lang, ...navigator.languages], { weekday: m });
503
532
  }
504
533
  get daysInMonth() {
505
534
  if (this.isValid && !__classPrivateFieldGet(this, _bbnDateTool_daysInMonth, "f")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.459",
3
+ "version": "1.0.460",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",