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

CBIIT / crdc-datahub-ui / 11936654675

20 Nov 2024 03:36PM UTC coverage: 54.194% (+0.4%) from 53.816%
11936654675

Pull #538

github

web-flow
Merge c22c3f883 into 468753eff
Pull Request #538: Misc Optimizations

2571 of 5232 branches covered (49.14%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

50 existing lines in 3 files now uncovered.

3690 of 6321 relevant lines covered (58.38%)

136.54 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);
102✔
6
dayjs.extend(timezone);
102✔
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 = (
102✔
18
  date: string,
19
  pattern = "M/D/YYYY",
×
20
  fallbackValue = null,
81✔
21
  offsetTimezone = true
477✔
22
): string => {
23
  const dateObj = offsetTimezone ? dayjs(date) : dayjs.utc(date);
954!
24

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

29
  try {
648✔
30
    return dateObj?.format(pattern);
648✔
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