Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

negative seconds in Delta evan if days is non-negative #20

Closed
Hanaasagi opened this issue Jun 8, 2023 · 1 comment
Closed

negative seconds in Delta evan if days is non-negative #20

Hanaasagi opened this issue Jun 8, 2023 · 1 comment

Comments

@Hanaasagi
Copy link
Contributor

Hanaasagi commented Jun 8, 2023

code example:

    const now = datetime.Datetime.fromSeconds(1686183930);
    const future = datetime.Datetime.fromSeconds(1686268800);
    const delta = future.sub(now);

    std.debug.print("future => {s}\n", .{try future.formatHttp(testing.allocator)});
    std.debug.print("now    => {s}\n", .{try now.formatHttp(testing.allocator)});
    std.debug.print("delta  => {any}\n", .{delta});

Output:

future => Fri, 9 Jun 2023 00:00:00 UTC
now    => Thu, 8 Jun 2023 00:25:30 UTC
delta  => datetime.Datetime.Delta{ .years = 0, .days = 1, .seconds = -1530, .nanoseconds = 0, .relative_to = null }

In the output, I noticed that the delta has a days value of 1 and a negative seconds value of -1530. To make it more convenient for comparing delta.days > 1, Would it be possible to changing the delta to have days = 0 and seconds = 84870?

@frmdstryr
Copy link
Owner

frmdstryr commented Jun 8, 2023

Makes sense, please review d21cc01 and let me know if that works. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants