-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from kdaveid/master
TZID property parameter MUST NOT be applied to values in UTC.
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Linq; | ||
using Ical.Net.DataTypes; | ||
using Ical.Net.Interfaces.DataTypes; | ||
using Ical.Net.Serialization.iCalendar.Serializers.DataTypes; | ||
using NUnit.Framework; | ||
|
||
namespace Ical.Net.UnitTests.Serialization.iCalendar.Serializers.DataTypes | ||
{ | ||
[TestFixture] | ||
public class DateTimeSerializerTests | ||
{ | ||
[Test, Category("Deserialization")] | ||
public void TZIDPropertyMustNotBeAppliedToUtcDateTime() | ||
{ | ||
var ical = new Ical.Net.Calendar(); | ||
var evt = new Ical.Net.Event(); | ||
evt.DtStamp = new CalDateTime(new DateTime(2016, 8, 17, 2, 30, 0, DateTimeKind.Utc)); | ||
ical.Events.Add(evt); | ||
|
||
var serializer = new Ical.Net.Serialization.iCalendar.Serializers.CalendarSerializer(); | ||
var serializedCalendar = serializer.SerializeToString(ical); | ||
|
||
var lines = serializedCalendar.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList(); | ||
var result = lines.First(s => s.StartsWith("DTSTAMP")); | ||
Assert.AreEqual("DTSTAMP:20160817T023000Z", result); | ||
} | ||
|
||
[Test, Category("Deserialization")] | ||
public void TZIDPropertyShouldBeAppliedForLocalTimezones() | ||
{ | ||
// see http://www.ietf.org/rfc/rfc2445.txt p.36 | ||
var result = DateTimeSerializer() | ||
.SerializeToString( | ||
new CalDateTime(new DateTime(1997, 7, 14, 13, 30, 0, DateTimeKind.Local), "US-Eastern")); | ||
|
||
// TZID is applied elsewhere - just make sure this doesn't have 'Z' appended. | ||
Assert.AreEqual("19970714T133000", result); | ||
} | ||
|
||
|
||
private static DateTimeSerializer DateTimeSerializer() | ||
{ | ||
return new DateTimeSerializer(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters