Giter VIP home page Giter VIP logo

tzurl's Introduction

iCal4j - iCalendar parser and object model

Table of Contents

  1. Introduction - What is iCal4j?
  2. Setup - Download and installation of iCal4j
  3. Usage - The iCal4j object model and how to use it
  4. References
  5. Configuration options
  6. Development - Guide for contributing to the iCalj project

Introduction

iCal4j is a Java library used to read and write iCalendar data streams as defined in RFC2445. The iCalendar standard provides a common data format used to store information about calendar-specific data such as events, appointments, to-do lists, etc. All of the popular calendaring tools, such as Lotus Notes, Outlook and Apple's iCal also support the iCalendar standard.

  • For a concise description of the goals and directions of iCal4j please take a look at the open issues.

  • You will find examples of how to use iCal4j in the official website and throughout the API documentation.

  • Detailed descriptions of changes included in each release may be found in the CHANGELOG.

  • iCal4j was created with the help of Open Source software.

Setup

System requirements

  • Version 4.x - Java 11 or later
  • Version 3.x - Java 8 or later
  • Version 2.x - Java 7 or later

Dependencies

In the interests of portability and compatibility with as many environments as possible, the number of dependent libraries for iCal4j is kept to a minimum. The following describes the required (and optional) dependencies and the functionality they provide.

  • slf4j-api [required] - A logging meta-library with integration to different logging framework implementations. Used in all classes that require logging.

  • commons-lang3 [required] - Provides enhancements to the standard Java library, including support for custom equals() and hashcode() implementations. Used in all classes requiring custom equality implementations.

  • commons-collections4 [required] - Provides enhancements to the standard Java collections API, including support for closures. Used in net.fortuna.ical4j.validate.Validator implementations to reduce the duplication of code in validity checks.

  • javax.cache.cache-api [optional*] - Supports caching timzeone definitions. * NOTE: when not included you must set a value for the net.fortuna.ical4j.timezone.cache.impl configuration

  • commons-codec [optional] - Provides support for encoding and decoding binary data in text form. Used in net.fortuna.ical4j.model.property.Attach

  • groovy-all [optional] - The runtime for the Groovy language. Required for library enhancements such as iCalendar object construction using the net.fortuna.ical4j.model.ContentBuilder DSL. This library is optional for all non-Groovy features of iCal4j.

  • bndlib [optional] - A tool for generating OSGi library metadata and packaging OSGi bundles. This library is not a runtime requirement, and is used only to generate version information in the javadoc API documentation.

Release Downloads

Install with Maven

Install with Gradle

Usage

iCal4j 4.x (new Java Date/Time API)

The following table provides a comparison between the old and the new date/time API for creating dates and date-based properties:

Description New API Old API
DTSTART with date value new DtStart<>(LocalDate.now()) new DtStart(new org.mnode.ical4j.model.Date())
DTSTART with date-time value new DtStart<>(ZoneDateTime.now()) new DtStart(new org.mnode.ical4j.model.DateTime())
DTSTART with specific timezone new DtStart<>(ZonedDateTime.now(tzReg.getTimeZone("Australia/Melbourne").toZoneId())); dtStart = new DtStart(new org.mnode.ical4j.model.DateTime()); dtStart.setTimeZone(tzReg.getTimeZone("Australia/Melbourne"));
Parse a DATE-TIME string TemporalAdapter.parse("20130101T120000Z") new org.mnode.ical4j.model.DateTime("20130101T120000Z")
Parse a DATE string TemporalAdapter.parse("20200229") new org.mnode.ical4j.model.Date("20200229")

You may also find the Java Legacy Date-Time Code web page useful.

iCal4j 3.x (old Java Date API)

Examples

References

  • RFC5545 - Internet Calendaring and Scheduling Core Object Specification (iCalendar)
  • RFC5546 - iCalendar Transport-Independent Interoperability Protocol (iTIP)
  • RFC6047 - iCalendar Message-Based Interoperability Protocol (iMIP)
  • RFC6868 - Parameter Value Encoding in iCalendar and vCard
  • RFC7953 - Calendar Availability
  • RFC7808 - Time Zone Data Distribution Service
  • RFC7986 - New Properties for iCalendar
  • RFC7529 - Non-Gregorian Recurrence Rules in iCalendar
  • RFC9073 - Event Publishing Extensions to iCalendar
  • RFC9074 - "VALARM" Extensions for iCalendar
  • RFC9253 - Support for iCalendar Relationships

Configuration

net.fortuna.ical4j.parser=net.fortuna.ical4j.data.HCalendarParserFactory

net.fortuna.ical4j.timezone.registry=net.fortuna.ical4j.model.DefaultTimeZoneRegistryFactory

net.fortuna.ical4j.timezone.update.enabled={true|false}

net.fortuna.ical4j.factory.decoder=net.fortuna.ical4j.util.DefaultDecoderFactory

net.fortuna.ical4j.factory.encoder=net.fortuna.ical4j.util.DefaultEncoderFactory

net.fortuna.ical4j.recur.maxincrementcount=1000

net.fortuna.ical4j.timezone.cache.impl=net.fortuna.ical4j.util.MapTimeZoneCache

Compatibility Hints

Relaxed Parsing

ical4j.parsing.relaxed={true|false}

iCal4j now has the capability to "relax" its parsing rules to enable parsing of *.ics files that don't properly conform to the iCalendar specification (RFC2445)

This property is intended as a general relaxation of parsing rules to allow for parsing otherwise invalid calendar files. Initially enabling this property will allow for the creation of properties and components with illegal names (e.g. Mozilla Calendar's "X" property). Note that although this will allow for parsing calendars with illegal names, validation will still identify such names as an error in the calendar model.

  • You can relax iCal4j's unfolding rules by specifying the following system property:

     ical4j.unfolding.relaxed={true|false}
    

Note that I believe this problem is not restricted to Mozilla calendaring products, but rather may be caused by UNIX/Linux-based applications relying on the default newline character (LF) to fold long lines (KOrganizer also seems to have this problem). This is, however, still incorrect as by definition long lines are folded using a (CRLF) combination.

I've obtained a couple of samples of non-standard iCalendar files that I've included in the latest release (0.9.11). There is a Sunbird, phpicalendar, and a KOrganizer sample there (open them in Notepad on Windows to see what I mean).

It seems that phpicalendar and KOrganizer always use LF instead of CRLF, and in addition KOrganizer seems to fold all property parameters and values (similar to Mozilla Calendar/Sunbird).

Mozilla Calendar/Sunbird uses CRLF to fold all property parameter/values, however it uses just LF to fold long lines (i.e. longer than 75 characters).

The latest release of iCal4j includes changes to UnfoldingReader that should work correctly with Mozilla Calendar/Sunbird, as long as the ical4j.unfolding.relaxed system property is set to true.

KOrganizer/phpicalendar files should also work with the relaxed property, although because ALL lines are separated with just LF it also relies on the StreamTokenizer to correctly identify LF as a newline on Windows, and CRLF as a newline on UNIX/Linux. The API documentation for Java 1.5 says that it does do this, so if you still see problems with parsing it could be a bug in the Java implementation.

The full set of system properties may be found in net.fortuna.ical4j.util.CompatibilityHints.

iCal4j and Timezones

iCal4j 4.x

iCal4j 4.x introduces support for the new Java Date/Time API. This is a major change to how dates are represented in iCal4j, as the following table outlines:

Description iCal4j 4.x iCal4j 3.x
3.3.4. Date TemporalAdapter<LocalDate> org.mnode.ical4j.model.Date
3.3.5. Date-Time
FORM #1: DATE WITH LOCAL TIME TemporalAdapter<LocalDateTime> org.mnode.ical4j.model.DateTime
FORM #2: DATE WITH UTC TIME TemporalAdapter<Instant> org.mnode.ical4j.model.DateTime
FORM #3: DATE WITH LOCAL TIME AND TIME ZONE REFERENCE TemporalAdapter<ZonedDateTime> org.mnode.ical4j.model.DateTime
3.3.6. Duration TemporalAmountAdapter org.mnode.ical4j.model.Dur
3.3.9. Period of Time Period<T extends Temporal> org.mnode.ical4j.model.Period
3.3.12. Time
FORM #1 LOCAL TIME TemporalAdapter<LocalTime> org.mnode.ical4j.model.Time
FORM #2: UTC TIME TemporalAdapter<Instant> org.mnode.ical4j.model.Time
FORM #3: LOCAL TIME AND TIME ZONE REFERENCE TemporalAdapter<OffsetTime> org.mnode.ical4j.model.Time
iCal4j 3.x
net.fortuna.ical4j.timezone.date.floating={true|false}

Supporting timezones in an iCalendar implementation can be a complicated process, mostly due to the fact that there is not a definitive list of timezone definitions used by all iCalendar implementations. This means that an iCalendar file may be produced by one implementation and, if the file does not include all definitions for timezones relevant to the calendar properties, an alternate implementation may not know how to interpret the timezone identified in the calendar (or worse, it may interpret the timezone differently to the original implementation). All of these possibilities mean unpredictable behaviour which, to put it nicely, is not desireable.

iCal4j approaches the problem of timezones in two ways: The first and by far the preferred approach is for iCalendar files to include definitions for all timezones referenced in the calendar object. To support this, when an existing calendar is parsed a list of VTimeZone definitions contained in the calendar is constructed. This list may then be queried whenever a VTimeZone definition is required.

The second approach is to rely on a registry of VTimeZone definitions. iCal4j includes a default registry of timezone definitions (derived from the Olson timezone database - a defacto standard for timezone definitions), or you may also provide your own registry implementation from which to retreieve timezones. This approach is required when constructing new iCalendar files.

Note that the intention of the iCal4j model is not to provide continuous validation feedback for every change in the model. For this reason you are free to change timezones on Time objects, remove or add TzId parameters, remove or add VTimeZone definitions, etc. without restriction. However when validation is run (automatically on output of the calendar) you will be notified if the changes are invalid.

Validation

ical4j.validation.relaxed={true|false}

Micosoft Outlook compatibility

ical4j.compatibility.outlook={true|false}

Behaviour:

  • Enforces a folding length of 75 characters (by default ical4j will fold at 73 characters)
  • Allows for spaces when parsing a WEEKDAY list

Microsoft Outlook also appears to provide quoted TZID parameter values, as follows:

DTSTART;TZID="Pacific Time (US & Canada),Tijuana":20041011T223000

Lotus Notes compatibility

ical4j.compatibility.notes={true|false}

Development

Building with Gradle

iCal4j includes the Gradle wrapper for a simpler and more consistent build.

Run unit tests

./gradlew clean test

Build a new release

./gradlew clean test release -Prelease.forceVersion=2.0.0

Upload release binaries and packages

RELEASE_VERSION=2.0.0 ./gradlew uploadArchives uploadDist

Redistribution

If you intend to use and distribute iCal4j in your own project please follow these very simple guidelines:

  • Make a copy of the LICENSE, rename it to LICENSE.ical4j, and save it to the directory where you are re-distributing the iCal4j JAR.

  • I don't recommend extracting the iCal4j classes from its JAR and package in another JAR along with other classes. It may lead to version incompatibilites in the future. Rather I would suggest to include the ical4j.jar in your classpath as required.

Contributing

Open source software is made stronger by the community that supports it. Through participation you not only contribute to the quality of the software, but also gain a deeper insight into the inner workings.

Contributions may be in the form of feature enhancements, bug fixes, test cases, documentation and forum participation. If you have a question, just ask. If you have an answer, write it down.

And if you are somehow constrained from participation, through corporate policy or otherwise, consider financial support. After all, if you are profiting from open source it's only fair to give something back to the community that make it all possible.

tzurl's People

Contributors

benfortuna avatar hubpan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tzurl's Issues

Create docker container for tzurl

Should support the following options:

  • download specified tzdata version and recompile
  • generate zoneinfo
  • sync to a location OR
  • serve zoneinfo using Apache

Africa/Casablanca timezone questions (probably incorrect?)

Hi,

I have some questions about the Africa/Casablanca timezone. First of all the 
outlook compatible one (http://tzurl.org/zoneinfo-outlook/Africa/Casablanca) 
seems to have a wrong TZOFFSETFROM at the DAYLIGHT timezone part. From my point 
of view the TZOFFSETFROM shoutld be +0000 and not +0100?

However, I have bigger concerns when I look at the none Outlook version 
(http://tzurl.org/zoneinfo/Africa/Casablanca) which I prefer to use at my 
products. 

1) Why does the following timezone start in the year 2026? From my point of 
view it should start at an earlier point in time? Whats your opinion? 
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0100
TZNAME:WEST
DTSTART:20260329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU

2)The other timezone parts, for my point of view, are also probably not 
completely correct. For example, a standard timezone with an rrule starts in 
the year 2013 (btw. why 2013? shouldn't the same rule also apply at years 
before 2013?):
BEGIN:STANDARD
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
TZNAME:WET
DTSTART:20131027T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU

But then there are also other standard timezones which start in 1939 BUT have 
RDATES until 2022 which are quite irregularly defined. Should the standard 
timezone really start on a different month each year? And why are there RDATES 
> 2013 defined when we already have a STANDARD Timezone with a rrule which 
starts in 2013? 
RDATE:20110731T000000
RDATE:20120720T030000
RDATE:20120930T030000
RDATE:20130707T030000
RDATE:20140628T030000
RDATE:20150613T030000
RDATE:20160604T030000
RDATE:20170520T030000
RDATE:20180512T030000
RDATE:20190504T030000
RDATE:20200418T030000

3) Similar questions arise in my mind when I investigate the DAYLIGHT 
timezones. E.g. why does the DAYLIGHT timezone with the rrule start in 2026? (I 
assume that also should start earlier) and also the RDATES show a similar 
unstable occurrence as it does at the example above.

Am I interpreting something wrong here? Please correct me if I do. 

Original issue reported on code.google.com by [email protected] on 26 Feb 2015 at 10:45

Why error 500 when trying go get America/Jamaica ?

What steps will reproduce the problem?
1. http://tzurl.org/zoneinfo/America/Jamaica.ics or
http://tzurl.org/zoneinfo/America/Jamaica/

What is the expected output? What do you see instead?
Maybe a 404 if not exist, but get a 500.

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

Please provide any additional information below.
none

Original issue reported on code.google.com by [email protected] on 22 Jun 2009 at 7:14

Missing URL

I would like to let you know the following URLS are not accessible:

/zoneinfo/America/Shiprock.ics
/zoneinfo/Australia/Broken_Hill.ics
/zoneinfo/Europe/Tirane.ics

Original issue reported on code.google.com by [email protected] on 23 Nov 2011 at 8:59

Failed to compile 2012f data

./vzic --olson-dir tzdatasrc
WARNING: Antarctica/Palmer: Modifying RRULE to be compatible with Outlook (day 
>= 9, month = 3)
WARNING: Antarctica/Palmer: Modifying RRULE to be compatible with Outlook (day 
>= 9, month = 10)
WARNING: Couldn't find a LETTER_S to use in FORMAT: CHO%sT in Zone: 
Asia/Choibalsan Leaving TZNAME empty
WARNING: Pacific/Fiji: Modifying RRULE to be compatible with Outlook (day >= 
18, month = 10)
ERROR: Pacific/Fiji: Couldn't modify RRULE to be compatible with Outlook (day 
>= 18, month = 10, ddd = 31)

Original issue reported on code.google.com by sviegres on 15 Oct 2012 at 9:44

Support SSL

SSL endpoint required to prevent mitm and other calendar attacks

Apparent copy-paste error in Europe/Amsterdam.ics

Hi,

since last monday, october 23rd, some of our tests have been failing. Apparently, a few TZNAME fields in Amsterdam.ics that used to have values like EST and NEST now contain values like +0120 and +0020. These values look like copies of the values in the TZOFFSETTO fields. I checked some other countries' ics files and those don't seem to have these changes.

I changed the ical4j.properties to contain net.fortuna.ical4j.timezone.update.enabled=false and now our tests use only our local copy of Amsterdam.ics, and no longer fail.

I thought that maybe you would like to know about this (apparent) issue.

Kind regards

Rob Velseboer

Brazil zones with DST have wrong TZOFFSETFROM

For America/Sao_Paulo, America/Campo_Grande, and America/Cuiaba the TZOFFSETFROM is the same as TZOFFSETTO for the standard component, e.g.:

BEGIN:STANDARD
TZOFFSETFROM:-0300
TZOFFSETTO:-0300
TZNAME:-03
DTSTART:19700215T000000

Europe/Moscow time zone is incorrectly generated

Hello!

Since 26 October 2014 Moscow is back to UTC+3 time zone. But http://tzurl.org/zoneinfo/Europe/Moscow.ics still contain +0400 as the last entry. So i think that time/zone database must be re-generated.

Olson/IANA time zone database already contain correct definition for Europe/Moscow time zone (checked using current version version 2017b at https://www.iana.org/time-zones/repository/releases/tzdb-2017b.tar.lz):

Zone Europe/Moscow       2:30:17 -      LMT     1880
                         2:30:17 -      MMT     1916 Jul  3 # Moscow Mean Time
                         2:31:19 Russia %s      1919 Jul  1  0:00u
                         3:00   Russia  %s      1921 Oct
                         3:00   Russia  MSK/MSD 1922 Oct
                         2:00   -       EET     1930 Jun 21
                         3:00   Russia  MSK/MSD 1991 Mar 31  2:00s
                         2:00   Russia  EE%sT   1992 Jan 19  2:00s
                         3:00   Russia  MSK/MSD 2011 Mar 27  2:00s
                         4:00   -       MSK     2014 Oct 26  2:00s
                         3:00   -       MSK

Container orchestration

Add orchestration configuration using docker-compose and rancher-compose.

  • load balancer: single instance attached to dedicated cluster node. For high availability can deploy on all nodes and include external load balancer

  • tzurl: single instance, scale on request count, load, etc.

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.