Comments (7)
Can you give a more specific example of what you want to achieve?
from rrule.
example
FREQ=MINUTELY;DTSTART=20130827T003000Z;INTERVAL=30;WKST=MO;COUNT=10;UNTIL=20131227T023000Z; Starttime=03:00;Endtime=04:00
result
1 Tue Aug 27 2013 03:00:00 GMT+0300 (Arab Standard Time)
2 Tue Aug 27 2013 03:30:00 GMT+0300 (Arab Standard Time)
3 Tue Aug 28 2013 03:00:00 GMT+0300 (Arab Standard Time)
4 Tue Aug 28 2013 03:30:00 GMT+0300 (Arab Standard Time)
5 Tue Aug 29 2013 03:00:00 GMT+0300 (Arab Standard Time)
6 Tue Aug 29 2013 03:30:00 GMT+0300 (Arab Standard Time)
7 Tue Aug 30 2013 03:00:00 GMT+0300 (Arab Standard Time)
8 Tue Aug 30 2013 03:30:00 GMT+0300 (Arab Standard Time)
9 Tue Aug 31 2013 03:00:00 GMT+0300 (Arab Standard Time)
10 Tue Aug 31 2013 03:30:00 GMT+0300 (Arab Standard Time)
now return time in all day and go to next day
i need specific time in day
from rrule.
This can be done by filtering the result, such as:
var rule = RRule.fromString('FREQ=MINUTELY;DTSTART=20130827T003000Z;INTERVAL=30;WKST=MO;COUNT=10;UNTIL=20131227T023000Z');
var allDates = rule.all();
var filteredDates = []
for (var i = 0; i < allDates.length; i++) {
var date = allDates[i], hours = date.getHours(), minutes = date.getMinutes();
if (hours == 3 || (hours == 4 && minutes == 0)) {
filteredDates.push(date);
}
}
console.log(filteredDates);
from rrule.
thank you for help me
but i think Count option not get all result correct because will get all result in same day
example
var rule = RRule.fromString('FREQ=MINUTELY;DTSTART=20130827T003000Z;INTERVAL=30;WKST=MO;COUNT=10;UNTIL=20131227T023000Z');
var allDates = rule.all();
it will get top 10 in same day and loop filter get 2 record only
result
1 Tue Aug 27 2013 03:30:00 GMT+0300 (Arab Standard Time)
2 Tue Aug 27 2013 04:00:00 GMT+0300 (Arab Standard Time)
3 Tue Aug 27 2013 04:30:00 GMT+0300 (Arab Standard Time)
4 Tue Aug 27 2013 05:00:00 GMT+0300 (Arab Standard Time)
5 Tue Aug 27 2013 05:30:00 GMT+0300 (Arab Standard Time)
6 Tue Aug 27 2013 06:00:00 GMT+0300 (Arab Standard Time)
7 Tue Aug 27 2013 06:30:00 GMT+0300 (Arab Standard Time)
8 Tue Aug 27 2013 07:00:00 GMT+0300 (Arab Standard Time)
9 Tue Aug 27 2013 07:30:00 GMT+0300 (Arab Standard Time)
10 Tue Aug 27 2013 08:00:00 GMT+0300 (Arab Standard Time)
but i need that
1 Tue Aug 27 2013 03:00:00 GMT+0300 (Arab Standard Time)
2 Tue Aug 27 2013 03:30:00 GMT+0300 (Arab Standard Time)
3 Tue Aug 28 2013 03:00:00 GMT+0300 (Arab Standard Time)
4 Tue Aug 28 2013 03:30:00 GMT+0300 (Arab Standard Time)
5 Tue Aug 29 2013 03:00:00 GMT+0300 (Arab Standard Time)
6 Tue Aug 29 2013 03:30:00 GMT+0300 (Arab Standard Time)
7 Tue Aug 30 2013 03:00:00 GMT+0300 (Arab Standard Time)
8 Tue Aug 30 2013 03:30:00 GMT+0300 (Arab Standard Time)
9 Tue Aug 31 2013 03:00:00 GMT+0300 (Arab Standard Time)
10 Tue Aug 31 2013 03:30:00 GMT+0300 (Arab Standard Time)
from rrule.
i make update in code and now work fine
but i will test now all cases
string formula
FREQ=MINUTELY;timefrom=03:00;timeto=04:00;isparttime=1,DTSTART=20130828T000000Z;INTERVAL=30;WKST=MO;COUNT=10
and add to option parameter
timefrom ----> 03:00
timeto ----> 04:00
isparttime ---> 0 or 1
code update line 1252
add this code
.... code
if (freq < RRule.HOURLY) {
if (!iterResult.accept(res)) {
return iterResult.getValue();
}
}
else {
if (this.options.isparttime == 1) {
var cutime = res.getHours().toString() + ":" + res.getMinutes().toString();
var timefrom = this.options.timefrom;
var timeto = this.options.timeto;
if (dateCompare(cutime, timefrom) >= 0 && dateCompare(timeto, cutime) > 0) {
if (!iterResult.accept(res)) {
return iterResult.getValue();
}
}
else {
continue;
}
}
else {
if (!iterResult.accept(res)) {
return iterResult.getValue();
}
}
}
......code
add this method for compare time
function dateCompare(time1,time2) {
var t1 = new Date();
var parts = time1.split(":");
t1.setHours(parts[0],parts[1],0,0);
var t2 = new Date();
parts = time2.split(":");
t2.setHours(parts[0],parts[1],0,0);
// returns 1 if greater, -1 if less and 0 if the same
if (t1.getTime()>t2.getTime()) return 1;
if (t1.getTime()<t2.getTime()) return -1;
return 0;
}
from rrule.
There is no need for adding new options. You can achieve what you need already with the current API, and also adding new options would make it incompatible with the iCalendar standard. If you need extra filtering, you can either use the approach I showed above, or in your case it might be more suitable to use the iterator
argument to rule.all()
:
// Create a rule with no COUNT
var rule = RRule.fromString('FREQ=MINUTELY;DTSTART=20130827T003000Z;INTERVAL=30;WKST=MO;UNTIL=20131227T023000Z');
var dates = [];
var limit = 10;
rule.all(function(date){
// The iterator function allows for custom filtering
// and limiting the number of dates manually.
// It's called for each date matched by the rule.
// Does the date match our custom filter?
if (date.getHours() == 3 || (date.getHours() == 4 && date.getMinutes() == 0)) {
dates.push(date); // Yup
if (dates.length == limit) {
return false; // Stop iteration, we have enough dates
}
}
return true; // Continue iteration
});
console.log(dates);
from rrule.
Thank you I will use api to achieve this
Sent from my Windows Phone
From: Jakub Roztočilmailto:[email protected]
Sent: 8/28/2013 12:31 PM
To: jkbr/rrulemailto:[email protected]
Subject: Re: [rrule] I want to add features (#23)
There is no need for adding new options. You can achieve what you need already with the current API, and also adding new options would make it incompatible with the iCalendar standard. If you need extra filtering, you can either use the approach I showed above, or in your case it might be more suitable to use the iterator
argument to rule.all()
:
// Create a rule with no COUNT
var rule = RRule.fromString('FREQ=MINUTELY;DTSTART=20130827T003000Z;INTERVAL=30;WKST=MO;UNTIL=20131227T023000Z');
var dates = [];
var limit = 10;
rule.all(function(date){
// The iterator function allows for custom filtering
// and limiting the number of dates manually.
// It's called for each date matched by the rule.
// Does the date match our custom filter?
if (date.getHours() == 3 || (date.getHours() == 4 && date.getMinutes() == 0)) {
dates.push(date); // Yup
if (dates.length == limit) {
return false; // Stop iteration, we have enough dates
}
}
return true; // Continue iteration
});
console.log(dates);
Reply to this email directly or view it on GitHub:
#23 (comment)
from rrule.
Related Issues (20)
- Broken the link HOT 2
- Combining MINUTELY with BYHOUR and BYDAY misses out days when used with just one BYHOUR value
- Possible solution for "Invalid UNTIL value"
- [bug] Decimal interval creates an infinite loop HOT 2
- Using RRule.after and RRule.between with Hermes JS Engine HOT 1
- RRrule timezone issue
- Exdates returning UTC date without TZID offset HOT 3
- rrule.after method doesn't work if there is a TZID in the dtstart HOT 1
- returned date incorrect caused by TZ rollover HOT 5
- Occurences are wrong when DTStart includes timezone
- rrulestr constructor with options doesn't flow through DTStart or TZID
- Is this still being actively maintained?
- working with Evolution Mail and web calendar using RRULE fail because of X-EVOLUTION-ENDDATE in rrule HOT 2
- Timezone issue
- How can we define a repeating rule that occurs Yearly and spans for a month - ex) Black History Month HOT 1
- Given an RRuleSet, how can we modify a single event in a recurrence HOT 1
- RRule is missing next occurrence HOT 1
- Invalid rrule string generated for single-digit year dtstart dates (ex: "0002-01-01") HOT 1
- Bower install rrule does not seem to generate a dist/es5/rrule.js HOT 1
- possible issue, skipping initial date when tzid and dtstart is provided
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rrule.