Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-7508

[C#] DateTime32 Reading is Broken

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 0.15.1
    • 0.16.0
    • C#

    Description

      DateTime support for writing works - but reading is broken.

      This is another arithmetic overflow bug (reported a few already) which is causing date to be misinterpreted

       I extracted the current logic out to linqpad and to show the bug and fix:

       

      	var dto = DateTimeOffset.Parse("2024-09-25");
      	(dto.ToUnixTimeMilliseconds() / 86400000).Dump();
      	// YIELDS: 19991
      	
      	unchecked  (current code)
      	{
      		DateTimeOffset.FromUnixTimeMilliseconds(19991 * 86400000).Dump();
      		// 1/8/1970 WRONG
      	}	
      
              checked
      	{
      		DateTimeOffset.FromUnixTimeMilliseconds((long)19991 * 86400000).Dump();
      		// 9/25/2024 CORRECT
      	} 

       

       

      this fix is trivial - a cast to long is missing where ever FromUnixTimeMilliseconds is used

       

       

      Attachments

        Issue Links

          Activity

            People

              abbot Anthony Abate
              abbot Anthony Abate
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h
                  2h