Skip to content

Commit

Permalink
Merge pull request #296 from TwistyPop/master
Browse files Browse the repository at this point in the history
Reverted TZID parameter in UTC Dates.
  • Loading branch information
rianjs authored Jun 15, 2017
2 parents 031125c + fa0beda commit 9756412
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 22 deletions.
4 changes: 1 addition & 3 deletions net-core/Ical.Net/Ical.Net.UnitTests/CalendarEventTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ public bool EnsureAutomaticallySetDTSTAMPisSerializedAsKindUTC(string serialized
var lines = serialized.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
var result = lines.First(s => s.StartsWith("DTSTAMP"));

//Both of these are correct, since the library no longer asserts that UTC must elide an explicit TZID in favor of the Z suffix on UTC times
return !result.Contains("TZID=") && result.EndsWith("Z")
|| result.Contains("TZID=") && !result.EndsWith("Z");
return !result.Contains("TZID=") && result.EndsWith("Z");
}

public static IEnumerable<ITestCaseData> EnsureAutomaticallySetDtStampIsSerializedAsUtcKind_TestCases()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@ public override string SerializeToString(object obj)
{
var dt = obj as IDateTime;

//Historically, dday.ical substituted TZID=UTC with Z suffixes on DateTimes. However this behavior isn't part of the spec. Some popular libraries
//like Telerik's RadSchedule components will only understand the DateTimeKind.Utc if the ical text says TZID=UTC. Anything but that is treated as
//DateTimeKind.Unspecified, which is problematic.
// RFC 5545 3.3.5:
// The date with UTC time, or absolute time, is identified by a LATIN
// CAPITAL LETTER Z suffix character, the UTC designator, appended to
// the time value. The "TZID" property parameter MUST NOT be applied to DATE-TIME
// properties whose time values are specified in UTC.
if (dt.IsUniversalTime)
{
dt.Parameters.Remove("TZID");

if (!string.IsNullOrWhiteSpace(dt.TzId))
} else if (!string.IsNullOrWhiteSpace(dt.TzId))
{
dt.Parameters.Set("TZID", dt.TzId);
}
Expand Down
2 changes: 1 addition & 1 deletion v2/ical.NET.Collections/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ical.net.collections
namespace Ical.Net.Collections
{
public class ObjectEventArgs<T, TU> :
EventArgs
Expand Down
6 changes: 3 additions & 3 deletions v2/ical.NET.Collections/GroupedValueList.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ical.net.collections.Interfaces;
using ical.net.collections.Proxies;
using Ical.Net.Collections.Interfaces;
using Ical.Net.Collections.Proxies;

namespace ical.net.collections
namespace Ical.Net.Collections
{
public class GroupedValueList<TGroup, TInterface, TItem, TValueType> :
GroupedList<TGroup, TInterface>
Expand Down
2 changes: 1 addition & 1 deletion v2/ical.NET.Collections/Interfaces/IGroupedList.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace ical.net.collections.Interfaces
namespace Ical.Net.Collections.Interfaces
{
public interface IGroupedList<TGroup, TItem> :
IGroupedCollection<TGroup, TItem>,
Expand Down
2 changes: 1 addition & 1 deletion v2/ical.NET.Collections/Interfaces/IGroupedObject.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ical.net.collections.Interfaces
namespace Ical.Net.Collections.Interfaces
{
public interface IGroupedObject<TGroup>
{
Expand Down
2 changes: 1 addition & 1 deletion v2/ical.NET.Collections/Interfaces/IMultiLinkedList.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace ical.net.collections.Interfaces
namespace Ical.Net.Collections.Interfaces
{
public interface IMultiLinkedList<TType> :
IList<TType>
Expand Down
2 changes: 1 addition & 1 deletion v2/ical.NET.Collections/Interfaces/IValueObject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

namespace ical.net.collections.Interfaces
namespace Ical.Net.Collections.Interfaces
{
public interface IValueObject<T>
{
Expand Down
4 changes: 1 addition & 3 deletions v2/ical.NET.UnitTests/EventTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ public bool EnsureAutomaticallySetDTSTAMPisSerializedAsKindUTC(string serialized
var lines = serialized.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
var result = lines.First(s => s.StartsWith("DTSTAMP"));

//Both of these are correct, since the library no longer asserts that UTC must elide an explicit TZID in favor of the Z suffix on UTC times
return !result.Contains("TZID=") && result.EndsWith("Z")
|| result.Contains("TZID=") && !result.EndsWith("Z");
return !result.Contains("TZID=") && result.EndsWith("Z");
}

public static IEnumerable<ITestCaseData> EnsureAutomaticallySetDtStampIsSerializedAsUtcKind_TestCases()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ public override string SerializeToString(object obj)
{
var dt = obj as IDateTime;

//Historically, dday.ical substituted TZID=UTC with Z suffixes on DateTimes. However this behavior isn't part of the spec. Some popular libraries
//like Telerik's RadSchedule components will only understand the DateTimeKind.Utc if the ical text says TZID=UTC. Anything but that is treated as
//DateTimeKind.Unspecified, which is problematic.
// RFC 5545 3.3.5:
// The date with UTC time, or absolute time, is identified by a LATIN
// CAPITAL LETTER Z suffix character, the UTC designator, appended to
// the time value. The "TZID" property parameter MUST NOT be applied to DATE-TIME
// properties whose time values are specified in UTC.
if (dt.IsUniversalTime)
{
dt.Parameters.Remove("TZID");

if (!string.IsNullOrWhiteSpace(dt.TzId))
} else if (!string.IsNullOrWhiteSpace(dt.TzId))
{
dt.Parameters.Set("TZID", dt.TzId);
}
Expand Down

0 comments on commit 9756412

Please sign in to comment.