• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CBIIT / crdc-datahub-ui / 12184841426

05 Dec 2024 05:23PM UTC coverage: 56.473% (+1.0%) from 55.452%
12184841426

Pull #538

github

web-flow
Merge a4707dc0e into d1264f14e
Pull Request #538: Miscellaneous Performance and QoL Improvements

2664 of 5191 branches covered (51.32%)

Branch coverage included in aggregate %.

36 of 50 new or added lines in 6 files covered. (72.0%)

14 existing lines in 2 files now uncovered.

3818 of 6287 relevant lines covered (60.73%)

143.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/utils/dateUtils.ts
1
import dayjs from "dayjs";
2
import utc from "dayjs/plugin/utc";
3
import timezone from "dayjs/plugin/timezone";
4

5
dayjs.extend(utc);
118✔
6
dayjs.extend(timezone);
118✔
7

8
/**
9
 * Format a date string to a specified pattern
10
 *
11
 * @param date input date string
12
 * @param pattern output date pattern
13
 * @param fallbackValue value to return if date is invalid or fails to format
14
 * @param offsetTimezone whether to offset UTC to the user's timezone
15
 * @returns formatted date or fallbackValue if invalid
16
 */
17
export const FormatDate = (
118✔
18
  date: string,
19
  pattern = "M/D/YYYY",
×
20
  fallbackValue = null,
101✔
21
  offsetTimezone = true
498✔
22
): string => {
23
  const dateObj = offsetTimezone ? dayjs(date) : dayjs.utc(date);
996!
24

25
  if (!dateObj?.isValid()) {
996✔
26
    return fallbackValue;
306✔
27
  }
28

29
  try {
690✔
30
    return dateObj?.format(pattern);
690✔
31
  } catch (e) {
UNCOV
32
    return fallbackValue;
×
33
  }
34
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc