@open-tender/utils 0.5.9 → 0.5.10

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.
@@ -51,7 +51,7 @@ export declare const isoToDateStrMinutes: (iso: ISOString, tz: Timezone) => {
51
51
  date: `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
52
52
  minutes: number;
53
53
  };
54
- export declare const makeReadableDateStrFromIso: (iso: string, tz: Timezone, verbose?: boolean) => string;
54
+ export declare const makeReadableDateStrFromIso: (iso: string, tz: Timezone, verbose?: boolean, withTime?: boolean) => string;
55
55
  export declare const makeRequestedIso: (requestedAt: string) => string;
56
56
  export declare const makeRequestedAtStr: (requestedAt: string | null, tz: Timezone, verbose?: boolean) => string;
57
57
  export declare const makeEstimatedTime: (requestedAt: ISOString | string, revenueCenter: RevenueCenter, serviceType: ServiceType, verbose?: boolean) => string | null;
@@ -212,20 +212,22 @@ const isoToDateStrMinutes = (iso, tz) => {
212
212
  return { date, minutes };
213
213
  };
214
214
  exports.isoToDateStrMinutes = isoToDateStrMinutes;
215
- const makeReadableDateStrFromIso = (iso, tz, verbose = false) => {
215
+ const makeReadableDateStrFromIso = (iso, tz, verbose = false, withTime = true) => {
216
216
  if (!iso || iso.toLowerCase() === 'asap')
217
217
  return 'ASAP';
218
218
  const date = (0, date_fns_tz_1.utcToZonedTime)((0, date_fns_1.parseISO)(iso), tz);
219
219
  const timeString = (0, date_fns_tz_1.format)(date, exports.TIME).toLowerCase();
220
220
  const dateString = (0, exports.makeLocalDateStr)(date);
221
221
  if (dateString === (0, exports.todayDate)()) {
222
+ if (!withTime)
223
+ return 'Today';
222
224
  return verbose ? `Today @ ${timeString}` : timeString;
223
225
  }
224
226
  else if (dateString === (0, exports.tomorrowDate)()) {
225
- return `${verbose ? 'Tomorrow' : 'Tmrw'} @ ${timeString}`;
227
+ return `${verbose ? 'Tomorrow' : 'Tmrw'} ${withTime && `@ ${timeString}`}`;
226
228
  }
227
229
  else {
228
- return `${verbose ? (0, date_fns_tz_1.format)(date, 'EEE, MMM d') : (0, date_fns_tz_1.format)(date, 'M/d')} @ ${timeString}`;
230
+ return `${verbose ? (0, date_fns_tz_1.format)(date, 'EEE, MMM d') : (0, date_fns_tz_1.format)(date, 'M/d')} ${withTime && `@ ${timeString}`}`;
229
231
  }
230
232
  };
231
233
  exports.makeReadableDateStrFromIso = makeReadableDateStrFromIso;
@@ -51,7 +51,7 @@ export declare const isoToDateStrMinutes: (iso: ISOString, tz: Timezone) => {
51
51
  date: `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
52
52
  minutes: number;
53
53
  };
54
- export declare const makeReadableDateStrFromIso: (iso: string, tz: Timezone, verbose?: boolean) => string;
54
+ export declare const makeReadableDateStrFromIso: (iso: string, tz: Timezone, verbose?: boolean, withTime?: boolean) => string;
55
55
  export declare const makeRequestedIso: (requestedAt: string) => string;
56
56
  export declare const makeRequestedAtStr: (requestedAt: string | null, tz: Timezone, verbose?: boolean) => string;
57
57
  export declare const makeEstimatedTime: (requestedAt: ISOString | string, revenueCenter: RevenueCenter, serviceType: ServiceType, verbose?: boolean) => string | null;
@@ -173,20 +173,22 @@ export const isoToDateStrMinutes = (iso, tz) => {
173
173
  const date = format(dateObj, DATE);
174
174
  return { date, minutes };
175
175
  };
176
- export const makeReadableDateStrFromIso = (iso, tz, verbose = false) => {
176
+ export const makeReadableDateStrFromIso = (iso, tz, verbose = false, withTime = true) => {
177
177
  if (!iso || iso.toLowerCase() === 'asap')
178
178
  return 'ASAP';
179
179
  const date = utcToZonedTime(parseISO(iso), tz);
180
180
  const timeString = format(date, TIME).toLowerCase();
181
181
  const dateString = makeLocalDateStr(date);
182
182
  if (dateString === todayDate()) {
183
+ if (!withTime)
184
+ return 'Today';
183
185
  return verbose ? `Today @ ${timeString}` : timeString;
184
186
  }
185
187
  else if (dateString === tomorrowDate()) {
186
- return `${verbose ? 'Tomorrow' : 'Tmrw'} @ ${timeString}`;
188
+ return `${verbose ? 'Tomorrow' : 'Tmrw'} ${withTime && `@ ${timeString}`}`;
187
189
  }
188
190
  else {
189
- return `${verbose ? format(date, 'EEE, MMM d') : format(date, 'M/d')} @ ${timeString}`;
191
+ return `${verbose ? format(date, 'EEE, MMM d') : format(date, 'M/d')} ${withTime && `@ ${timeString}`}`;
190
192
  }
191
193
  };
192
194
  export const makeRequestedIso = (requestedAt) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/utils",
3
- "version": "0.5.9",
3
+ "version": "0.5.10",
4
4
  "description": "A library of utils for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",