• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Giorgi / DuckDB.NET / 21786556530

07 Feb 2026 08:39PM UTC coverage: 89.155% (-0.07%) from 89.223%
21786556530

push

github

Giorgi
Added support for clearing in-progress adapter

Requires DuckDB 1.5

1199 of 1393 branches covered (86.07%)

Branch coverage included in aggregate %.

6 of 8 new or added lines in 1 file covered. (75.0%)

193 existing lines in 43 files now uncovered.

2336 of 2572 relevant lines covered (90.82%)

557295.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.3
/DuckDB.NET.Bindings/DuckDBTimestamp.cs
1
namespace DuckDB.NET.Native;
2

3
[StructLayout(LayoutKind.Sequential)]
4
public readonly struct DuckDBTimestamp(DuckDBDateOnly date, DuckDBTimeOnly time)
5
{
6
    /// <summary>
7
    /// Represents positive infinity for DuckDB timestamps.
8
    /// </summary>
9
    public static readonly DuckDBTimestamp PositiveInfinity =
3✔
10
        // This is the max timestamp value + 1 microsecond (because timestamps are represented as an int64 of microseconds)
3✔
11
        // Theoretically: '294247-01-10 04:00:54.775806'::timestamp + INTERVAL '1 microsecond'
3✔
12
        new(new DuckDBDateOnly(294247, 1, 10), new DuckDBTimeOnly(4, 0, 54, 775807));
3✔
13

14
    /// <summary>
15
    /// Represents negative infinity for DuckDB timestamps.
16
    /// </summary>
17
    public static readonly DuckDBTimestamp NegativeInfinity =
3✔
18
        // This is the min timestamp value - 1 microsecond (because timestamps are represented as an int64 of microseconds)
3✔
19
        // Theoretically: '290309-12-22 (BC) 00:00:00.000000'::timestamp - INTERVAL '1 microsecond'
3✔
20
        new(new DuckDBDateOnly(-290308, 12, 21), new DuckDBTimeOnly(23, 59, 59, 999999));
3✔
21

22
    public DuckDBDateOnly Date { get; } = date;
63,480✔
23
    public DuckDBTimeOnly Time { get; } = time;
31,599✔
24

25
    /// <summary>
26
    /// Returns true if this timestamp represents positive or negative infinity.
27
    /// </summary>
28
    public bool IsInfinity => IsPositiveInfinity || IsNegativeInfinity;
63✔
29

30
    /// <summary>
31
    /// Returns true if this timestamp represents positive infinity.
32
    /// </summary>
33
    public bool IsPositiveInfinity => Equals(PositiveInfinity);
15,807✔
34

35
    /// <summary>
36
    /// Returns true if this timestamp represents negative infinity.
37
    /// </summary>
38
    public bool IsNegativeInfinity => Equals(NegativeInfinity);
15,732✔
39

40
    public DateTime ToDateTime()
41
    {
42
        return new DateTime(Date.Year, Date.Month, Date.Day).AddTicks(Time.Ticks);
15,936✔
43
    }
44

45
    public static DuckDBTimestamp FromDateTime(DateTime dateTime)
46
    {
47
        return new DuckDBTimestamp(DuckDBDateOnly.FromDateTime(dateTime), DuckDBTimeOnly.FromDateTime(dateTime));
15,621✔
48
    }
49

50
    /// <summary>
51
    /// Converts a DuckDBTimestampStruct to DuckDBTimestamp, handling infinity values.
52
    /// </summary>
53
    public static DuckDBTimestamp FromDuckDBTimestampStruct(DuckDBTimestampStruct timestampStruct)
54
    {
55
        if (timestampStruct.IsPositiveInfinity)
16,077✔
56
            return PositiveInfinity;
39✔
57
        if (timestampStruct.IsNegativeInfinity)
16,038✔
58
            return NegativeInfinity;
39✔
59

60
        return NativeMethods.DateTimeHelpers.DuckDBFromTimestamp(timestampStruct);
15,999✔
61
    }
62

63
    /// <summary>
64
    /// Converts this DuckDBTimestamp to a DuckDBTimestampStruct, handling infinity values.
65
    /// </summary>
66
    public DuckDBTimestampStruct ToDuckDBTimestampStruct()
67
    {
68
        if (IsPositiveInfinity)
15,711✔
69
            return DuckDBTimestampStruct.PositiveInfinity;
45✔
70
        if (IsNegativeInfinity)
15,666✔
71
            return DuckDBTimestampStruct.NegativeInfinity;
45✔
72

73
        return NativeMethods.DateTimeHelpers.DuckDBToTimestamp(this);
15,621✔
74
    }
75

UNCOV
76
    public static implicit operator DateTime(DuckDBTimestamp timestamp) => timestamp.ToDateTime();
×
77
    public static implicit operator DuckDBTimestamp(DateTime timestamp) => DuckDBTimestamp.FromDateTime(timestamp);
3✔
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc