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

CBIIT / crdc-datahub-ui / 11955374340

21 Nov 2024 02:32PM UTC coverage: 55.678% (+0.8%) from 54.88%
11955374340

Pull #538

github

web-flow
Merge e1beac3f8 into 85b9e32a0
Pull Request #538: Misc Optimizations

2631 of 5208 branches covered (50.52%)

Branch coverage included in aggregate %.

13 of 20 new or added lines in 4 files covered. (65.0%)

38 existing lines in 3 files now uncovered.

3787 of 6319 relevant lines covered (59.93%)

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

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

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