Announcement

Collapse
No announcement yet.

[OPEN] [#2967] Bug with DateTime - AddDays (April)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [OPEN] [#2967] Bug with DateTime - AddDays (April)

    Incorrect date

    https://deck.net/cedcad4ccf3df353ac1766bb3c6f5b90

    https://dotnetfiddle.net/U2mvCc

  • #2
    Added Workaround - if the hours == 23 then add 1 hour. seems to fix

    Comment


    • #3
      Hi,

      Can you explain what is incorrect?

      Here is my output:
      - Deck
      04/01/2017 00:00:00
      04/02/2017 00:00:00
      04/03/2017 00:00:00
      05/01/2017 00:00:00
      05/02/2017 00:00:00
      05/03/2017 00:00:00
      - dotnetfiddle
      4/1/2017 12:00:00 AM
      4/2/2017 12:00:00 AM
      4/3/2017 12:00:00 AM
      5/1/2017 12:00:00 AM
      5/2/2017 12:00:00 AM
      5/3/2017 12:00:00 AM

      Comment


      • #4
        using chrome:

        public class Program
        {
        public static void Main()
        {
        var x = new DateTime(2017, 04, 1);

        Console.WriteLine(x);

        Console.WriteLine(x.AddDays(1));
        Console.WriteLine(x.AddDays(2));

        var y = new DateTime(2017, 05, 1);

        Console.WriteLine(y);

        Console.WriteLine(y.AddDays(1));
        Console.WriteLine(y.AddDays(2));
        }
        }

        /**
        * @compiler Bridge.NET 16.0.0-beta4
        */
        Bridge.assembly("Demo", function ($asm, globals) {
        "use strict";

        Bridge.define("Demo.Program", {
        main: function Main () {
        var x = new Date(2017, 4 - 1, 1);

        System.Console.WriteLine(Bridge.box(x, System.DateTime, System.DateTime.format));

        System.Console.WriteLine(Bridge.box(new Date(x.valueOf() + Math.round((1) * 864e5)), System.DateTime, System.DateTime.format));
        System.Console.WriteLine(Bridge.box(new Date(x.valueOf() + Math.round((2) * 864e5)), System.DateTime, System.DateTime.format));

        var y = new Date(2017, 5 - 1, 1);

        System.Console.WriteLine(Bridge.box(y, System.DateTime, System.DateTime.format));

        System.Console.WriteLine(Bridge.box(new Date(y.valueOf() + Math.round((1) * 864e5)), System.DateTime, System.DateTime.format));
        System.Console.WriteLine(Bridge.box(new Date(y.valueOf() + Math.round((2) * 864e5)), System.DateTime, System.DateTime.format));
        }
        });
        });

        output
        • 04/01/2017 00:00:00
        • 04/02/2017 00:00:00
        • 04/02/2017 23:00:00
        • 05/01/2017 00:00:00
        • 05/02/2017 00:00:00
        • 05/03/2017 00:00:00

        Comment


        • #5
          • 04/02/2017 00:00:00
          • 04/02/2017 23:00:00
          on the second day, it adds 23 hours not 24 hours, only with april.Chrome on my Windows 10 and Chrome on Ubuntu both show the same error

          Comment


          • #6
            Hi samuelgrahame – Thanks for the code samples. Can you share a link to your samples running in either Deck or DotNotFiddle? or both.

            When posting code samples in the Bridge forums, please wrap your code samples in [CODE] tags. We would appreciate if you could edit your posts above to add [CODE] tags and formatting to your code samples.

            Comment


            • #7
              Issue #2967 has been created to track this defect.

              I haven't been able to reproduce the defect, but I suspect it has something to do with AddDays spanning across Daylight Saving Time. The logic is being revised and will be included in pull request #2945.

              Comment


              • #8
                yeah,i think too. it is because im using it in australia

                Comment

                Working...
                X