2026년 11월 26일 목요일

Why does my all-day ICS event end a day early?

If an all-day event runs through January 2, its calendar file should say January 3 in DTEND. That field marks the first day outside the event. You can check an export before importing it by comparing two dates in the file with the last day in the event listing.

Why does my all-day ICS event end a day early?
A reading map of the checks explained below.

Find the dates for one event

Open a copy of the .ics file in a text editor. Find the event you want and stay inside its BEGIN:VEVENT and END:VEVENT lines. Look for DTSTART;VALUE=DATE and DTEND;VALUE=DATE. Copy the eight digits after each property. Then write the last day shown in the original listing in the same year-month-day order, using eight digits and no separators.

For an event advertised as December 30 through January 2, use 20261230 for the start and 20270102 for the advertised last day. Take the exported end from the file itself. Keeping the listing and file values separate lets you check whether they agree.

Sources: RFC 5545, iCalendar — RFC 5545 §3.6.1, Event Component, including the multi-day event example

Check the exported end against the listing

First confirm that the advertised last day is on or after the start. Add one calendar day to that last day to get the expected DTEND. This works across month and year boundaries. If the end in the file equals or precedes the start, check that you copied both properties from the same event.

To try your own dates, copy the Python example below and replace one row in its list. Enter the start first, the exported end second and the advertised last day third. The program prints a verdict and the expected DTEND line. It reads only the three values you supply.

Check the exported end against the listing
Reported resultWhat to inspect or change
MATCHThe exported end matches the listing. Keep it.
Days shortConfirm the final date with the organizer and compare it with the expected DTEND line.
Days longCheck whether the exporter added a day to a date that was already exclusive.
INVALID RANGECheck the start and end fields. The explicit end must follow the start.

Sources: RFC 5545, iCalendar — RFC 5545 §3.6.1, Event Component, Python 3.12 datetime — Python 3.12 datetime documentation, date supported operations

Try three possible end dates for the same event

In the synthetic examples run with Python 3.12.13 below, an end value of 20270102 left January 2 out. An end of 20270103 included all four advertised days. An end of 20270104 included January 3 too. All three runs used the same start and advertised last day. Only the test value for DTEND changed.

The example also checks a one-day event and an end equal to its start. To report a problem to the calendar publisher, send the three dates, the result and the expected DTEND line. Those details let the publisher repeat the comparison without sharing the rest of your calendar.

Sources: RFC 5545, iCalendar — RFC 5545 §3.6.1, Event Component, Python 3.12 datetime — Python 3.12 datetime documentation, date supported operations

Check whether the event uses a different format

This check is for a single all-day event with explicit DATE values for both start and end. An all-day event can also have a start with neither DTEND nor DURATION. RFC 5545 gives that form a one-day duration. A recurring event, a DURATION field or a timestamp with a clock time needs a different interpretation. The examples here test calendar-date arithmetic locally.

Sources: RFC 5545, iCalendar — RFC 5545 §3.6.1, Event Component

Primary sources checked: 2026-11-26. Only the explicitly recorded fixture was tested locally; other guidance is documentation-based. No performance benchmark was performed.

Reproduce the locally verified result

ics-all-day-local-v1

Recorded environment: 3.12.13 / Darwin. Checked: 2026-11-26T06:04:11.365552+00:00

from datetime import date, timedelta

def read_date(value):
    if len(value) != 8 or not value.isascii() or not value.isdigit():
        raise ValueError("Use the eight digits from a VALUE=DATE property")
    return date(int(value[:4]), int(value[4:6]), int(value[6:]))

def check(start, exported_end, advertised_last):
    first, end, last = map(read_date, (start, exported_end, advertised_last))
    if last < first:
        raise ValueError("The advertised last day is before the start")
    expected = last + timedelta(days=1)
    if end <= first:
        status = "INVALID RANGE"
    else:
        delta = (end - expected).days
        status = "MATCH" if delta == 0 else f"{abs(delta)} day(s) " + ("short" if delta < 0 else "long")
    return f"{status} | expected DTEND;VALUE=DATE:{expected:%Y%m%d}"

# Each row: DTSTART, exported DTEND, last day shown in the listing.
for case in [
    ("20261230", "20261231", "20261230"),  # one day
    ("20261230", "20270102", "20270102"),  # advertised through Jan 2
    ("20261230", "20270103", "20270102"),  # already correct
    ("20261230", "20270104", "20270102"),  # an extra day was added twice
    ("20261230", "20261230", "20261230"),  # end equals start
]:
    print(*case, "|", check(*case))

Observed output

20261230 20261231 20261230 | MATCH | expected DTEND;VALUE=DATE:20261231
20261230 20270102 20270102 | 1 day(s) short | expected DTEND;VALUE=DATE:20270103
20261230 20270103 20270102 | MATCH | expected DTEND;VALUE=DATE:20270103
20261230 20270104 20270102 | 1 day(s) long | expected DTEND;VALUE=DATE:20270103
20261230 20261230 20261230 | INVALID RANGE | expected DTEND;VALUE=DATE:20261231

Only this fixed synthetic fixture was tested on the recorded runtime. No production files, other OS/version combinations, UI applications, throughput or performance were tested.

2026년 11월 24일 화요일

Why a UTF-16 CSV retry can report “No columns to parse from file”

The retry can be reading from the end of the uploaded stream. A failed UTF-8 parse may already have consumed its bytes; changing the retry to UTF-16 does not reset the position. Check the position after the failure, then return a seekable stream to its start before retrying. This diagnosis applies when the upload remains open, supports seeking, and actually contains CSV data in the chosen encoding.

Why a UTF-16 CSV retry can report “No columns to parse from file”
A reading map of the checks explained below.

What does the error mean in this retry?

pandas.read_csv accepts a file-like object and an explicit encoding. The encoding tells pandas how to interpret bytes it reads; it does not make an earlier read available again. If the first attempt leaves the upload at its end, the second attempt receives no CSV header or data, even when UTF-16 is the correct encoding.

Treat the initial UnicodeDecodeError and the later empty-data error as observations from two separate attempts. The first points to a decoding problem with the selected UTF-8 attempt. The second may reflect where the next read began. Neither error alone proves that the upload has zero bytes.

Sources: pandas.read_csv — pandas.read_csv — Parameters: filepath_or_buffer; encoding, io — Core tools for working with streams — I/O base classes — IOBase.seek; IOBase.tell

How can I distinguish the causes?

After catching the UTF-8 decoding error, inspect upload.tell() if the stream supports it. That reports its current position. Compare it with the known byte length when available. A position at the end makes an unrewound retry a useful control: it tests the remaining bytes, which may be none, rather than testing whether UTF-16 can parse the original upload.

The recorded synthetic fixture used the same CSV content encoded once as UTF-8 and once as UTF-16. With pandas 2.0.3 on Python 3.9.6, the UTF-8 case parsed directly. In the UTF-16 case, the failed UTF-8 read left the BytesIO position at 32 of 32 bytes; an immediate UTF-16 retry raised EmptyDataError. This is a local result for that fixture, not a guarantee of how every upload object or pandas version positions its stream.

Sources: io — Core tools for working with streams — I/O base classes — IOBase.tell; IOBase.seekable, pandas.read_csv — pandas.read_csv — Parameters: encoding

How should the retry read the upload?

For a seekable upload, call upload.seek(0) after the failed attempt and before pd.read_csv(upload, encoding="utf-16"). Python documents zero as the start position for a seekable stream. In the recorded fixture, that rewind let the UTF-16 case parse the expected item and quantity row.

If the upload is not seekable, obtain a fresh readable stream from the original bytes before another attempt. Confirm that the stream is open and that the encoding matches the file being supplied. A successful rewind only restores access to bytes; it cannot fix an incorrect encoding or a file without parseable CSV columns. The fixture did not test framework upload wrappers, arbitrary encoding detection, or delimiter detection, so check those separately if a rewind still fails.

Sources: io — Core tools for working with streams — I/O base classes — IOBase.seek; IOBase.seekable; IOBase.close, pandas.read_csv — pandas.read_csv — Parameters: filepath_or_buffer; encoding; sep; header

Primary sources checked: 2026-11-24. Only the explicitly recorded fixture was tested locally; other guidance is documentation-based. No performance benchmark was performed.

Reproduce the locally verified result

pandas-csv-retry-stream-v1

Recorded environment: 3.9.6 / Darwin. Checked: 2026-11-24T12:49:26.528837+00:00

import io
import pandas as pd

print("pandas", pd.__version__)
for encoding in ("utf-8", "utf-16"):
    data = "item,qty\npen,2\n".encode(encoding)
    upload = io.BytesIO(data)
    try:
        rows = pd.read_csv(upload, encoding="utf-8")
    except UnicodeDecodeError:
        print(encoding, "after failed UTF-8 read:", upload.tell(), "of", len(data))
        try:
            pd.read_csv(upload, encoding="utf-16")
        except pd.errors.EmptyDataError:
            print("retry at current position: EmptyDataError")
        upload.seek(0)
        rows = pd.read_csv(upload, encoding="utf-16")
    print(encoding, rows.to_dict("records"))

Observed output

pandas 2.0.3
utf-8 [{'item': 'pen', 'qty': 2}]
utf-16 after failed UTF-8 read: 32 of 32
retry at current position: EmptyDataError
utf-16 [{'item': 'pen', 'qty': 2}]

One seekable synthetic BytesIO stream with a known encoding and comma delimiter per case. No Django upload, Teams export, arbitrary encoding detection or delimiter detection was tested.