Skip to content

Instantly share code, notes, and snippets.

@mihael
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihael/9f18e9d3d9521e455696 to your computer and use it in GitHub Desktop.
Save mihael/9f18e9d3d9521e455696 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'active_support/time'
require 'ice_cube'
#monthly on the 1st
rule = IceCube::Rule.monthly.day_of_month(1)
#UTC
utc_start = Time.new(2002, 10, 1, 4, 55, 0, "+00:00")
s_UTC = IceCube::Schedule.new(utc_start)
s_UTC.add_recurrence_rule(rule)
puts "UTC start: #{utc_start}, next_occurrence: #{s_UTC.next_occurrence(utc_start)}"
#GMT
gmt_start = Time.new(2002, 9, 30, 23, 55, 0, "-05:00")
s_GMT = IceCube::Schedule.new(gmt_start)
s_GMT.add_recurrence_rule(rule)
puts "GMT start: #{gmt_start}, next_occurrence: #{s_GMT.next_occurrence(gmt_start)}"
puts "GMT in UTC : #{gmt_start}.utc => #{gmt_start.utc}"
puts "UTC in GMT: #{utc_start}.in_time_zone() => #{utc_start.in_time_zone('EST')}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment