Back to Feed
article 2m read

PDF import could wipe the schedule, and then its preview showed the wrong weekday

The agent's first PDF import for my shift scheduler wrote over the whole schedule; a review-then-save version replaced it within minutes, but its day labels and post-import jump came out a day early west of UTC until a later change built dates from their parts. The looser parser and a refocus check still have gaps I haven't closed.

Article DepthPractice

Flow

How my import handles four situations now

The last one is the gap I most want closed.

  1. 1PDF with only a few days

    Other stored days stay. The first version would have wiped them.

  2. 2Day left unticked or Cancel

    Nothing is written for it.

  3. 3Viewer west of UTC

    Labels and the jump now use the right day, after a later change.

  4. 4Date line it cannot read

    Every shift under it is dropped and the box does not say so.

For about ten minutes, importing a PDF into my shift scheduler would have replaced the whole schedule with just the days in that PDF.

The scheduler stores every day in one file, keyed by date. The agent built the import in small steps. One step turns the PDF into text. The next reads that text and finds days and shifts.

Saving too early

The first version of the reader saved what it found straight over the schedule file. Give it three days and every other day would be gone. A second branch from the agent took that save out and added a review box. It landed about ten minutes later. I haven't checked whether anything got wiped in between.

Now the reader only hands back what it found. A box lists each day with a ticked checkbox. Import copies the ticked days in and saves the normal way. Cancel changes nothing.

It still replaces a whole day at once. If a day already had my edits, they're gone, and the box doesn't warn me.

The wrong weekday

The box built each day's label from a stored key like a year, month and day joined by dashes. JavaScript reads a bare date like that as midnight in UTC. West of UTC, that's still the evening before, so a Monday would show as Sunday:

new Date("2031-03-03")   // the day before, west of UTC
new Date(2031, 2, 3)     // the right day everywhere

A jump to the first imported day had the same bug, so it would land on an empty day. A later change built both dates from plain numbers instead.

Messy PDFs

Real PDF text is messy. The reader now joins a weekday with a date on the next line, and it accepts much looser shift lines. That lets more real sheets in, plus some junk. If it can't read a day's date, every shift under it vanishes and the box can't show that. People are matched by first name, and every shift gets the same default breaks.

The refocus check

An earlier check jumps back to today when the window regains focus. I think it would also pull me off a day I chose on purpose, including the one the import just jumped to. I haven't clicked through that in the browser.

Keep reading

Pick up a connected idea or branch into a nearby one.

5 paths forward