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

sangupta / bedrock / 4360887097

08 Mar 2023 03:34AM UTC coverage: 80.687% (+14.5%) from 66.224%
4360887097

push

github

Sandeep Gupta
export all prop interfaces

121 of 129 branches covered (93.8%)

Branch coverage included in aggregate %.

5185 of 6447 relevant lines covered (80.43%)

1.36 hits per line

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

54.9
/src/components/content/DateTime.tsx
1
/**
1✔
2
 * bedrock - UI Component Library
1✔
3
 * https://github.com/sangupta/bedrock
1✔
4
 *
1✔
5
 * MIT License.
1✔
6
 * Copyright (c) 2022, Sandeep Gupta.
1✔
7
 *
1✔
8
 * Use of this source code is governed by a MIT style license
1✔
9
 * that can be found in LICENSE file in the code repository.
1✔
10
 */
1✔
11

1✔
12
import React from 'react';
1✔
13
import { asDate, asDateTime, asTime } from '../../Utils';
1✔
14
import { DateTimeFormatType, ValueType } from '../data/Data';
1✔
15

1✔
16
export interface DateTimeProps {
1✔
17
    value: number;
1✔
18
    valueType?: ValueType;
1✔
19
    type: DateTimeFormatType;
1✔
20
}
1✔
21

1✔
22
export default class DateTime extends React.Component<DateTimeProps> {
1✔
23

1✔
24
    formatValue(type: DateTimeFormatType, value: number): string | number {
1✔
25
        switch (type) {
×
26
            case 'date-time':
×
27
                return asDateTime(value);
×
28

×
29
            case 'date':
×
30
                return asDate(value);
×
31

×
32
            case 'time':
×
33
                return asTime(value);
×
34

×
35
            default:
×
36
                return value;
×
37
        }
×
38
    }
×
39

1✔
40
    render(): React.ReactNode {
1✔
41
        const { value, valueType, type } = this.props;
×
42
        if(value === undefined || value === null || value < 0) {
×
43
            return "";
×
44
        }
×
45

×
46
        const millis = valueType === 'seconds' ? value * 1000 : value;
×
47
        const formattedValue = this.formatValue(type, millis);
×
48
        return <span className='format-date-time' title={'' + formattedValue}>{formattedValue}</span>
×
49
    }
×
50

1✔
51
}
1✔
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

© 2025 Coveralls, Inc