Sha256: b00dd0406d895e0835432e403cf28c1bb2e00ced170bba7ba623fad8930f354c

Contents?: true

Size: 1.24 KB

Versions: 28

Compression:

Stored size: 1.24 KB

Contents

class Pyk::DateTime
  
  #Pyk::DateTime.end_of_day(date_object)
  def self.end_of_day(date_object)
    Date.new(date_object.year, date_object.month, date_object.day).to_time + 86340
  end
  
  #Pyk::Date.get_start_date_from_tag(tag, default_year=nil, default_month=nil)
  def self.get_start_date_from_tag(tag, default_year=nil, default_month=nil)
    if tag == "this_month"
      return Date.new(Time.now.strftime("%Y").to_i, Time.now.strftime("%m").to_i, 1).to_time
    elsif tag == "last_30"
      return (Date.today - 30).to_time
    elsif tag == "last_month"
      lm = (Time.now - 1.month)
      sdt = Date.new(lm.strftime("%Y").to_i, lm.strftime("%m").to_i, 1)
      return Date.new(lm.strftime("%Y").to_i, lm.strftime("%m").to_i, 1).to_time
    elsif tag == "last_7"
      return (Date.today - 7).to_time
    else
      return Date.new(default_year, default_month, 1).to_time
    end
  end
  
  #Pyk::Date.get_end_date_from_tag(tag)
  def self.get_end_date_from_tag(tag)
    if tag == "last_month"
      lm = (Time.now - 1.month)
      sdt = Date.new(lm.strftime("%Y").to_i, lm.strftime("%m").to_i, 1)
      ed = (sdt + 1.month - 1.day).to_time
    else #if tag == "this_month" or tag == "last_30" or tag == "last_7"
      return Time.now
    end
  end
  
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
pyk-0.3.2 lib/pyk/date_time.rb
pyk-0.3.1 lib/pyk/date_time.rb
pyk-0.3.0 lib/pyk/date_time.rb
pyk-0.2.9 lib/pyk/date_time.rb
pyk-0.2.8 lib/pyk/date_time.rb
pyk-0.2.7 lib/pyk/date_time.rb
pyk-0.2.6 lib/pyk/date_time.rb
pyk-0.2.5 lib/pyk/date_time.rb
pyk-0.2.3 lib/pyk/date_time.rb
pyk-0.2.2 lib/pyk/date_time.rb
pyk-0.2.1 lib/pyk/date_time.rb
pyk-0.2.0 lib/pyk/date_time.rb
pyk-0.1.9 lib/pyk/date_time.rb
pyk-0.1.8 lib/pyk/date_time.rb
pyk-0.1.6 lib/pyk/date_time.rb
pyk-0.1.5 lib/pyk/date_time.rb
pyk-0.1.4 lib/pyk/date_time.rb
pyk-0.1.3 lib/pyk/date_time.rb
pyk-0.1.2 lib/pyk/date_time.rb
pyk-0.1.1 lib/pyk/date_time.rb