@castlabs/ui 7.13.0 → 7.14.0

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.
@@ -25,6 +25,7 @@ declare module '@castlabs/ui/dist/castlabs-ui.module.js' {
25
25
  export function clFormatDate (date: Date): string
26
26
  export function clFormatTimeUTC (date: Date): string
27
27
  export function clFormatDateTimeUTC (date: Date, seconds?: boolean): string
28
+ export function clFormatDateTimeTabularUTC (date: Date, year?:boolean, month?:boolean, day?:boolean, time?:boolean, seconds?:boolean): string
28
29
  export function clFormatDuration (from: Date, until: Date, seconds?: boolean, ms?: boolean): string
29
30
  export function clFormatPeriod (date: Date): string
30
31
  export function clFormatNumber (amount: number, decimalPlaces?: number): string
@@ -1,4 +1,4 @@
1
- /* @castlabs/ui v7.13.0 */
1
+ /* @castlabs/ui v7.14.0 */
2
2
 
3
3
  /*!
4
4
  * Bootstrap v5.3.8 (https://getbootstrap.com/)
@@ -174,20 +174,20 @@ function clCookieBannerShow (accept = clCookieBannerAccept, decline = clCookieBa
174
174
  >privacy policy</a>.
175
175
  </p>
176
176
 
177
- <div class="cl-spacing-box text-center">
177
+ <div class="cl-spacing-box cl-spread">
178
178
  <button
179
- id="cl-button-cookie-accept"
179
+ id="cl-button-cookie-decline"
180
180
  type="button"
181
- class="btn btn-sm cl-color-red it-ok"
181
+ class="btn btn-sm cl-color-night it-cancel"
182
182
  >
183
- Accept
183
+ Decline
184
184
  </button>
185
185
  <button
186
- id="cl-button-cookie-decline"
186
+ id="cl-button-cookie-accept"
187
187
  type="button"
188
- class="btn btn-sm cl-color-night it-cancel"
188
+ class="btn btn-sm cl-color-red it-ok"
189
189
  >
190
- Decline
190
+ Accept
191
191
  </button>
192
192
  </div>
193
193
  </div>
@@ -1187,6 +1187,45 @@ export function clFormatDateTimeUTC (date, seconds = false) {
1187
1187
  return `${clFormatDate(date)} ${clFormatTimeUTC(date, seconds)}`
1188
1188
  }
1189
1189
 
1190
+ /**
1191
+ * Format a date and time into a sortable string.
1192
+ *
1193
+ * @param {Date} date Date to format.
1194
+ * @param {boolean} year If true (default), the output will contain a year.
1195
+ * @param {boolean} month If true (default), the output will contain a year.
1196
+ * @param {boolean} day If true (default), the output will contain a year.
1197
+ * @param {boolean} hour If true (default), the output will contain hour.
1198
+ * @param {boolean} minute If true (default), the output will contain hours and minutes.
1199
+ * @param {boolean} seconds If true (default false), the output will contain seconds.
1200
+ * @return {string} Formatted date, e.g. '2021-08-01 18:21'.
1201
+ */
1202
+ export function clFormatDateTimeTabularUTC (
1203
+ date,
1204
+ year = true,
1205
+ month = true,
1206
+ day = true,
1207
+ time = true,
1208
+ seconds = false
1209
+ ) {
1210
+ const YYYY = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(date)
1211
+ const MM = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(date)
1212
+ const DD = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(date)
1213
+ const [hh, mm, ss] = [
1214
+ ('' + date.getUTCHours()).padStart(2, '0'),
1215
+ ('' + date.getUTCMinutes()).padStart(2, '0'),
1216
+ ('' + date.getUTCSeconds()).padStart(2, '0')
1217
+ ]
1218
+
1219
+ let result = ''
1220
+ if (year) result += ` ${YYYY}`
1221
+ if (month) result += `-${MM}`
1222
+ if (day) result += `-${DD}`
1223
+ if (time) result += ` ${hh}:${mm}`
1224
+ if (seconds) result += `:${ss}`
1225
+
1226
+ return result.trim()
1227
+ }
1228
+
1190
1229
  /**
1191
1230
  * Format the duration between two dates. Format can adapt on scale of duraction (years/weeks, milliseconds, ...)
1192
1231
  *