Coder Social home page Coder Social logo

icalendar's Introduction

VObject

Parse and manipulate iCalendar (RFC5545) and vCard objects (RFC6350). Parameter escaping follows (RFC6868).

Implementation is feature complete and standards-conformant.

Usage

string = ~s"""
BEGIN:VEVENT
DTSTART:20170419T091500Z
DTEND:20170419T102500Z
UID:00U5E000001JfN7UAK
DESCRIPTION:some HTML in here
LOCATION:here
STATUS:CONFIRMED
SUMMARY:test reminder2
RDATE;VALUE=PERIOD:19960403T020000Z/19960403T040000Z,
19960404T010000Z/PT3H
END:VEVENT
"""

{:ok, event} = ICalendar.decode(string)

# event
%{
  __type__: :event,
  description: {"some HTML in here", %{}, :text},
  dtend: {#DateTime<2017-04-19 10:25:00Z>, %{}, :date_time},
  dtstart: {#DateTime<2017-04-19 09:15:00Z>, %{}, :date_time},
  location: {"here", %{}, :text},
  rdate: {[
     %Timex.Interval{
       from: ~N[1996-04-03 02:00:00],
       left_open: false,
       right_open: true,
       step: [days: 1],
       until: ~N[1996-04-03 04:00:00]
     },
     %Timex.Interval{
       from: ~N[1996-04-04 01:00:00],
       left_open: false,
       right_open: true,
       step: [days: 1],
       until: ~N[1996-04-04 04:00:00]
     }
   ], %{}, :period},
  status: {"CONFIRMED", %{}, :text},
  summary: {"test reminder2", %{}, :text},
  uid: {"00U5E000001JfN7UAK", %{}, :text}
}

ICalendar.encode(event)

Is it fast?

Yes

# Benchmarking with test/fixtures/blank_description.ics
Benchmarking decode...
Benchmarking encode...

Name             ips        average  deviation         median         99th %
encode        8.40 K      119.03 μs    ±17.19%         111 μs         196 μs
decode        1.67 K      598.95 μs    ±18.65%         574 μs        1072 μs

Comparison:
encode        8.40 K
decode        1.67 K - 5.03x slower

TODO

  • RFC 7986 - New Properties for iCalendar

  • RFC 7265 - jCal

  • RFC 6321 - xCal

  • RFC 6350 - vCard (4.0) (todo: vCard 3)

    • RFC 6351 - xCard
    • RFC 7095 - jCard

Special Thanks

@lpil for the original icalendar library which I used as a starting point for the rewrite.

@johnhamelink & @walter for the RRule module implementation.

Mozilla's iCal.js which served as an inspiration for parts of the parser.

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.