Skip to content

Commit

Permalink
fix: 🐛 fixed time issue and changed time graph to linear
Browse files Browse the repository at this point in the history
  • Loading branch information
WasiqB committed Oct 16, 2024
1 parent d358b2e commit a08d700
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
11 changes: 6 additions & 5 deletions components/charts/area-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,32 @@ export function AreaChartComponent({
<CardTitle className='text-xl'>{title}</CardTitle>
{description && <CardDescription>{description}</CardDescription>}
</CardHeader>
<CardContent className='flex-1 pb-0'>
<CardContent className='flex-1 pb-5'>
<ChartContainer config={config}>
<AreaChart
accessibilityLayer
data={data}
margin={{
left: 20,
right: 12,
left: 10,
right: 10,
}}
>
<CartesianGrid vertical={false} />
<CartesianGrid vertical={true} />
<XAxis
dataKey='property'
tickLine={false}
axisLine={false}
tickMargin={5}
tickFormatter={(value) => value.slice(0, 5)}
hide
/>
<ChartTooltip
cursor={false}
content={<ChartTooltipContent indicator='dot' />}
/>
<Area
dataKey='value'
type='natural'
type='linear'
fill='var(--color-property)'
fillOpacity={0.4}
stroke='var(--color-property)'
Expand Down
2 changes: 1 addition & 1 deletion components/data-table/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const getFormattedData = (data: TestResultData[]): FormattedData => {

const areaChartData: AreaChartData[] = data.map((r) => {
return {
property: r.method_name,
property: `${r.class_name} / ${r.method_name}`,
value: toDuration(r.duration_ms),
};
});
Expand Down
17 changes: 10 additions & 7 deletions lib/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,35 @@ export const formatDateTime = (
const systemZone = Intl.DateTimeFormat().resolvedOptions().timeZone;

const timezoneSplit = dateTimeString.split(' ');
let timezone = systemZone;
let adjustedDateTimeString = dateTimeString;

if (timezoneSplit.length > 1) {
timezone = timezoneSplit.pop() || systemZone;
timezoneSplit.pop();
adjustedDateTimeString = timezoneSplit.join(' ');
}

let dateTime = DateTime.fromISO(adjustedDateTimeString, { zone: timezone });
let dateTime = DateTime.fromISO(adjustedDateTimeString, {
zone: systemZone,
});

if (!dateTime.isValid) {
dateTime = DateTime.fromRFC2822(adjustedDateTimeString, {
zone: timezone,
zone: systemZone,
});
}

if (!dateTime.isValid) {
dateTime = DateTime.fromHTTP(adjustedDateTimeString, { zone: timezone });
dateTime = DateTime.fromHTTP(adjustedDateTimeString, {
zone: systemZone,
});
}

if (!dateTime.isValid) {
throw new Error('Invalid date-time format');
}

const formattedDate = dateTime.toUTC().toFormat('yyyy-MM-dd');
const formattedTime = dateTime.toUTC().toFormat('hh:mm:ss a');
const formattedDate = dateTime.toFormat('yyyy-MM-dd');
const formattedTime = dateTime.toFormat('hh:mm:ss a');

return { date: formattedDate, time: formattedTime };
} catch (error) {
Expand Down

0 comments on commit a08d700

Please sign in to comment.