Skip to content

Commit

Permalink
Bugfix/99 fix readme (#104)
Browse files Browse the repository at this point in the history
README.md fixes

fix documentation and remove lgtm badge
fixes #99
  • Loading branch information
dmfs authored Nov 6, 2022
1 parent 5791fbd commit bfe749b
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[![Build Status](https://travis-ci.org/dmfs/lib-recur.svg?branch=master)](https://travis-ci.org/dmfs/lib-recur)
[![codecov](https://codecov.io/gh/dmfs/lib-recur/branch/master/graph/badge.svg)](https://codecov.io/gh/dmfs/lib-recur)
[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/dmfs/lib-recur.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/dmfs/lib-recur/context:java)

# lib-recur

Expand Down Expand Up @@ -127,7 +126,7 @@ new RecurrenceSet(DateTime.parse("19820523"),
```
results in
```
19830524,19840524,19850524…
19820524,19830524,19840524,19850524…
```
Note that `19820523` is not among the results.

Expand All @@ -142,7 +141,7 @@ new RecurrenceSet(DateTime.parse("19820523"),
```
results in
```
19820523,19830524,19840524,19850524…
19820523,19820524,19830524,19840524,19850524…
```


Expand All @@ -167,27 +166,22 @@ This will always stop iterating after at most 1000 instances.
By default, the parser is very tolerant and accepts all rules that comply with RFC 5545. You can use other modes to ensure a certain compliance level:

RecurrenceRule rule1 = new RecurrenceRule("FREQ=WEEKLY;BYWEEKNO=1,2,3,4;BYDAY=SU", RfcMode.RFC2445_STRICT);
// -> will iterate Sunday in the first four weeks of the year

// -> will throw an InvalidRecurrenceRuleExceptionException because in RFC 2445 BYWEEKNO is only valid in
// combination with YEARLY rules

RecurrenceRule rule2 = new RecurrenceRule("FREQ=WEEKLY;BYWEEKNO=1,2,3,4;BYDAY=SU", RfcMode.RFC2445_LAX);
// -> will iterate Sunday in the first four weeks of the year (just like RfcMode.RFC2445_STRICT)

// -> will iterate Sunday in the first four weeks of the year

RecurrenceRule rule3 = new RecurrenceRule("FREQ=WEEKLY;BYWEEKNO=1,2,3,4;BYDAY=SU", RfcMode.RFC5545_STRICT);
// -> will throw an InvalidRecurrenceRuleExceptionException because in RFC 5545 BYWEEKNO is only valid in
// combination to YEARLY rules

// combination with YEARLY rules

RecurrenceRule rule4 = new RecurrenceRule("FREQ=WEEKLY;BYWEEKNO=1,2,3,4;BYDAY=SU", RfcMode.RFC5545_LAX);
// -> will iterate every Sunday of the year
// since BYWEEKNO is not valid in WEEKLY rules this part is just dropped and the rule left is "FREQ=WEEKLY;BYDAY=SU"

// -> will iterate Sunday in the first four weeks of the year

RecurrenceRule rule5 = new RecurrenceRule("BYWEEKNO=1,2,3,4;BYDAY=SU;FREQ=WEEKLY", RfcMode.RFC2445_STRICT);
// -> will throw an InvalidRecurrenceRuleExceptionException because in RFC 2445 the rule must start with "FREQ="


RecurrenceRule rule6 = new RecurrenceRule("FREQ=MONTHLY;BYMONTH=4;", RfcMode.RFC2445_STRICT);
// -> will throw an InvalidRecurrenceRuleExceptionException because the trailing ";" is invalid

Expand All @@ -203,18 +197,18 @@ To build a rule you have to specify a base frequency and optionally an RfcMode.
rule.setCount(20);

// note that unlike with java.util.Calendar the months in this list are 1-based not 0-based
rule.setByRule(Parts.BYMONTH, 1, 3, 5, 7);
rule.setByRule(Part.BYMONTH, 1, 3, 5, 7);

rule.setByRule(Parts.BYMONTHDAY, 4, 8, 12);
rule.setByRule(Part.BYMONTHDAY, 4, 8, 12);

/*
* Alternatively set the values from a list or an array:
*/
Integer[] dayArray = new Integer[]{4, 8, 12};
rule.setByRule(Parts.BYMONTHDAY, dayArray);
rule.setByRule(Part.BYMONTHDAY, dayArray);
List<Integer> dayList = Arrays.asList(dayArray);
rule.setByRule(Parts.BYMONTHDAY, dayList);
rule.setByRule(Part.BYMONTHDAY, dayList);

String ruleStr = rule.toString();
// ruleStr is "FREQ=MONTHLY;BYMONTH=1,3,5,7;BYMONTHDAY=4,8,12;COUNT=20"
Expand Down

0 comments on commit bfe749b

Please sign in to comment.