Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cp-webapp/src/components/snapshot-view/commits-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Commit } from '@/generated/runner/types.gen';
import { GitCommit } from 'lucide-react';
import React, { useEffect, useState } from 'react';
import { useSnapshotContext } from './context';
import { convertToISO8601 } from '@/lib/utils';

interface CommitsListProps {
commits: Commit[];
Expand Down Expand Up @@ -156,7 +157,7 @@ export const CommitsList: React.FC<CommitsListProps> = ({
</div>
<div className="line-clamp-2 break-words text-sm">{commit.message}</div>
<div className="text-xs text-gray-500 dark:text-gray-400">
{new Date(commit.date).toLocaleString(undefined, {
{new Date(convertToISO8601(commit.date)).toLocaleString(undefined, {
year: 'numeric',
month: 'numeric',
day: 'numeric',
Expand Down
18 changes: 18 additions & 0 deletions cp-webapp/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,21 @@ export function getProxiedImageUrl(url: string) {
// Using Cloudflare's proxy service
return `https://images.1choice.ai?url=${encodeURIComponent(url)}`;
}

export function convertToISO8601(dateString: string): string {
// Check if the input string matches the expected format
const regex = /^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) ([+-]\d{4})$/;
const match = dateString.match(regex);

if (!match) {
throw new Error('Invalid date format. Expected format: YYYY-MM-DD HH:MM:SS ±HHMM');
}

const [, datePart, timePart, timezonePart] = match;

// Insert 'T' between date and time
// Format timezone offset by inserting a colon (e.g., -0800 -> -08:00)
const formattedTimezone = `${timezonePart.slice(0, 3)}:${timezonePart.slice(3)}`;

return `${datePart}T${timePart}${formattedTimezone}`;
}
Loading