Module: CalendarAssistant::CLI::Helpers
- Defined in:
- lib/calendar_assistant/cli/helpers.rb
Defined Under Namespace
Classes: ChronicParseException
Class Method Summary
collapse
Class Method Details
.find_av_uri(ca, timespec) ⇒ Object
.now ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/calendar_assistant/cli/helpers.rb', line 26
def self.now
CalendarAssistant::Event.new(
Google::Apis::CalendarV3::Event.new(start: Google::Apis::CalendarV3::EventDateTime.new(date_time: Time.now),
end: Google::Apis::CalendarV3::EventDateTime.new(date_time: Time.now),
summary: Rainbow(" now ").inverse.faint)
)
end
|
.parse_datespec(userspec) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/calendar_assistant/cli/helpers.rb', line 8
def self.parse_datespec(userspec)
start_userspec, end_userspec = userspec.split(/ ?\.\.\.? ?/)
if end_userspec.nil?
time = Chronic.parse(userspec) || raise(ChronicParseException, "could not parse '#{userspec}'")
return time.beginning_of_day..time.end_of_day
end
start_time = Chronic.parse(start_userspec) || raise(ChronicParseException, "could not parse '#{start_userspec}'")
end_time = Chronic.parse(end_userspec) || raise(ChronicParseException, "could not parse '#{end_userspec}'")
if start_time.to_date == end_time.to_date
start_time..end_time
else
start_time.beginning_of_day..end_time.end_of_day
end
end
|