Skip to content

Commit af13bc7

Browse files
authored
DateTime handling adjustments for inconsistencies between local and UTC times.
1 parent c6ae83f commit af13bc7

File tree

290 files changed

+2886
-7163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+2886
-7163
lines changed

buildtools/CustomTasks/TimingTask.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public override bool Execute()
1515
if (ShouldInit)
1616
{
1717
ShouldInit = false;
18-
StartTime = DateTime.Now;
18+
StartTime = DateTime.UtcNow;
1919
MainThread = new Thread(() =>
2020
{
2121
try
2222
{
2323
while (true)
2424
{
25-
var elapsed = DateTime.Now - StartTime;
25+
var elapsed = DateTime.UtcNow - StartTime;
2626
Console.WriteLine(">>>>> ELAPSED TIME = " + elapsed.ToString("h'h 'm'm 's's'"));
2727
Thread.Sleep(SleepTime);
2828
}

docgenerator/AWSSDKDocSamples/AutoScaling/AutoScaling.GeneratedSamples.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -957,11 +957,11 @@ public void AutoScalingPutScheduledUpdateGroupAction()
957957
{
958958
AutoScalingGroupName = "my-auto-scaling-group",
959959
DesiredCapacity = 4,
960-
EndTimeUtc = new DateTime(2014, 5, 12, 8, 0, 0, DateTimeKind.Utc),
960+
EndTime = new DateTime(2014, 5, 12, 8, 0, 0, DateTimeKind.Utc),
961961
MaxSize = 6,
962962
MinSize = 2,
963963
ScheduledActionName = "my-scheduled-action",
964-
StartTimeUtc = new DateTime(2014, 5, 12, 8, 0, 0, DateTimeKind.Utc)
964+
StartTime = new DateTime(2014, 5, 12, 8, 0, 0, DateTimeKind.Utc)
965965
});
966966

967967

docgenerator/AWSSDKDocSamples/EC2/EC2.GeneratedSamples.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ public void EC2DescribeSpotFleetRequestHistory()
18271827
var response = client.DescribeSpotFleetRequestHistory(new DescribeSpotFleetRequestHistoryRequest
18281828
{
18291829
SpotFleetRequestId = "sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE",
1830-
StartTimeUtc = new DateTime(2015, 5, 26, 12, 0, 0, DateTimeKind.Utc)
1830+
StartTime = new DateTime(2015, 5, 26, 12, 0, 0, DateTimeKind.Utc)
18311831
});
18321832

18331833
List<HistoryRecord> historyRecords = response.HistoryRecords;
@@ -1879,14 +1879,14 @@ public void EC2DescribeSpotPriceHistory()
18791879
var client = new AmazonEC2Client();
18801880
var response = client.DescribeSpotPriceHistory(new DescribeSpotPriceHistoryRequest
18811881
{
1882-
EndTimeUtc = new DateTime(2014, 1, 6, 8, 9, 10, DateTimeKind.Utc),
1882+
EndTime = new DateTime(2014, 1, 6, 8, 9, 10, DateTimeKind.Utc),
18831883
InstanceTypes = new List<string> {
18841884
"m1.xlarge"
18851885
},
18861886
ProductDescriptions = new List<string> {
18871887
"Linux/UNIX (Amazon VPC)"
18881888
},
1889-
StartTimeUtc = new DateTime(2014, 1, 6, 7, 8, 9, DateTimeKind.Utc)
1889+
StartTime = new DateTime(2014, 1, 6, 7, 8, 9, DateTimeKind.Utc)
18901890
});
18911891

18921892
List<SpotPrice> spotPriceHistory = response.SpotPriceHistory;

docgenerator/AWSSDKDocSamples/ElastiCache/ElastiCache.GeneratedSamples.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public void ElastiCacheDescribeEvents()
534534
var client = new AmazonElastiCacheClient();
535535
var response = client.DescribeEvents(new DescribeEventsRequest
536536
{
537-
StartTimeUtc = new DateTime(2016, 12, 22, 3, 0, 0, DateTimeKind.Utc)
537+
StartTime = new DateTime(2016, 12, 22, 3, 0, 0, DateTimeKind.Utc)
538538
});
539539

540540
List<Event> events = response.Events;

extensions/src/AWSSDK.Extensions.CloudFront.Signers/AmazonCloudFrontCookieSigner.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public static CookiesForCannedPolicy GetCookiesForCannedPolicy(string resourceUr
155155
{
156156
var cookies = new CookiesForCannedPolicy();
157157

158-
string epochSeconds = AWSSDKUtils.ConvertToUnixEpochSecondsString(expiresOn.ToUniversalTime());
158+
string epochSeconds = AWSSDKUtils.ConvertToUnixEpochSecondsString(expiresOn);
159159
cookies.Expires = new KeyValuePair<string, string>(
160160
ExpiresKey, epochSeconds);
161161

extensions/src/AWSSDK.Extensions.CloudFront.Signers/AmazonCloudFrontUrlSigner.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public static String SignUrlCanned(string resourceUrlOrPath,
329329
TextReader privateKey,
330330
DateTime expiresOn)
331331
{
332-
string epochSeconds = AWSSDKUtils.ConvertToUnixEpochSecondsString(expiresOn.ToUniversalTime());
332+
string epochSeconds = AWSSDKUtils.ConvertToUnixEpochSecondsString(expiresOn);
333333
RSAParameters rsaParameters = ConvertPEMToRSAParameters(privateKey);
334334
string cannedPolicy = "{\"Statement\":[{\"Resource\":\"" + resourceUrlOrPath
335335
+ "\",\"Condition\":{\"DateLessThan\":{\"AWS:EpochTime\":" + epochSeconds
@@ -408,15 +408,15 @@ public static string BuildPolicyForSignedUrl(string resourcePath,
408408
+ "\""
409409
+ ",\"Condition\":{"
410410
+ "\"DateLessThan\":{\"AWS:EpochTime\":"
411-
+ AWSSDKUtils.ConvertToUnixEpochSecondsString(expiresOn.ToUniversalTime())
411+
+ AWSSDKUtils.ConvertToUnixEpochSecondsString(expiresOn)
412412
+ "}"
413413
// omitting IpAddress parameter indicates any ip address access
414414
+ (string.IsNullOrEmpty(limitToIpAddressCIDR)
415415
? ""
416416
: ",\"IpAddress\":{\"AWS:SourceIp\":\"" + limitToIpAddressCIDR + "\"}")
417417
// Ignore epochDateGreaterThan if its value is DateTime.MinValue, the default value of DateTime.
418418
+ (activeFrom > DateTime.MinValue ? ",\"DateGreaterThan\":{\"AWS:EpochTime\":"
419-
+ AWSSDKUtils.ConvertToUnixEpochSecondsString(activeFrom.ToUniversalTime()) + "}"
419+
+ AWSSDKUtils.ConvertToUnixEpochSecondsString(activeFrom) + "}"
420420
: string.Empty)
421421
+ "}}]}";
422422
return policy;

extensions/test/CloudFront.SignersTests/URLSignerTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void TestGetCannedSignedUrlWithOpenSSL3()
163163
-----END PRIVATE KEY-----
164164
");
165165

166-
Assert.NotNull(AmazonCloudFrontUrlSigner.GetCannedSignedURL("http://example.com", reader, "keyPairId", DateTime.Now));
166+
Assert.NotNull(AmazonCloudFrontUrlSigner.GetCannedSignedURL("http://example.com", reader, "keyPairId", DateTime.UtcNow));
167167

168168
}
169169
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"core": {
3+
"changeLogMessages": [
4+
"Updated DateTime handling to use UTC instead of local times.",
5+
"DateTime handling (Breaking Change): Removed obsolete properties such EndTime then changed EndTimeUtc to EndTime. This could lead to offset times for developers still using the marked obsolete original EndTime for example. A compile time error will occur for anyone using any of the removed *Utc properties such as EndTimeUtc.",
6+
"DateTime handling (Breaking Change): Response unmarshallers for TimeStamps and list TimeStamps for formats TimestampFormat.ISO8601 || TimestampFormat.RFC822 datetimes were being parsed into local times. Adjusted DateTime parsing to return UTC times.",
7+
"DateTime handling (Breaking Change): Fixed the DateTimeUnmarshaller which was parsing datetime strings into and returning them as local time which in some cases were still getting converted back to UTC on a prior bug fix but not always. DateTime strings unmarshalled are assumed to be UTC time and will be specified and unmarshalled as UTC.",
8+
"DateTime handling (Breaking Change): ConvertFromUnixEpochSeconds/ConvertFromUnixEpochMilliseconds incorrectly returning the Unix Epoch time as local time instead of a UTC time by definition. This changes the behavior where these methods were used.",
9+
"DateTime handling (Breaking Change): DynamoDB RetrieveDateTimeInUtc has been switched to true as the default.",
10+
"DateTime handling (Bug fix): Fixed internal Epoch dates to UTC per definition where the epoch date was created in local time. ",
11+
"DateTime handling (Bug fix): Stopped using expiry times in credentials internally as local time. Changed to UTC.",
12+
"DateTime handling (Bug fix): Ensured DateTime.Max and DateTime.Min are marked with a DateTime.Kind DateTimeKind.Utc for proper calculations.",
13+
"DateTime handling (Bug fix): Instead of assuming SAML credentials are local time then converting to UTC and assume that the time given is UTC to work properly with credential expiration being in UTC time for other credential providers.",
14+
"DateTime handling (Bug fix): Console logger outputs timestamps as a UTC date incase output is sent off the local machine and for easier comparison with other UTC dates.",
15+
"DateTime handling (Bug fix): RetryPolicies return UTC server time instead of a UTC time converted to local time.",
16+
"DateTime handling (Bug fix): AWSPublicIpAddressRanges mixing UTC and local time.",
17+
"DateTime handling (Bug fix): GetFormattedTimestampISO8601 incorrectly creating a DateTime object as local time even though it is passed in as UTC. Then formatting it as a UTC string."
18+
],
19+
"type": "patch",
20+
"updateMinimum": true
21+
}
22+
}

generator/ServiceClientGeneratorLib/Customizations.cs

-41
Original file line numberDiff line numberDiff line change
@@ -857,10 +857,8 @@ public class ShapeModifier
857857
public const string InjectKey = "inject";
858858
public const string CustomMarshallKey = "customMarshall";
859859
public const string DeprecatedMessageKey = "deprecatedMessage";
860-
public const string BackwardsCompatibleDateTimeKey = "backwardsCompatibleDateTimeProperties";
861860

862861
private readonly HashSet<string> _excludedProperties;
863-
private readonly HashSet<string> _backwardsCompatibleDateTimeProperties;
864862
private readonly Dictionary<string, JsonData> _modifiedProperties;
865863
private readonly Dictionary<string, JsonData> _injectedProperties;
866864

@@ -871,7 +869,6 @@ public ShapeModifier(JsonData data)
871869
DeprecationMessage = data[DeprecatedMessageKey].CastToString();
872870

873871
_excludedProperties = ParseExclusions(data);
874-
_backwardsCompatibleDateTimeProperties = ParseBackwardsCompatibleDateTimeProperties(data);
875872
_modifiedProperties = ParseModifiers(data);
876873
// Process additions after rename to allow for models where we
877874
// add a 'convenience' member (for backwards compatibility) using
@@ -931,25 +928,6 @@ public bool IsExcludedProperty(string propertyName)
931928

932929
#endregion
933930

934-
#region Backwards Compatible DateTime Properties
935-
936-
// Backwards Compatible DateTime Properties modifier is a simple array of property names.
937-
// "backwardsCompatibleDateTimeProperties": [ "propName1", "propName2" ]
938-
private static HashSet<string> ParseBackwardsCompatibleDateTimeProperties(JsonData data)
939-
{
940-
var exclusions = data[ShapeModifier.BackwardsCompatibleDateTimeKey]
941-
?.Cast<object>()
942-
.Select(exclusion => exclusion.ToString());
943-
return new HashSet<string>(exclusions ?? new string[0]);
944-
}
945-
946-
public bool IsBackwardsCompatibleDateTimeProperty(string propertyName)
947-
{
948-
return _backwardsCompatibleDateTimeProperties.Contains(propertyName);
949-
}
950-
951-
#endregion
952-
953931
#region Property Modifiers
954932

955933
// A modifier is an array of objects, each object being the original
@@ -1237,25 +1215,6 @@ public bool IsExcludedProperty(string propertyName, string shapeName = null)
12371215
return false;
12381216
}
12391217

1240-
/// <summary>
1241-
/// Returns true if the specified property name is marked as requiring backwards compatible handling
1242-
/// of DateTime values at global or per-shape scope.
1243-
/// </summary>
1244-
/// <param name="propertyName"></param>
1245-
/// <param name="shapeName"></param>
1246-
/// <returns></returns>
1247-
public bool IsBackwardsCompatibleDateTimeProperty(string propertyName, string shapeName = null)
1248-
{
1249-
if (shapeName != null)
1250-
{
1251-
var shapeModifier = GetShapeModifier(shapeName);
1252-
if (shapeModifier != null)
1253-
return shapeModifier.IsBackwardsCompatibleDateTimeProperty(propertyName);
1254-
}
1255-
1256-
return false;
1257-
}
1258-
12591218
public OperationModifiers GetOperationModifiers(string operationName)
12601219
{
12611220
var data = _documentRoot[OperationModifiers.OperationModifiersKey];

generator/ServiceClientGeneratorLib/Example.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public void GetSampleLiteral(Shape shape, JsonData data, CodeBuilder cb)
314314
cb.AppendFormat("new {0}({1})", ShapeType(shape), data.ToString());
315315
}
316316

317-
else if (shape.IsDateTime)
317+
else if (shape.IsTimeStamp)
318318
{
319319
string exampleValue = null;
320320

@@ -363,7 +363,7 @@ private string ShapeType(Shape shape)
363363
return "float";
364364
if (shape.IsDouble)
365365
return "double";
366-
if (shape.IsDateTime)
366+
if (shape.IsTimeStamp)
367367
return "DateTime";
368368
if (shape.IsMemoryStream)
369369
return "MemoryStream";

0 commit comments

Comments
 (0)