Skip to content

Commit 25bc868

Browse files
authored
fix: evoting timezone issue (#322)
1 parent 9226fe0 commit 25bc868

File tree

1 file changed

+29
-2
lines changed
  • platforms/eVoting/src/app/(app)/create

1 file changed

+29
-2
lines changed

platforms/eVoting/src/app/(app)/create/page.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,39 @@ export default function CreatePoll() {
128128
const onSubmit = async (data: CreatePollForm) => {
129129
setIsSubmitting(true);
130130
try {
131+
// Convert local deadline to UTC before sending to backend
132+
let utcDeadline: string | undefined;
133+
if (data.deadline) {
134+
// Create a Date object from the local datetime-local input
135+
const localDate = new Date(data.deadline);
136+
// Convert to UTC ISO string
137+
utcDeadline = localDate.toISOString();
138+
139+
// Show user the timezone conversion for transparency
140+
const localTime = localDate.toLocaleString();
141+
const utcTime = new Date(utcDeadline).toLocaleString('en-US', { timeZone: 'UTC' });
142+
143+
console.log('🕐 Deadline conversion:', {
144+
local: data.deadline,
145+
localTime,
146+
utc: utcDeadline,
147+
utcTime
148+
});
149+
150+
toast({
151+
title: "Timezone Converted",
152+
description: `Local: ${localTime} → UTC: ${utcTime}`,
153+
duration: 3000,
154+
});
155+
}
156+
131157
await pollApi.createPoll({
132158
title: data.title,
133159
mode: data.mode,
134160
visibility: data.visibility,
135161
groupId: data.groupId,
136162
options: data.options.filter(option => option.trim() !== ""),
137-
deadline: data.deadline || undefined
163+
deadline: utcDeadline
138164
});
139165

140166
toast({
@@ -225,7 +251,8 @@ export default function CreatePoll() {
225251
required
226252
/>
227253
<p className="mt-1 text-sm text-gray-500">
228-
Set a deadline for when voting will end.
254+
Set a deadline for when voting will end.
255+
<span className="text-blue-600 font-medium"> Note: Times are automatically converted to UTC for accurate backend processing.</span>
229256
</p>
230257
{errors.deadline && (
231258
<p className="mt-1 text-sm text-red-600">

0 commit comments

Comments
 (0)