Skip to content

Commit

Permalink
fix vod timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
KentoNishi committed Jul 3, 2024
1 parent 69c4841 commit 5f33994
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/ts/chat-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ const formatTimestamp = (timestampUsec: number): string => {
.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: false });
};

const convert12hTo24h = (timestamp: string): string => {
const parts = timestamp.split(' ');
const time = parts[0];
const ampm = parts[1];
const [hour, minute] = time.split(':').map(Number);
const isPM = ampm === 'PM';
const newHour = (hour % 12) + (isPM ? 12 : 0);
return `${newHour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
};
// const convert12hTo24h = (timestamp: string): string => {
// const parts = timestamp.split(' ');
// const time = parts[0];
// const ampm = parts[1];
// const [hour, minute] = time.split(':').map(Number);
// const isPM = ampm === 'PM';
// const newHour = (hour % 12) + (isPM ? 12 : 0);
// return `${newHour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
// };

const colorToHex = (color: number): string => color.toString(16).slice(-6);

Expand Down Expand Up @@ -126,7 +126,7 @@ const parseAddChatItemAction = (action: Ytc.AddChatItemAction, isReplay = false,
profileIcon
},
message: runs,
timestamp: isReplay && timestampText != null ? convert12hTo24h(timestampText) : formatTimestamp(timestampUsec),
timestamp: isReplay && timestampText != null ? timestampText : formatTimestamp(timestampUsec),
showtime: isReplay ? liveTimeoutOrReplayMs : liveShowtimeMs,
messageId: renderer.id,
params: messageRenderer.contextMenuEndpoint?.liveChatItemContextMenuEndpoint.params
Expand Down

0 comments on commit 5f33994

Please sign in to comment.