@servicetitan/datetime-utils 32.3.0 → 32.4.1

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Culture } from '@servicetitan/culture';
1
+ import type { Culture } from '@servicetitan/culture';
2
2
  export declare class DateTimeUtils {
3
3
  private locale;
4
4
  private dateFormatter;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiB,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAsB/D,qBACa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,kBAAkB,CAAsB;IAChD,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,uBAAuB,CAAsB;IACrD,OAAO,CAAC,kBAAkB,CAAsB;IAChD,OAAO,CAAC,sBAAsB,CAAsB;IACpD,OAAO,CAAC,wBAAwB,CAAsB;IACtD,OAAO,CAAC,yBAAyB,CAAsB;gBAEpB,OAAO,EAAE,OAAO;IA8CnD;;;;;;;;;OASG;IACH,MAAM,GAAI,MAAM,IAAI,EAAE,UAAU,IAAI,CAAC,qBAAqB,KAAG,MAAM,CAEjE;IAEF;;;OAGG;IACH,UAAU,GAAI,MAAM,IAAI,KAAG,MAAM,CAE/B;IAEF;;;OAGG;IACH,eAAe,GAAI,MAAM,IAAI,KAAG,MAAM,CAEpC;IAEF;;;OAGG;IACH,cAAc,GAAI,MAAM,IAAI,KAAG,MAAM,CAEnC;IAEF;;;OAGG;IACH,kBAAkB,GAAI,MAAM,IAAI,KAAG,MAAM,CAEvC;IAEF;;;OAGG;IACH,mBAAmB,GAAI,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EzC;IAEF,SAAS,QAAO,MAAM,CAEpB;CACL"}
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ function _ts_param(paramIndex, decorator) {
26
26
  };
27
27
  }
28
28
  import { injectable, inject } from '@servicetitan/react-ioc';
29
- import { CULTURE_TOKEN, Culture } from '@servicetitan/culture';
29
+ import { CULTURE_TOKEN } from '@servicetitan/culture';
30
30
  function ordinalString(num) {
31
31
  switch(num % 100){
32
32
  case 11:
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import { injectable, inject } from '@servicetitan/react-ioc';\nimport { CULTURE_TOKEN, Culture } from '@servicetitan/culture';\n\nfunction ordinalString(num: number): string {\n switch (num % 100) {\n case 11:\n case 12:\n case 13:\n return num.toString() + 'th';\n default:\n switch (num % 10) {\n case 1:\n return num.toString() + 'st';\n case 2:\n return num.toString() + 'nd';\n case 3:\n return num.toString() + 'rd';\n default:\n return num.toString() + 'th';\n }\n }\n}\n\n@injectable()\nexport class DateTimeUtils {\n private locale: string;\n private dateFormatter: Intl.DateTimeFormat;\n private dateFullFormatter: Intl.DateTimeFormat;\n private shortTimeFormatter: Intl.DateTimeFormat;\n private fullTimeFormatter: Intl.DateTimeFormat;\n private shortWeekdayFormatter: Intl.DateTimeFormat;\n private shortMonthFormatter: Intl.DateTimeFormat;\n private shortMonthDateFormatter: Intl.DateTimeFormat;\n private fullMonthFormatter: Intl.DateTimeFormat;\n private fullMonthDateFormatter: Intl.DateTimeFormat;\n private short24HourTimeFormatter: Intl.DateTimeFormat;\n private medium24HourTimeFormatter: Intl.DateTimeFormat;\n\n constructor(@inject(CULTURE_TOKEN) culture: Culture) {\n this.locale = culture.Name;\n\n this.dateFormatter = new Intl.DateTimeFormat(this.locale, {\n day: 'numeric',\n month: 'numeric',\n year: '2-digit',\n });\n this.dateFullFormatter = new Intl.DateTimeFormat(this.locale, {\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n });\n this.shortTimeFormatter = new Intl.DateTimeFormat(this.locale, {\n hour: 'numeric',\n minute: '2-digit',\n });\n this.fullTimeFormatter = new Intl.DateTimeFormat(this.locale, {\n hour: '2-digit',\n minute: '2-digit',\n });\n this.short24HourTimeFormatter = new Intl.DateTimeFormat(this.locale, {\n hour: '2-digit',\n minute: '2-digit',\n hourCycle: 'h23',\n } as Intl.DateTimeFormatOptions);\n this.medium24HourTimeFormatter = new Intl.DateTimeFormat(this.locale, {\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hourCycle: 'h23',\n } as Intl.DateTimeFormatOptions);\n this.shortWeekdayFormatter = new Intl.DateTimeFormat(this.locale, { weekday: 'short' });\n this.shortMonthFormatter = new Intl.DateTimeFormat(this.locale, { month: 'short' });\n this.shortMonthDateFormatter = new Intl.DateTimeFormat(this.locale, {\n month: 'short',\n day: 'numeric',\n });\n this.fullMonthFormatter = new Intl.DateTimeFormat(this.locale, { month: 'long' });\n this.fullMonthDateFormatter = new Intl.DateTimeFormat(this.locale, {\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n });\n }\n\n /**\n * General date formatting.\n *\n * @example\n * format(date, {\n * weekday: 'long',\n * month: 'long',\n * day: 'numeric'\n * }); // Tuesday, December 3\n */\n format = (date: Date, options?: Intl.DateTimeFormatOptions): string => {\n return date.toLocaleDateString(this.locale, options);\n };\n\n /**\n * Equals moment format: 'M/D/YY'\n * Returns: 1/2/20\n */\n formatDate = (date: Date): string => {\n return this.dateFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MMM DY'\n * Returns: Dec 2\n */\n formatDateShort = (date: Date): string => {\n return this.shortMonthDateFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MM/DD/YYYY', 'MM/DD/Y', with US locale - 'L'\n * Returns: 01/02/2020\n */\n formatDateFull = (date: Date): string => {\n return this.dateFullFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MM/DD/YYYY hh:mm A', with US locale - 'L LT'\n * Returns: 01/02/2020 03:47 AM\n */\n formatDateTimeFull = (date: Date): string => {\n return `${this.formatDateFull(date)} ${this.formatFullTime(date)}`;\n };\n\n /**\n * Equals moment format: 'M/D/YY hh:mm A', with US locale - 'L LT'\n * Returns: 1/2/20 3:47 AM\n */\n formatDateTimeShort = (date: Date): string => {\n return `${this.formatDate(date)} ${this.formatShortTime(date)}`;\n };\n\n /**\n * Equals moment format: 'MMM D, hh:mm A', with US locale - 'L LT'\n * Returns: Dec 2 3:47 AM\n */\n formatDateTimeShortest = (date: Date): string => {\n return `${this.formatDateShort(date)} ${this.formatShortTime(date)}`;\n };\n\n /**\n * Equals moment format: 'h:mm A', with US locale - 'LT'\n * Returns: 3:00 PM\n */\n formatShortTime = (date: Date): string => {\n return this.shortTimeFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'hh:mm A'\n * Returns: 03:00 PM\n */\n formatFullTime = (date: Date): string => {\n return this.fullTimeFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'hh:mm'\n * Returns: 15:00\n */\n formatShort24HourTime = (date: Date): string => {\n return this.short24HourTimeFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'hh:mm:ss'\n * Returns: 15:00:00\n */\n formatMedium24HourTime = (date: Date): string => {\n return this.medium24HourTimeFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'ddd'\n * Returns: Thu\n */\n formatShortWeekday = (date: Date): string => {\n return this.shortWeekdayFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MMM'\n * Returns: Jan\n */\n formatShortMonth = (date: Date): string => {\n return this.shortMonthFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MMMM'\n * Returns: January\n */\n formatFullMonth = (date: Date): string => {\n return this.fullMonthFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MMMM D, YYYY', with US locale - 'LL'\n * Returns: January 2, 2020\n */\n formatFullMonthDate = (date: Date): string => {\n return this.fullMonthDateFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MMM Do, YYYY'\n * Returns: Jan 2nd, 2020\n */\n formatShortMonthOrdinalDate = (date: Date): string => {\n const ordinalDate = ordinalString(date.getDate());\n return `${this.formatShortMonth(date)} ${ordinalDate}, ${date.getFullYear()}`;\n };\n\n /**\n * Equals moment format: 'MMM D YYYY'\n * Returns: Jan 2 2020\n */\n formatShortMonthDate = (date: Date): string => {\n return `${this.formatShortMonth(date)} ${date.getDate()} ${date.getFullYear()}`;\n };\n\n getLocale = (): string => {\n return this.locale;\n };\n}\n"],"names":["injectable","inject","CULTURE_TOKEN","Culture","ordinalString","num","toString","DateTimeUtils","constructor","culture","locale","dateFormatter","dateFullFormatter","shortTimeFormatter","fullTimeFormatter","shortWeekdayFormatter","shortMonthFormatter","shortMonthDateFormatter","fullMonthFormatter","fullMonthDateFormatter","short24HourTimeFormatter","medium24HourTimeFormatter","format","date","options","toLocaleDateString","formatDate","formatDateShort","formatDateFull","formatDateTimeFull","formatFullTime","formatDateTimeShort","formatShortTime","formatDateTimeShortest","formatShort24HourTime","formatMedium24HourTime","formatShortWeekday","formatShortMonth","formatFullMonth","formatFullMonthDate","formatShortMonthOrdinalDate","ordinalDate","getDate","getFullYear","formatShortMonthDate","getLocale","Name","Intl","DateTimeFormat","day","month","year","hour","minute","hourCycle","second","weekday"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,UAAU,EAAEC,MAAM,QAAQ,0BAA0B;AAC7D,SAASC,aAAa,EAAEC,OAAO,QAAQ,wBAAwB;AAE/D,SAASC,cAAcC,GAAW;IAC9B,OAAQA,MAAM;QACV,KAAK;QACL,KAAK;QACL,KAAK;YACD,OAAOA,IAAIC,QAAQ,KAAK;QAC5B;YACI,OAAQD,MAAM;gBACV,KAAK;oBACD,OAAOA,IAAIC,QAAQ,KAAK;gBAC5B,KAAK;oBACD,OAAOD,IAAIC,QAAQ,KAAK;gBAC5B,KAAK;oBACD,OAAOD,IAAIC,QAAQ,KAAK;gBAC5B;oBACI,OAAOD,IAAIC,QAAQ,KAAK;YAChC;IACR;AACJ;AA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AO;QAAO;QAC/E,IAAI,CAAC/B,sBAAsB,GAAG,IAAI4B,KAAKC,cAAc,CAAC,IAAI,CAACtC,MAAM,EAAE;YAC/DwC,OAAO;YACPD,KAAK;YACLE,MAAM;QACV;IACJ;AAoJJ"}
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import { injectable, inject } from '@servicetitan/react-ioc';\nimport type { Culture } from '@servicetitan/culture';\nimport { CULTURE_TOKEN } from '@servicetitan/culture';\n\nfunction ordinalString(num: number): string {\n switch (num % 100) {\n case 11:\n case 12:\n case 13:\n return num.toString() + 'th';\n default:\n switch (num % 10) {\n case 1:\n return num.toString() + 'st';\n case 2:\n return num.toString() + 'nd';\n case 3:\n return num.toString() + 'rd';\n default:\n return num.toString() + 'th';\n }\n }\n}\n\n@injectable()\nexport class DateTimeUtils {\n private locale: string;\n private dateFormatter: Intl.DateTimeFormat;\n private dateFullFormatter: Intl.DateTimeFormat;\n private shortTimeFormatter: Intl.DateTimeFormat;\n private fullTimeFormatter: Intl.DateTimeFormat;\n private shortWeekdayFormatter: Intl.DateTimeFormat;\n private shortMonthFormatter: Intl.DateTimeFormat;\n private shortMonthDateFormatter: Intl.DateTimeFormat;\n private fullMonthFormatter: Intl.DateTimeFormat;\n private fullMonthDateFormatter: Intl.DateTimeFormat;\n private short24HourTimeFormatter: Intl.DateTimeFormat;\n private medium24HourTimeFormatter: Intl.DateTimeFormat;\n\n constructor(@inject(CULTURE_TOKEN) culture: Culture) {\n this.locale = culture.Name;\n\n this.dateFormatter = new Intl.DateTimeFormat(this.locale, {\n day: 'numeric',\n month: 'numeric',\n year: '2-digit',\n });\n this.dateFullFormatter = new Intl.DateTimeFormat(this.locale, {\n day: '2-digit',\n month: '2-digit',\n year: 'numeric',\n });\n this.shortTimeFormatter = new Intl.DateTimeFormat(this.locale, {\n hour: 'numeric',\n minute: '2-digit',\n });\n this.fullTimeFormatter = new Intl.DateTimeFormat(this.locale, {\n hour: '2-digit',\n minute: '2-digit',\n });\n this.short24HourTimeFormatter = new Intl.DateTimeFormat(this.locale, {\n hour: '2-digit',\n minute: '2-digit',\n hourCycle: 'h23',\n } as Intl.DateTimeFormatOptions);\n this.medium24HourTimeFormatter = new Intl.DateTimeFormat(this.locale, {\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hourCycle: 'h23',\n } as Intl.DateTimeFormatOptions);\n this.shortWeekdayFormatter = new Intl.DateTimeFormat(this.locale, { weekday: 'short' });\n this.shortMonthFormatter = new Intl.DateTimeFormat(this.locale, { month: 'short' });\n this.shortMonthDateFormatter = new Intl.DateTimeFormat(this.locale, {\n month: 'short',\n day: 'numeric',\n });\n this.fullMonthFormatter = new Intl.DateTimeFormat(this.locale, { month: 'long' });\n this.fullMonthDateFormatter = new Intl.DateTimeFormat(this.locale, {\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n });\n }\n\n /**\n * General date formatting.\n *\n * @example\n * format(date, {\n * weekday: 'long',\n * month: 'long',\n * day: 'numeric'\n * }); // Tuesday, December 3\n */\n format = (date: Date, options?: Intl.DateTimeFormatOptions): string => {\n return date.toLocaleDateString(this.locale, options);\n };\n\n /**\n * Equals moment format: 'M/D/YY'\n * Returns: 1/2/20\n */\n formatDate = (date: Date): string => {\n return this.dateFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MMM DY'\n * Returns: Dec 2\n */\n formatDateShort = (date: Date): string => {\n return this.shortMonthDateFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MM/DD/YYYY', 'MM/DD/Y', with US locale - 'L'\n * Returns: 01/02/2020\n */\n formatDateFull = (date: Date): string => {\n return this.dateFullFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MM/DD/YYYY hh:mm A', with US locale - 'L LT'\n * Returns: 01/02/2020 03:47 AM\n */\n formatDateTimeFull = (date: Date): string => {\n return `${this.formatDateFull(date)} ${this.formatFullTime(date)}`;\n };\n\n /**\n * Equals moment format: 'M/D/YY hh:mm A', with US locale - 'L LT'\n * Returns: 1/2/20 3:47 AM\n */\n formatDateTimeShort = (date: Date): string => {\n return `${this.formatDate(date)} ${this.formatShortTime(date)}`;\n };\n\n /**\n * Equals moment format: 'MMM D, hh:mm A', with US locale - 'L LT'\n * Returns: Dec 2 3:47 AM\n */\n formatDateTimeShortest = (date: Date): string => {\n return `${this.formatDateShort(date)} ${this.formatShortTime(date)}`;\n };\n\n /**\n * Equals moment format: 'h:mm A', with US locale - 'LT'\n * Returns: 3:00 PM\n */\n formatShortTime = (date: Date): string => {\n return this.shortTimeFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'hh:mm A'\n * Returns: 03:00 PM\n */\n formatFullTime = (date: Date): string => {\n return this.fullTimeFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'hh:mm'\n * Returns: 15:00\n */\n formatShort24HourTime = (date: Date): string => {\n return this.short24HourTimeFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'hh:mm:ss'\n * Returns: 15:00:00\n */\n formatMedium24HourTime = (date: Date): string => {\n return this.medium24HourTimeFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'ddd'\n * Returns: Thu\n */\n formatShortWeekday = (date: Date): string => {\n return this.shortWeekdayFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MMM'\n * Returns: Jan\n */\n formatShortMonth = (date: Date): string => {\n return this.shortMonthFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MMMM'\n * Returns: January\n */\n formatFullMonth = (date: Date): string => {\n return this.fullMonthFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MMMM D, YYYY', with US locale - 'LL'\n * Returns: January 2, 2020\n */\n formatFullMonthDate = (date: Date): string => {\n return this.fullMonthDateFormatter.format(date);\n };\n\n /**\n * Equals moment format: 'MMM Do, YYYY'\n * Returns: Jan 2nd, 2020\n */\n formatShortMonthOrdinalDate = (date: Date): string => {\n const ordinalDate = ordinalString(date.getDate());\n return `${this.formatShortMonth(date)} ${ordinalDate}, ${date.getFullYear()}`;\n };\n\n /**\n * Equals moment format: 'MMM D YYYY'\n * Returns: Jan 2 2020\n */\n formatShortMonthDate = (date: Date): string => {\n return `${this.formatShortMonth(date)} ${date.getDate()} ${date.getFullYear()}`;\n };\n\n getLocale = (): string => {\n return this.locale;\n };\n}\n"],"names":["injectable","inject","CULTURE_TOKEN","ordinalString","num","toString","DateTimeUtils","culture","locale","dateFormatter","dateFullFormatter","shortTimeFormatter","fullTimeFormatter","shortWeekdayFormatter","shortMonthFormatter","shortMonthDateFormatter","fullMonthFormatter","fullMonthDateFormatter","short24HourTimeFormatter","medium24HourTimeFormatter","format","date","options","toLocaleDateString","formatDate","formatDateShort","formatDateFull","formatDateTimeFull","formatFullTime","formatDateTimeShort","formatShortTime","formatDateTimeShortest","formatShort24HourTime","formatMedium24HourTime","formatShortWeekday","formatShortMonth","formatFullMonth","formatFullMonthDate","formatShortMonthOrdinalDate","ordinalDate","getDate","getFullYear","formatShortMonthDate","getLocale","Name","Intl","DateTimeFormat","day","month","year","hour","minute","hourCycle","second","weekday"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,UAAU,EAAEC,MAAM,QAAQ,0BAA0B;AAE7D,SAASC,aAAa,QAAQ,wBAAwB;AAEtD,SAASC,cAAcC,GAAW;IAC9B,OAAQA,MAAM;QACV,KAAK;QACL,KAAK;QACL,KAAK;YACD,OAAOA,IAAIC,QAAQ,KAAK;QAC5B;YACI,OAAQD,MAAM;gBACV,KAAK;oBACD,OAAOA,IAAIC,QAAQ,KAAK;gBAC5B,KAAK;oBACD,OAAOD,IAAIC,QAAQ,KAAK;gBAC5B,KAAK;oBACD,OAAOD,IAAIC,QAAQ,KAAK;gBAC5B;oBACI,OAAOD,IAAIC,QAAQ,KAAK;YAChC;IACR;AACJ;AAGA,OAAO,MAAMC;IAcT,YAAY,AAAuBC,OAAgB,CAAE;QAbrD,uBAAQC,UAAR,KAAA;QACA,uBAAQC,iBAAR,KAAA;QACA,uBAAQC,qBAAR,KAAA;QACA,uBAAQC,sBAAR,KAA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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/datetime-utils",
3
- "version": "32.3.0",
3
+ "version": "32.4.1",
4
4
  "description": "",
5
5
  "homepage": "https://docs.st.dev/docs/frontend/date-time-formatting",
6
6
  "repository": {
@@ -16,11 +16,11 @@
16
16
  "src"
17
17
  ],
18
18
  "devDependencies": {
19
- "@servicetitan/culture": "^32.3.0",
20
- "@servicetitan/react-ioc": "^31.3.2"
19
+ "@servicetitan/culture": "^32.4.1",
20
+ "@servicetitan/react-ioc": "^31.6.0"
21
21
  },
22
22
  "peerDependencies": {
23
- "@servicetitan/culture": "^32.3.0",
23
+ "@servicetitan/culture": "^32.4.1",
24
24
  "@servicetitan/react-ioc": ">21.0.0"
25
25
  },
26
26
  "publishConfig": {
@@ -29,5 +29,5 @@
29
29
  "cli": {
30
30
  "webpack": false
31
31
  },
32
- "gitHead": "948549f6eedb039a353ac4fc3ec1b90eee4d0321"
32
+ "gitHead": "5bc4f3c9c8a181df124fdc614964757e5490ea9b"
33
33
  }
@@ -1,5 +1,6 @@
1
1
  import { Container } from '@servicetitan/react-ioc';
2
- import { CULTURE_TOKEN, Culture } from '@servicetitan/culture';
2
+ import type { Culture } from '@servicetitan/culture';
3
+ import { CULTURE_TOKEN } from '@servicetitan/culture';
3
4
 
4
5
  import { DateTimeUtils } from '..';
5
6
 
package/src/index.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { injectable, inject } from '@servicetitan/react-ioc';
2
- import { CULTURE_TOKEN, Culture } from '@servicetitan/culture';
2
+ import type { Culture } from '@servicetitan/culture';
3
+ import { CULTURE_TOKEN } from '@servicetitan/culture';
3
4
 
4
5
  function ordinalString(num: number): string {
5
6
  switch (num % 100) {