Skip to content

Commit

Permalink
Remove DTSTAMP from VTIMEZONE (#323)
Browse files Browse the repository at this point in the history
* Revert "Remove DTSTAMP from VTIMEZONE

* Remove unused imports

* Add test for cleaning up old VTIMEZONEs with DTSTAMP
  • Loading branch information
allenporter authored Apr 21, 2024
1 parent 4b612fe commit 2203051
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 16 deletions.
6 changes: 0 additions & 6 deletions ical/timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from .parsing.property import ParsedProperty
from .types import Recur, Uri, UtcOffset
from .tzif import timezoneinfo, tz_rule
from .util import dtstamp_factory

__all__ = [
"Timezone",
Expand Down Expand Up @@ -135,11 +134,6 @@ class Timezone(ComponentModel):
sub-component.
"""

dtstamp: Union[datetime.datetime, datetime.date] = Field(
default_factory=lambda: dtstamp_factory()
)
"""Last revision date."""

tz_id: str = Field(alias="tzid")
"""An identifier for this Timezone, unique within a calendar."""

Expand Down
4 changes: 0 additions & 4 deletions tests/__snapshots__/test_calendar_stream.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
}),
}),
]),
'dtstamp': '2023-03-13T01:12:29',
'standard': list([
dict({
'dtstart': '2010-11-07T02:00:00',
Expand Down Expand Up @@ -1027,7 +1026,6 @@
}),
}),
]),
'dtstamp': '2022-08-11T06:12:12',
'last_modified': '2005-08-09T05:00:00+00:00',
'standard': list([
dict({
Expand Down Expand Up @@ -1278,7 +1276,6 @@
SEQUENCE:0
END:VEVENT
BEGIN:VTIMEZONE
DTSTAMP:20230313T011229
TZID:America/Example
BEGIN:STANDARD
DTSTART:20101107T020000
Expand Down Expand Up @@ -1788,7 +1785,6 @@
PRODID:-//ABC Corporation//NONSGML My Product//EN
VERSION:2.0
BEGIN:VTIMEZONE
DTSTAMP:20220811T061212
TZID:America/New_York
LAST-MODIFIED:20050809T050000Z
BEGIN:STANDARD
Expand Down
43 changes: 41 additions & 2 deletions tests/test_timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def test_from_tzif_timezoneinfo_with_dst(
PRODID:-//example//1.2.3
VERSION:2.0
BEGIN:VTIMEZONE
DTSTAMP:20220822T123000
TZID:America/New_York
BEGIN:STANDARD
DTSTART:20101107T020000
Expand Down Expand Up @@ -156,7 +155,6 @@ def test_from_tzif_timezoneinfo_fixed_offset(
PRODID:-//example//1.2.3
VERSION:2.0
BEGIN:VTIMEZONE
DTSTAMP:20220822T123000
TZID:Asia/Tokyo
BEGIN:STANDARD
DTSTART:20100101T000000
Expand All @@ -175,3 +173,44 @@ def test_invalid_tzif_key() -> None:

with pytest.raises(TimezoneInfoError, match=r"Unable to find timezone"):
Timezone.from_tzif("invalid")



@freeze_time("2022-08-22 12:30:00")
def test_clear_old_dtstamp(
mock_prodid: Generator[None, None, None]
) -> None:
"""Verify a timezone created from a tzif timezone info with a fixed offset"""

stream = IcsCalendarStream.from_ics(inspect.cleandoc("""
BEGIN:VCALENDAR
PRODID:-//example//1.2.3
VERSION:2.0
BEGIN:VTIMEZONE
DTSTAMP:20220822T123000
TZID:Asia/Tokyo
BEGIN:STANDARD
DTSTART:20100101T000000
TZOFFSETTO:0900
TZOFFSETFROM:0900
TZNAME:JST
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
"""))
# DTSTAMP is omitted from the output
assert stream.ics() == inspect.cleandoc("""
BEGIN:VCALENDAR
PRODID:-//example//1.2.3
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Asia/Tokyo
BEGIN:STANDARD
DTSTART:20100101T000000
TZOFFSETTO:0900
TZOFFSETFROM:0900
TZNAME:JST
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
""")
3 changes: 1 addition & 2 deletions tests/testdata/datetime_vtimezone.ics
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ CREATED:20230313T011226
SEQUENCE:0
END:VEVENT
BEGIN:VTIMEZONE
DTSTAMP:20230313T011229
TZID:America/Example
BEGIN:STANDARD
DTSTART:20101107T020000
Expand All @@ -28,4 +27,4 @@ RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
TZNAME:PDT
END:DAYLIGHT
END:VTIMEZONE
END:VCALENDAR
END:VCALENDAR
3 changes: 1 addition & 2 deletions tests/testdata/timezone_ny.ics
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ BEGIN:VCALENDAR
PRODID:-//ABC Corporation//NONSGML My Product//EN
VERSION:2.0
BEGIN:VTIMEZONE
DTSTAMP:20220811T061212
TZID:America/New_York
LAST-MODIFIED:20050809T050000Z
BEGIN:DAYLIGHT
Expand Down Expand Up @@ -55,4 +54,4 @@ TZOFFSETTO:-0500
TZNAME:EST
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
END:VCALENDAR

0 comments on commit 2203051

Please sign in to comment.