Iterator for Duration/Interval/Period

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Iterator for Duration/Interval/Period

Nepomuk Seiler
Hi,

Joda Time has a lot of nice convenient methods. However one is missing to iterate nicely
over Intervals (or Durations, Periods).

Normally you would do somethink like

Interval interval = ...;
Days days = Days. daysBetween(interval.getStart(), interval.getEnd());
for(int i=0; i < days.getDays(); i++) {
  // do something
}

or adding up DateTimes and compare, etc.

It would be nice to have an iterator for this. Like:

Iterator<DateTime> iter = Intervals.daysIn(interval);

So I can call

for(DateTime day : Intervals.daysIn(interval)) {
   // work with day
}


what do you think?
Muki

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Iterator for Duration/Interval/Period

jodastephen
Looping/iteration may be a good addition, but it is possible with the
API as is as you demonstrate.
With my current JSR-310 commitments its unlikely I'd have time to look
into this.
Stephen

On 26 January 2013 22:22, Nepomuk Seiler <[hidden email]> wrote:

> Hi,
>
> Joda Time has a lot of nice convenient methods. However one is missing to
> iterate nicely
> over Intervals (or Durations, Periods).
>
> Normally you would do somethink like
>
> Interval interval = ...;
> Days days = Days. daysBetween(interval.getStart(), interval.getEnd());
> for(int i=0; i < days.getDays(); i++) {
>   // do something
> }
>
> or adding up DateTimes and compare, etc.
>
> It would be nice to have an iterator for this. Like:
>
> Iterator<DateTime> iter = Intervals.daysIn(interval);
>
> So I can call
>
> for(DateTime day : Intervals.daysIn(interval)) {
>    // work with day
> }
>
>
> what do you think?
> Muki
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Iterator for Duration/Interval/Period

Nepomuk Seiler-2

Hi,

I would provide an implementation if it will be merged at some point. Would that be an option?

Cheers,
Muki



2013/1/27 Nepomuk Seiler <[hidden email]>

Hi,

I would provide an implementation if it will be merged at some point. Would that be an option?

Cheers,
Muki

Am 27.01.2013 01:20 schrieb "Stephen Colebourne" <[hidden email]>:

Looping/iteration may be a good addition, but it is possible with the
API as is as you demonstrate.
With my current JSR-310 commitments its unlikely I'd have time to look
into this.
Stephen

On 26 January 2013 22:22, Nepomuk Seiler <[hidden email]> wrote:
> Hi,
>
> Joda Time has a lot of nice convenient methods. However one is missing to
> iterate nicely
> over Intervals (or Durations, Periods).
>
> Normally you would do somethink like
>
> Interval interval = ...;
> Days days = Days. daysBetween(interval.getStart(), interval.getEnd());
> for(int i=0; i < days.getDays(); i++) {
>   // do something
> }
>
> or adding up DateTimes and compare, etc.
>
> It would be nice to have an iterator for this. Like:
>
> Iterator<DateTime> iter = Intervals.daysIn(interval);
>
> So I can call
>
> for(DateTime day : Intervals.daysIn(interval)) {
>    // work with day
> }
>
>
> what do you think?
> Muki
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...