lib/date_time_extensions.rb in transient-1.1.0 vs lib/date_time_extensions.rb in transient-2.0.0
- old
+ new
@@ -1,6 +1,7 @@
class DateTime
+
def self.beginning_of
DateTime.parse( "0000-01-01T00:00:00+00:00" )
end
def self.end_of
@@ -12,13 +13,15 @@
end
def to_standard_s
return time? ? strftime( "%B %d, %Y %I:%M %p" ) : to_date.to_standard_s
end
+
end
class Date
+
def self.beginning_of
DateTime.beginning_of.to_date
end
def self.end_of
@@ -30,16 +33,19 @@
end
def to_standard_s
strftime( "%B %d, %Y" )
end
+
end
class Time
+
def time?
return !(hour == 0 && min == 0 && sec == 0)
end
def to_standard_s
return time? ? to_datetime.to_standard_s : to_date.to_standard_s
end
-end
\ No newline at end of file
+
+end