Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverted TZID parameter in UTC Dates. #296

Merged
merged 2 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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