Git Product home page Git Product logo

date_and_time-samples's Introduction

A small project that uses JQuery datepicker, formtastic, event_calendar, validates_timeliness and chronic.

The issue I was trying to solve was how to integrate all these and allow users to choose a date and time easily.  IMHO that is
choose a date from a calendar, then choose the time from select boxes.  Because this is an event, a User nust also choose duration.


1.  JQuery - look at application.js....I changed the default Date format of the datepicker to YY-MM-DD.  Chronic can parse DD-MM-YY to a correct
date format for ActiveRecord, but I needed a way to validate user input.  My app uses YY-MM-DD format, so not an inconvenient trade off.

2.  Event_calendar
The event_calendar needs a start_at and end_at to create the calendar.
I take the start_at_date, start_at_hour, start_at_minute and am_pm attributes and parse a start_date from those values in the 
Event befor_save callback.  In the same method, I create the end_at by using rails some_integer.minutes.since self.start_at
I use the all_day flag.  As the has_event_calendar method has a before_save call in it, the date parsing I needed to create these dates was
failing.  I put the has_event_calendar below the before_save :date_parser call and then event_calendar can do its thing as it has a start_date.

3.  The rest is pretty straight forward...there are few extra date and time fields in the views/events/_form.html.erb so you can see how those look too.
4. No testing..I know.

date_and_time-samples's People

Contributors

tjobrien avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Forkers

jvang2003

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.