Skip to content

Commit

Permalink
SNOW-1271212 fixed epoch to be in utc
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mhofman committed Apr 3, 2024
1 parent 0e842c0 commit adf3c45
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Snowflake.Data.Tests/IntegrationTests/SFBindTestIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ public void TestDateTimeBinding(ResultFormat resultFormat, SFTableType tableType
var timestamp = "2023/03/15 13:17:29.207 +05:00"; // 08:17:29.207 UTC
var expected = ExpectedTimestampWrapper.From(timestamp, columnType);
var columnWithPrecision = ColumnTypeWithPrecision(columnType, columnPrecision);
var testCase = $"TableType={tableType}, ColumnType={columnWithPrecision}, BindingType={bindingType}, ComparisonFormat={comparisonFormat}";
var testCase = $"ResultFormat={resultFormat}, TableType={tableType}, ColumnType={columnWithPrecision}, BindingType={bindingType}, ComparisonFormat={comparisonFormat}";
var bindingThreshold = 65280; // when exceeded enforces bindings via file on stage
var smallBatchRowCount = 2;
var bigBatchRowCount = bindingThreshold / 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Snowflake.Data.Tests.Util
{
public static class DbCommandTestExtensions
public static class DbCommandExtensions
{
internal static IDbDataParameter Add(this IDbCommand command, string name, DbType dbType, object value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Snowflake.Data.Tests.Util
{
public static class DbConnectionTestExtensions
public static class DbConnectionExtensions
{
internal static IDbCommand CreateCommand(this IDbConnection connection, string commandText)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public enum SFTableType
Iceberg
}

static class TableTypeTestExtensions
static class TableTypeExtensions
{
internal static string TableDDLCreationPrefix(this SFTableType val) => val == SFTableType.Standard ? "" : val.ToString().ToUpper();

Expand Down
6 changes: 3 additions & 3 deletions Snowflake.Data/Core/SFBindUploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ internal string GetCSVData(string sType, string sValue)
if (sValue == null)
return sValue;

DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Unspecified);
DateTime epoch = SFDataConverter.UnixEpoch;
switch (sType)
{
case "TEXT":
Expand Down Expand Up @@ -265,9 +265,9 @@ internal string GetCSVData(string sType, string sValue)
string[] tstzString = sValue.Split(' ');
long nsFromEpochTz = long.Parse(tstzString[0]); // SFDateConverter provides in [ns] from Epoch
int timeZoneOffset = int.Parse(tstzString[1]) - 1440; // SFDateConverter provides in minutes increased by 1440m
DateTime timestamp = epoch.AddTicks(nsFromEpochTz/100);
DateTime timestamp = epoch.AddTicks(nsFromEpochTz/100).AddMinutes(timeZoneOffset);
TimeSpan offset = TimeSpan.FromMinutes(timeZoneOffset);
DateTimeOffset tzDateTimeOffset = new DateTimeOffset(timestamp.AddMinutes(timeZoneOffset), offset);
DateTimeOffset tzDateTimeOffset = new DateTimeOffset(timestamp.Year, timestamp.Month, timestamp.Day, timestamp.Hour, timestamp.Minute, timestamp.Second, timestamp.Millisecond, offset);
return tzDateTimeOffset.ToString("yyyy-MM-dd HH:mm:ss.fffffff zzz");
}
return sValue;
Expand Down

0 comments on commit adf3c45

Please sign in to comment.