Coder Social home page Coder Social logo

perl-ics-tools's Introduction

Perl-ICS-Tools

Primitive Parser and Tools for Dealing With iCal Files

What this does

Takes input as raw ICS data and outputs a Hash Reference with nested arrays and hashes for events, reminders and other properties.

Nesting occurs at every "BEGIN" statement. Objects which are allowed to appear more than once according to the iCal specifications will be added as an array, other properties will be scalars. Simple example output converted to JSON:

{
   "VCALENDAR" : {
      "X-WR-CALDESC" : "Solid Waste and Recycling",
      "PRODID" : "Data::ICal 0.23",
      "X-PUBLISHED-TTL" : "1440",
      "METHOD" : "PUBLISH",
      "VERSION" : "2.0",
      "X-WR-CALNAME" : "<redacted address>, Ottawa, Ontario, Canada",
      "X-WR-TIMEZONE" : "America/Toronto",
      "VEVENT" : [
         {
            "SUMMARY" : "Garbage, blue bin, green bin, and yard trimmings",
            "DESCRIPTION" : "Garbage, blue bin, green bin, and yard trimmings",
            "UID" : "[email protected]",
            "DTSTART;VALUE=DATE" : "20200327"
         },
         {

            "SUMMARY" : "Black bin, green bin, and yard trimmings",
            "UID" : "[email protected]",
            "DESCRIPTION" : "Black bin, green bin, and yard trimmings",
            "DTSTART;VALUE=DATE" : "20201226"
         }
      ]
   }
}

Why it is primitive

Ideally, a proper parser would do a lot of other things:

  • Validate the the input
    • This module doesn't even know what to do if a line has neither a leading space or a colon.
    • It doesn't check proper syntax.
    • It doesn't check for required fields.
    • It doesn't check for illegal fields.
  • Encode as well as decode
  • Understand and handle property options (eg. DTSTART;VALUE=DATE)

Will you be improving these things?

Probably not anytime soon.

Validating input would require a greater awareness of the entire tree structure and a lot of rules for which properties are required or prohibited under which conditions.

I centralize all of my calendaring in Remind, so I don't have much need to encode as ICS. This would be relatively simple if I didn't do any validation here either, but not validating on export is a much more egregious omission.

I most created the repo because I wanted a simple tool to import events into my Remind calendar and ended up being quite satisfied with the recursive algorithm for writing arbitrary nesting structures.

perl-ics-tools's People

Contributors

johnmertz avatar

Watchers

James Cloos avatar  avatar

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.