question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AddTicks not work correctly

See original GitHub issue

add ticks not work correctly in this simple : https://deck.net/d8843f388823586dca2a2b94bbbd6af1 Expected Result 2019-12-01T00:00:00.0000000 2019-11-30T23:59:59.9990000 2019-11-30T23:59:59.9990000 Actual Result 2019-12-01T00:00:00.0000000 2019-12-01T00:00:00.0000000 2019-11-30T23:59:59.9990000 i think to fix this problem its to replace: https://github.com/theolivenbaum/h5/blob/d9c8a733e6b55584c3bd37b1f461ae9378882550/H5/H5/shared/System/DateTime.cs#L454 with is : return new DateTime((ulong)(ticks + value)); or with this: return new DateTime((long)(ticks + value));

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
hardhubcommented, Oct 8, 2021

@theolivenbaum I think you can use create$2 version inside AddTicks. Please use the following code (and I will not fork the repo for the moment).

addTicks: function (d, v) {
                v = System.Int64.is64Bit(v) ? v : System.Int64(v);

                var ticks = this.getTicks(d).add(v);
                var kind = d.kind;

                if (ticks.lt(this.TicksPerDay)) {
                    d = new Date(0);
                    d.setMilliseconds(d.getMilliseconds() + this.$getTzOffset(d).div(10000).toNumber());
                    d.setFullYear(1);
                } else {
                    d = new Date(ticks.sub(this.$getMinOffset()).div(10000).toNumber());

                    if (kind !== 1) {
                        d.setTime(d.getTime() + (d.getTimezoneOffset() * 60000));
                    }
                }

                d.kind = (kind !== undefined) ? kind : 0;
                d.ticks = ticks;

                return d;
            },

I have adjusted it a bit for needs of AddTicks. And it shows more correct result.

2019-12-01T00:00:00.0000000
2019-11-30T23:59:59.9990000
2019-11-30T23:59:59.9990000

Of course it is not 999 9999, but at least the behaviour is equal to other DateTime logic and bug is solved.

0reactions
theolivenbaumcommented, Oct 8, 2021

Looks good, I’ll add over the weekend when I’ve some time, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Unable to use DateTime.AddTicks
Timer.Interval is milliseconds. But ticks are not milliseconds, they are something much smaller. You're mixing apples and oranges. I think you ...
Read more >
DateTime.AddTicks() Method in C# - GeeksforGeeks
This method is used to returns a new DateTime that adds the specified number of ticks to the value of this instance. This...
Read more >
How to add ticks in a circle in TikZ
How to add ticks in a circle in TikZ ... But, this approach is not effective, as the ticks length has to calculated...
Read more >
DateTime.AddTicks(Int64) Method (System)
Returns a new DateTime that adds the specified number of ticks to the value of this instance.
Read more >
pgfplots, multiply values, add ticks without numbers
I need a tick for every beat, but not a number, because the numbers would overlap. I need to multiply the values of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found