🛠️ToolsShed

일광절약시간 달력

현재 및 내년의 국가별 DST 시작 및 종료 날짜를 확인합니다.

겨울 UTC 오프셋
UTC-05:00
여름 UTC 오프셋
UTC-04:00
2026올해
DST 시작
Sun, Mar 8
UTC-04:00
DST 종료
Sun, Nov 1
UTC-05:00
2027내년
DST 시작
Sun, Mar 14
UTC-04:00
DST 종료
Sun, Nov 7
UTC-05:00

현지 시간 (오전 2시에 시계 변경)

자주 묻는 질문

코드 구현

from datetime import datetime, timedelta
import pytz  # pip install pytz

def get_dst_transitions(tz_name: str, year: int) -> dict:
    """Get DST start and end dates for a timezone in a given year."""
    tz = pytz.timezone(tz_name)
    transitions = []

    # Check each day of the year for offset changes
    prev_offset = None
    for day in range(365 + (1 if year % 4 == 0 else 0)):
        dt = datetime(year, 1, 1) + timedelta(days=day)
        localized = tz.localize(dt)
        offset = localized.utcoffset()
        if prev_offset is not None and offset != prev_offset:
            transitions.append({
                "date": dt.strftime("%Y-%m-%d"),
                "from_offset": str(prev_offset),
                "to_offset": str(offset),
                "type": "start" if offset > prev_offset else "end",
            })
        prev_offset = offset
    return {"timezone": tz_name, "year": year, "transitions": transitions}

# Example
info = get_dst_transitions("America/New_York", 2024)
for t in info["transitions"]:
    print(f"DST {t['type']}: {t['date']} ({t['from_offset']} -> {t['to_offset']})")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.