Skip to content

Commit b0c4698

Browse files
abbotwareeerhardt
authored andcommitted
ARROW-7508: [C#] DateTime32 Reading is Broken
fix for DateTime32 reading Closes apache#6136 from abbotware/ARROW-7508 and squashes the following commits: d7dd5b6 <Anthony Abate> change MillisecondsPerDay to long add unit test ff2552d <Abbotware> fix for date reading Lead-authored-by: Anthony Abate <anthony.abate@gmail.com> Co-authored-by: Abbotware <abbotware@users.noreply.github.com> Signed-off-by: Eric Erhardt <eric.erhardt@microsoft.com>
1 parent 3c452dc commit b0c4698

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

‎csharp/src/Apache.Arrow/Arrays/Date32Array.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Apache.Arrow
2020
{
2121
public class Date32Array : PrimitiveArray<int>
2222
{
23-
private const int MillisecondsPerDay = 86400000;
23+
private const long MillisecondsPerDay = 86400000;
2424

2525
public class Builder : PrimitiveArrayBuilder<DateTimeOffset, int, Date32Array, Builder>
2626
{
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one or more
2+
// contributor license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright ownership.
4+
// The ASF licenses this file to You under the Apache License, Version 2.0
5+
// (the "License"); you may not use this file except in compliance with
6+
// the License. You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
using System;
17+
using Xunit;
18+
19+
namespace Apache.Arrow.Tests
20+
{
21+
public class Date32ArrayTests
22+
{
23+
public class Set
24+
{
25+
[Fact]
26+
public void SetAndGet()
27+
{
28+
var now = DateTimeOffset.UtcNow;
29+
30+
// throw away the time portion of the date time
31+
var expected = new DateTime(now.Year, now.Month, now.Day);
32+
33+
var array = new Date32Array.Builder()
34+
.Resize(1)
35+
.Set(0, expected)
36+
.Build();
37+
38+
Assert.Equal(expected, array.GetDate(0).Value.Date);
39+
}
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)