4 Commits

5 changed files with 20 additions and 6 deletions

3
.gitignore vendored
View File

@@ -40,7 +40,8 @@ build/
### Generated Files ###
/videos
outputs/
/outputs
frontend/.flowbite-react
generated
.mvn

View File

@@ -3,6 +3,7 @@ import { Eye, EyeOff, Copy, Check } from "lucide-react";
import Box from "../components/Box.tsx";
import { getUser } from "../utils/endpoints.ts";
import type { User } from "../utils/types.ts";
import { formatLocalDate } from "../utils/utils.ts";
const Profile = () => {
const [user, setUser] = useState<User | null>(null);
@@ -44,7 +45,7 @@ const Profile = () => {
<p className="text-sm text-gray-500">@{user.username}</p>
<p className="text-sm text-gray-500">{user.email}</p>
<p className="text-xs text-gray-400 mt-1">
Member since {new Date(user.createdAt).toLocaleDateString(undefined, { year: "numeric", month: "long", day: "numeric" })}
Member since {formatLocalDate(user.createdAt)}
</p>
</div>
</Box>

View File

@@ -7,12 +7,20 @@ function formatTime(seconds: number): string {
return `${m}:${pad(s)}`;
}
// Parses a UTC date string, appending Z if no timezone offset is present so
// the browser always interprets the value as UTC rather than local time.
function stringToDate(dateString: string): Date {
const date = new Date(dateString.substring(0, 23));
const normalized = dateString.replace(/(\.\d{3})\d+/, "$1");
const withTz = /[Zz]$|[+-]\d{2}:\d{2}$|[+-]\d{4}$/.test(normalized) ? normalized : `${normalized}Z`;
const date = new Date(withTz);
if (isNaN(date.getTime())) throw new Error("Invalid date string");
return date;
}
function formatLocalDate(dateString: string, options?: Intl.DateTimeFormatOptions): string {
return stringToDate(dateString).toLocaleDateString(undefined, options ?? { year: "numeric", month: "long", day: "numeric" });
}
function dateToTimeAgo(date: Date): string {
const secondsAgo = Math.floor((Date.now() - date.getTime()) / 1000);
const units: [number, string][] = [
@@ -32,4 +40,4 @@ function dateToTimeAgo(date: Date): string {
return `${s} second${s !== 1 ? 's' : ''} ago`;
}
export { formatTime, stringToDate, dateToTimeAgo };
export { formatTime, stringToDate, dateToTimeAgo, formatLocalDate };

View File

@@ -58,7 +58,7 @@ public class StreamController {
Optional<Stream> stream = streamService.getActiveStream();
return stream.map(value -> ResponseEntity.ok(new APIResponse<>(SUCCESS,
"Streaming status retrieved",
new StreamResponse(true, value.getId())))).orElseGet(() -> ResponseEntity.ok(new APIResponse<>("success",
new StreamResponse(true, value.getId())))).orElseGet(() -> ResponseEntity.ok(new APIResponse<>(SUCCESS,
"Streaming status retrieved",
new StreamResponse(false, null))));
}

View File

@@ -76,9 +76,13 @@ public class StreamActionsService {
progressTracker.markComplete();
return CompletableFuture.completedFuture(outputFile);
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
logger.error("Failed to save section to '{}'", outputFile, e);
return CompletableFuture.failedFuture(e);
} catch (InterruptedException e) {
logger.error("Failed to save section");
Thread.currentThread().interrupt();
return CompletableFuture.failedFuture(e);
}
}
}