simple_calendar 1.1.5 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f7a64081a152d2de429dcccfa3fc41f87cf8653
4
- data.tar.gz: 750684fef64d82960c570d366190e6641c0c96ce
3
+ metadata.gz: 1111d9baa8fca2e69d5e1891e1df353a6725e703
4
+ data.tar.gz: acc48d21cb13b6596b2981161d8104a05e176b49
5
5
  SHA512:
6
- metadata.gz: b0a9596ed759fb06e21f9f5ce0614e8d446533869f034873b0328ab111df54aa28d820b9a127ac30bbc4576503a1c833a4e18b08641b81335fe312f0b1b3811b
7
- data.tar.gz: 60c46c14dc99e633a591e2a54062b3bb2c6c72dc1af6bafa2f172723234f9744407498e88b13faa98a716aa17be972957efd8ff554d72037c8574afcd167a6fa
6
+ metadata.gz: 6a9501ebb265c7721b7fea63d3dff1a979444800a2b82119696ada6fc4e43287889b522df95b859f6da6ef2fa5283901f1f7bad007c2c6a09084447c9e7bd4eb
7
+ data.tar.gz: 4bd2cd2f82f5ab03d12fdd363b672ab1918fded1fe6d82f70a28732977136cb2978f54a82ed1f6810d3325b7ec0bfa3f6693d1db2d76bc51393602bfaa899144
data/README.md CHANGED
@@ -66,25 +66,25 @@ Setting `number_of_days` is optional and defaults to 4.
66
66
 
67
67
  ## Rendering Events
68
68
 
69
- What's a calendar without events in it? There are two simple steps for
70
- creating calendars with events.
69
+ What's a calendar without events in it? There are two simple steps for creating
70
+ calendars with events.
71
71
 
72
72
  The first step is to add the following to your model. We'll be using a
73
- model called Event, but you can add this to any model or Ruby object.
73
+ model called Meeting, but you can add this to any model or Ruby object.
74
74
 
75
75
  Here's an example model:
76
76
 
77
77
  ```bash
78
- rails g scaffold Event name starts_at:datetime
78
+ rails g scaffold Meeting name starts_at:datetime
79
79
  ```
80
80
 
81
81
  We use the `has_calendar` method to tell simple_calendar how to filter
82
- and sort the events on the different calendar days. This should be the
83
- start date/time of your event. By default it uses `starts_at` as the
82
+ and sort the meetings on the different calendar days. This should be the
83
+ start date/time of your meeting. By default it uses `starts_at` as the
84
84
  attribute name.
85
85
 
86
86
  ```ruby
87
- class Event < ActiveRecord::Base
87
+ class Meeting < ActiveRecord::Base
88
88
  extend SimpleCalendar
89
89
  has_calendar
90
90
 
@@ -93,32 +93,32 @@ class Event < ActiveRecord::Base
93
93
  end
94
94
  ```
95
95
 
96
- In your controller, query for these events and store them in an instance
97
- variable. We'll just load up all the events for this example.
96
+ In your controller, query for these meetings and store them in an instance
97
+ variable. We'll just load up all the meetings for this example.
98
98
 
99
99
  ```ruby
100
100
  def index
101
- @events = Event.all
101
+ @meetings = Meeting.all
102
102
  end
103
103
  ```
104
104
 
105
105
  Then in your view, you can pass in the `events` option to render. The
106
- events will automatically be filtered out by day for you.
106
+ meetings will automatically be filtered out by day for you.
107
107
 
108
108
  ```erb
109
- <%= month_calendar events: @events do |date, events| %>
109
+ <%= month_calendar events: @meetings do |date, meetings| %>
110
110
  <%= date %>
111
111
 
112
- <% events.each do |event| %>
112
+ <% meetings.each do |meeting| %>
113
113
  <div>
114
- <%= event.name %>
114
+ <%= meeting.name %>
115
115
  </div>
116
116
  <% end %>
117
117
  <% end %>
118
118
  ```
119
119
 
120
120
  If you pass in objects that don't respond to the attribute method (like
121
- starts_at), then all the events will be yielded each day. This lets you
121
+ starts_at), then all the meetings will be yielded each day. This lets you
122
122
  do custom filtering however you want.
123
123
 
124
124
  ## Customizing The Calendar
@@ -151,6 +151,13 @@ class ApplicationController < ActionController::Base
151
151
  end
152
152
  end
153
153
  ```
154
+ On the other hand, you can always pass a ``ActiveSupport::TimeZone`` object as an option to avoid possible timezone pollution:
155
+
156
+ ```erb
157
+ <%= calendar timezone: ActiveSupport::TimeZone.new('Taipei') do |date, events| %>
158
+ <% end %>
159
+ ```
160
+
154
161
  If you want to set the time zone globally, you can set the following in
155
162
  `config/application.rb`:
156
163
 
@@ -7,6 +7,7 @@ module SimpleCalendar
7
7
  def initialize(view_context, opts={})
8
8
  @view_context = view_context
9
9
  @events = opts.delete(:events) { [] }
10
+ @timezone = opts.fetch(:timezone, Time.zone)
10
11
 
11
12
  opts.reverse_merge!(
12
13
  header: {class: "calendar-header"},
@@ -72,7 +73,7 @@ module SimpleCalendar
72
73
  def events_for_date(current_date)
73
74
  if events.any? && events.first.respond_to?(:simple_calendar_start_time)
74
75
  events.select do |e|
75
- current_date == e.send(:simple_calendar_start_time).to_date
76
+ current_date == @timezone.utc_to_local(e.send(:simple_calendar_start_time)).to_date
76
77
  end.sort_by(&:simple_calendar_start_time)
77
78
  else
78
79
  events
@@ -1,3 +1,3 @@
1
1
  module SimpleCalendar
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-12 00:00:00.000000000 Z
11
+ date: 2014-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails