-
Notifications
You must be signed in to change notification settings - Fork 37
Add DateIterator and make consistent date type APIs #436
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
Conversation
why not use date + 100.iota!uint; |
That only works for days. Even if you did something a stride, then it is constant by days. So for instance, skipping every 30 days is not the same as skipping every month. I want to add a function, call it |
I'm also open to changing the name to something else, like
`DateLikeIterator`
…On Wed, Jul 20, 2022 at 2:01 PM Ilia Ki ***@***.***> wrote:
why not use iota?
date + 100.iota!uint;
—
Reply to this email directly, view it on GitHub
<#436 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADBFNSSZPGLESDILLF3NNYTVVA5H7ANCNFSM54BRAN5Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
One thing that might make this somewhat simpler for |
The following solution requires much less changes and additional. map!Date(YearMonth(2020, 1) + 4.iota!uint)
Not really. |
Yes, there are some special cases like leap year and different amount of days in a month. However, this day convention are much more complex and requires. There are multiple conventions of adding a month to a date that will result different adjusted dates. |
I'm open to suggestions, but this doesn't work currently because |
I would suggest making an MR from scratch and adding only |
@9il You added version(mir_test_date)
unittest
{
auto x = YearMonth(2020, 1);
auto x1 = x + 1;
auto x2 = x + 2;
auto x3 = x + 3;
import std.stdio: writeln;
writeln(x3); // prints YearMonth(2020, 7)
} |
That is because opBinary bug. It should use a temporal variable instead. BTW, we have two implementation |
Closed in favor of PR #438 |
Will use with
between
function to add support forperiod
function (to return slice of Dates).Had to make some adjustments to make each of the date types have a consistent API. I changed the
addXXX
to anincrementCopy
, but really the important thing is theincrement
part of it. I leftdate._addDays
since that was the only remainingaddXXX
function in `date and didn't want to get too ahead of myself.