Skip to content

Commit

Permalink
Avoid windows reserverd characters (#8)
Browse files Browse the repository at this point in the history
The approach with "toLocale" may include `:` or `/` in file names inside the zip file. Windows fails to unzip these files with errors around "The parameter is incorrect".

Instead just format to simle HH-mm regardless of locale.

I've verified this works as it should across timezones, where I still got the appropriate file names on a project in the US, while my machine had CET as timezone.
  • Loading branch information
hakon-matland-adsk authored Mar 12, 2024
1 parent f9b2dcc commit f80bda2
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/components/ExportButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@ export default function ExportButton(props: ExportButtonProps) {
);
while (current.toMillis() <= endDate.toMillis()) {
await Forma.sun.setDate({ date: current.toJSDate() });

const filename =
current.toLocaleString({
timeZone: projectTimezone,
hour: "2-digit",
minute: "2-digit",
hour12: false,
}) + ".png";
const filename = `${current.toFormat("HH-mm")}.png`;
const canvas = await Forma.camera.capture({ width, height });
const data = canvas.toDataURL().split("base64,")[1];
zipFolder.file(filename, data, { base64: true });
Expand Down

0 comments on commit f80bda2

Please sign in to comment.