Giter Club home page Giter Club logo

google-rfc-2445's Introduction

<!DOCTYPE PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Read Me</title>

<link type="text/css" rel="stylesheet"
 href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" />
<script type="text/javascript"
 src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"
></script>

</head>
<body onload="prettyPrint()" bgcolor="white">
<h2>Online Documentation</h2>
<p>The javadoc is available <a
 href="http://google-rfc-2445.googlecode.com/svn/trunk/snapshot/docs/index.html"
>online</a>.</p>

<h2>Downloading</h2>
<p>The source is available from subversion.  See <a
 href="http://code.google.com/p/google-rfc-2445/source">the project page</a> for
instructions on how to download the source from subversion.</p>


<h2>Building</h2>

<p>Requires <a href="http://ant.apache.org/">ant</a> to build with
<a href="http://www.junit.org/">junit</a> for testing, and optionally
<a href="http://joda-time.sourceforge.net/">joda-time</a> installed.</p>

<p>Once you've got <code>ant</code>
<a href="http://ant.apache.org/manual/index.html">set up and installed</a>,
run <code>ant default</code> to build the jars and documentation, and then
read the documentation in the <code>docs</code> directory.  You can use the jar
at <code>jars/rfc2445.jar</code> in your program.</p>

<p>To build without joda-time, run <code>ant rfc2445-no-joda</code> and it will
produce a version of the jar without the joda-time compatibility classes.</p>


<h2>Using</h2>

<p>Using the API is pretty easy.   Pass in some ical and you get back
a date iterable, which can be used in a for-each loop thusly:</p>

<pre class=prettyprint>
// A compatibility layer for joda-time
import com.google.ical.compat.jodatime.LocalDateIteratorFactory;
// A Joda time class that represents a day regardless of timezone
import org.joda.time.LocalDate;

public class ThirteenFridaysTheThirteenth {

  /** print the first 13 Friday the 13ths in the 3rd millenium AD. */
  public static void main(String[] args) throws java.text.ParseException {
    LocalDate start = new LocalDate(2001, 4, 13);

    // Every friday the thirteenth.
    String ical = "RRULE:FREQ=MONTHLY"
                  + ";BYDAY=FR"  // every Friday
                  + ";BYMONTHDAY=13"  // that occurs on the 13th of the month
                  + ";COUNT=13";  // stop after 13 occurences

    // Print out each date in the series.
    for (LocalDate date :
         LocalDateIteratorFactory.createLocalDateIterable(ical, start, true)) {
      System.out.println(date);
    }
  }

}
</pre>
<p>See <a href="rfc2445.html#4.3.10">RFC 2445</a> for the recurrence rule
syntax and what it means, and the examples <a href="rfc2445.html#4.8.5.4"
>later</a> in the same document.</p>

<p>If you use <code>java.util.Date</code> and <code>java.util.Calendar</code> in
your application instead of Joda-Time, you can use the
<code>com.google.ical.compat.javautil</code> package instead to provide
Date objects.</p>


<h2>Running tests</h2>

<p>If you make source changes, you can run <code>ant runtests</code> to run
build and run the tests.</p>

</body>
</html>

google-rfc-2445's People

Contributors

mikesamuel avatar

Watchers

James Cloos avatar

google-rfc-2445's Issues

Returns the StartDate even if not applicable

Hi, a lot of different RRULEs that I've tried returns me the start date.
The rule below is just an example.
Most of the examples from https://tools.ietf.org/html/rfc2445#section-4.8.5.4 
fails due to a returning startdate.

private static void runGoogleTests() throws ParseException
{
    DateTimeZone dtz = DateTimeZone.UTC;
    DateTime dtStart = new DateTime("2014-11-22T00:00:00Z", dtz);//SATURDAY
    DateTimeIterable dti = DateTimeIteratorFactory.createDateTimeIterable("RRULE:FREQ=WEEKLY;COUNT=10;BYDAY=MO", dtStart, dtz, true);

    System.out.println("Size of iterable = " + Iterators.size(dti.iterator()));
    for(DateTime dateTime : dti)
    {
        System.out.println(dateTime);
    }
}

What is the expected output? What do you see instead?
The expected output is a 10 dates that is only Mondays.

Output
Size of iterable = 11
2014-11-22T00:00:00.000Z  <-- Start date is Saturday
2014-11-24T00:00:00.000Z
2014-12-01T00:00:00.000Z
2014-12-08T00:00:00.000Z
2014-12-15T00:00:00.000Z
2014-12-22T00:00:00.000Z
2014-12-29T00:00:00.000Z
2015-01-05T00:00:00.000Z
2015-01-12T00:00:00.000Z
2015-01-19T00:00:00.000Z
2015-01-26T00:00:00.000Z

Original issue reported on code.google.com by [email protected] on 24 Nov 2014 at 1:15

Attachments:

deploy onto google maven repository


http://code.google.com/p/google-maven-repository/

Not really urgent on my behalf, but I expected the rfc2445 library to be 
there alongside the other open source google libraries I use.

Original issue reported on code.google.com by [email protected] on 21 Oct 2009 at 10:29

VcalRewriter.rewriteRule("RRULE:MP6 2+ MO TU WE TH FR #10")

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?
expected output: 
FREQ=MONTHLY;INTERVAL=6;BYDAY=2MO,2TU,2WE,2TH,2FR;COUNT=10

FREQ=MONTHLY;INTERVAL=6;BYDAY=2MO,TU,WE,TH,FR;COUNT=10

What version of the product are you using? On what operating system?


Please provide any additional information below.
According to the document "ivCalendar The Electronic Calendaring and Scheduling 
Exchange Format Version 1.0",

Every six months on the 2nd Monday thru Friday for 10 occurences:
    MP6 2+ MO TU WE TH FR #10

Original issue reported on code.google.com by [email protected] on 13 May 2009 at 4:12

DateTimeIterator.advanceTo() method skips a date for monthly 'bysetpos' rData

I am truely greateful for a wonderful library. I have a bug to report. 

    @Test
    public void reproduceAdanceToMethodBug() throws ParseException {
        // given
        String rData = "RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=TU;BYSETPOS=4";
        DateTime recurrenceStart = new DateTime(2015, 2, 20, 0, 0, 0, 0, DateTimeZone.UTC);
        DateTime skipBefore = new DateTime(2015, 4, 20, 0, 0, 0, 0, DateTimeZone.UTC);        
        DateTimeIterator iterator = DateTimeIteratorFactory.createDateTimeIterable(rData, recurrenceStart, recurrenceStart.getZone(), true).iterator();

        // when
        iterator.advanceTo(skipBefore);

        // then
        assertThat(iterator.next(), is(new DateTime(2015, 4, 28, 0, 0, 0, 0, DateTimeZone.UTC)));
    }

Test case above results in AssertionErrror. 

java.lang.AssertionError: 
Expected: is <2015-04-28T00:00:00.000Z>
     but: was <2015-05-26T00:00:00.000Z>

DateTimeIterator.advanceTo() method skips 2015-04-28T00:00:00. 
It seems to work correctly with rData without 'FREQ=MONTHLY + BYSETPOS' 
combination.

Original issue reported on code.google.com by [email protected] on 4 May 2015 at 8:08

Yearly recurrences

What steps will reproduce the problem?
1. Just running this test method : 

    public static void testsICAL(){
        String iCal = "RRULE:FREQ=YEARLY;INTERVAL=2;BYDAY=SA;BYMONTH=9;BYSETPOS=1";

        SimpleDateFormat datePatternUTC = new SimpleDateFormat(DATE_PATTERN_API);
        datePatternUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
        String sDateStart="2013-08-31T06:00:20.000";
        String sDateAdvanceTo="2013-10-01T00:00:00.000";
        Calendar cStart = Calendar.getInstance();
        Calendar cAdvanceTo= Calendar.getInstance();        

        try {
            cStart.setTime(datePatternUTC.parse(sDateStart));
            cAdvanceTo.setTime(datePatternUTC.parse(sDateAdvanceTo));
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        DateTime start = new DateTime(cStart.getTimeInMillis());
        DateTime advanceTo = new DateTime(cAdvanceTo.getTimeInMillis());

        try {
            DateTimeIterator it = com.google.ical.compat.jodatime.DateTimeIteratorFactory.createDateTimeIterator(iCal, start, DateTimeZone.forID("Europe/Paris"), true);
            if (it != null){
                // On avance l'iterateur jusqua la date de debut de liste
                it.advanceTo(advanceTo);
                Date date;
                int i = 0;
                while(i<=5 && it.hasNext()) {
                    date=it.next().toDate();
                    System.out.println("date: "+date);
                    i++;
                }
            }
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }


What is the expected output? What do you see instead?

I want to get the first Saturday of September, every two year. 
I want the list begin after : 2013-10-01T00:00:00.000.

Expected : 
date: Sat Sep 05 08:00:20 CEST 2015
date: Sat Sep 02 08:00:20 CEST 2017
date: Sat Sep 07 08:00:20 CEST 2019
date: Sat Sep 04 08:00:20 CEST 2021
date: Sat Sep 02 08:00:20 CEST 2023

See instead : 
date: Sat Sep 02 08:00:20 CEST 2017
date: Sat Sep 07 08:00:20 CEST 2019
date: Sat Sep 04 08:00:20 CEST 2021
date: Sat Sep 02 08:00:20 CEST 2023
date: Sat Sep 06 08:00:20 CEST 2025

The 2015 occurrence is ommited.

What version of the product are you using?
rfc2445-4Mar2011.jar 

Please provide any additional information below.
The problem does not occurs if I set : 
   sDateAdvanceTo="2013-09-30T00:00:00.000";


Original issue reported on code.google.com by [email protected] on 26 Sep 2014 at 7:37

google-rfc-2445 and thread safety.

The thread safety of google-rfc-2445 is not documented. Is it thread safe?

We are using google-rfc-2445 in a multi threaded environment and have
received the following exception:
08 Feb 2008 11:00:01,218 [ERROR] xxx.SurveillanceProcessor - Error
processing surveillance 264: java.lang.IndexOutOfBoundsException Index: 6,
Size: 3
java.lang.IndexOutOfBoundsException: Index: 6, Size: 3
    at java.util.ArrayList.RangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at com.google.ical.values.IcalSchema.applyContentSchema(IcalSchema.java:108)
    at com.google.ical.values.RRuleSchema$4.apply(RRuleSchema.java:158)
    at com.google.ical.values.IcalSchema.applyContentSchema(IcalSchema.java:101)
    at com.google.ical.values.RRuleSchema$1.apply(RRuleSchema.java:81)
    at com.google.ical.values.IcalSchema.applyObjectSchema(IcalSchema.java:117)
    at com.google.ical.values.AbstractIcalObject.parse(AbstractIcalObject.java:82)
    at com.google.ical.values.RRule.<init>(RRule.java:52)
    at
com.google.ical.iter.RecurrenceIteratorFactory.parseContentLines(RecurrenceItera
torFactory.java:451)
    at
com.google.ical.iter.RecurrenceIteratorFactory.createRecurrenceIterable(Recurren
ceIteratorFactory.java:93)
    at
com.google.ical.compat.jodatime.LocalDateIteratorFactory.createLocalDateIterable
(LocalDateIteratorFactory.java:83)
    at
com.google.ical.compat.jodatime.LocalDateIteratorFactory.createLocalDateIterable
(LocalDateIteratorFactory.java:100)

This exception doesn't happen every time and it is not clear under which
conditions it happens.

I fear that google-rfc-2445 is NOT thread safe. A look at the class
com.google.ical.values.IcalSchema has confirmed my fears.

Original issue reported on code.google.com by [email protected] on 13 Feb 2008 at 1:19

RecurrenceIteratorFactory.except doesn't honor its contract

A simple JUnit test is needed to reproduce the bug.



public void testExcept() throws Exception 
{
  RecurrenceIterator rrule 
         = RecurrenceIteratorFactory
                  .createRecurrenceIterator(
                                  "RRULE:FREQ=WEEKLY;INTERVAL=3;COUNT=5",
                                  new DateValueImpl(2009, 02, 02), 
                                  GMT1);
  StringBuilder sb = createRecuranceDateString(rrule);

  // test succeed
  assertEquals("20090202,20090223,20090316,20090406,20090427", 
                                   sb.toString());

  RecurrenceIterator rdate 
         = RecurrenceIteratorFactory
                  .createRecurrenceIterator(
                                  "RDATE;VALUE=DATE:20090316", 
                                  new DateValueImpl(2009, 03, 16), 
                                  GMT1);

  sb = createRecuranceDateString(rdate);

  //test succeed
  assertEquals("20090316", sb.toString());

  RecurrenceIterator rdateExcept 
                = RecurrenceIteratorFactory.except(rrule, rdate);

  sb = createRecuranceDateString(rdateExcept);

  //test FAILED !! 
  assertEquals("20090202,20090223,20090406,20090427", sb.toString());
}


The last assert returns: 
   junit.framework.ComparisonFailure: 
      expected:<20090202,20090223,20090406,20090427> 
      but was:<>


Thanks for this excellent project,

Regards


Yanick.

Original issue reported on code.google.com by [email protected] on 18 Feb 2009 at 11:15

Custom timezones handling

iCalendars often contain custom Timezone definitions (VTIMEZONE) which are not 
matching standard timezone names. In such a case the library will, wrongly, 
throw a 'bad parameter' exception.

The attached file is a test case.
In that file, parsing
EXDATE;TZID="Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna":20101216T10000
... will cause an exception

The library should handle custom timezones, but will presumably need a more 
richer  implementation than java.util.TimeZone: for example JodaTime's 
DateTimeZone which can be build dynamically by DateTimeZoneBuilder.


Original issue reported on code.google.com by [email protected] on 12 Jan 2011 at 8:53

Attachments:

UNTIL date should be inclusive

What steps will reproduce the problem?
Iterate over RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20110121
with start java.util.Date set to Mon Jan 17 11:00:00 CET 2011

What is the expected output? What do you see instead?
Expected output:
    1: Mon Jan 17 11:00:00 CET 2011
    2: Tue Jan 18 11:00:00 CET 2011
    3: Wed Jan 19 11:00:00 CET 2011
    4: Thu Jan 20 11:00:00 CET 2011
    5: Fri Jan 21 11:00:00 CET 2011
Total: 5 instances
Actual output:
    1: Mon Jan 17 11:00:00 CET 2011
    2: Tue Jan 18 11:00:00 CET 2011
    3: Wed Jan 19 11:00:00 CET 2011
    4: Thu Jan 20 11:00:00 CET 2011
Total: 4 instances

What version of the product are you using? On what operating system?
1.0.31, Windows XP, rfc2445-no-joda.jar

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 17 Jan 2011 at 1:49

RRULE does not honor UNTIL setting

What steps will reproduce the problem?

DTSTART:20070501T090000
RRULE:FREQ=DAILY;UNTIL=20070506T000000Z

Then call:
  RecurrenceIteratorFactory.createRecurrenceIterator 


What is the expected output? What do you see instead?

I should get just 5 days back.

The iterator does not seem to end (I break out of the loop
after 10000 dates).


What version of the product are you using? On what operating system?

Unknown.  Downloaded the jar from the website this week.


Please provide any additional information below.

I am using the RRULE functionality as a component of my Java-based
iCalendar library:

http://javacaltools.sourceforge.net

Original issue reported on code.google.com by [email protected] on 17 May 2007 at 5:26

Add Project to Maven Central

Would it be possible to add this project to Maven Central?

Original issue reported on code.google.com by mike.angstadt on 21 Sep 2014 at 9:46

GCalendar Recurrence string throws exception in RRule instantiation.

What steps will reproduce the problem?
1. Create a calendar entry in your google calendar with a never ending daily 
recurrence rule for each day.
2. Get the event data via the gdata.java-1.41.5 library and create a new RRule 
with the recurrence string of the created event.

What is the expected output? What do you see instead?
Expected: A RRule instance.

Here is my recurrence rule string:

DTSTART;TZID=Europe/Zurich:20100930T183000
DTEND;TZID=Europe/Zurich:20100930T193000
RRULE:FREQ=DAILY;UNTIL=20101005T163000Z
BEGIN:VTIMEZONE
TZID:Europe/Zurich
X-LIC-LOCATION:Europe/Zurich
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE

And here the thrown exception:

java.text.ParseException: cannot parse content line 
[[DTSTART;TZID=Europe/Zurich:20100930T183000
DTEND;TZID=Europe/Zurich:20100930T193000
RRULE:FREQ=DAILY
BEGIN:VTIMEZONE
TZID:Europe/Zurich
X-LIC-LOCATION:Europe/Zurich
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE]] in []
    at com.google.ical.values.IcalSchema.badContent(IcalSchema.java:164)
    at com.google.ical.values.AbstractIcalObject.parse(AbstractIcalObject.java:58)
    at com.google.ical.values.RRule.<init>(RRule.java:52)


What version of the product are you using? On what operating system?
I checked out the sources yesterday.

Original issue reported on code.google.com by [email protected] on 1 Oct 2010 at 8:36

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.