fossil 0.5.43 → 0.5.44
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.
- data/VERSION +1 -1
- data/fossil.gemspec +1 -1
- data/lib/sequel/fos_dates.rb +6 -0
- data/lib/sequel/model_patch.rb +11 -5
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.44
|
data/fossil.gemspec
CHANGED
data/lib/sequel/fos_dates.rb
CHANGED
@@ -107,6 +107,12 @@ end
|
|
107
107
|
class DateTime
|
108
108
|
include TimeFunctions
|
109
109
|
|
110
|
+
# using a date of 2000,1,1 is arbitrary
|
111
|
+
def self.from_fos_time(minutes)
|
112
|
+
minutes = 0 unless minutes
|
113
|
+
(Time.utc(2000, 1, 1) + minutes.minutes).to_datetime
|
114
|
+
end
|
115
|
+
|
110
116
|
# creates utc time from days and minutes
|
111
117
|
def self.from_fos_date_time(days, minutes)
|
112
118
|
days = 0 unless days
|
data/lib/sequel/model_patch.rb
CHANGED
@@ -244,7 +244,7 @@ class Sequel::Model
|
|
244
244
|
when :date
|
245
245
|
Date.from_fos_days(column_value) if column_value
|
246
246
|
when :time
|
247
|
-
|
247
|
+
DateTime.from_fos_time(column_value) if column_value
|
248
248
|
when :currency
|
249
249
|
# (column_value || 0).to_currency
|
250
250
|
number_to_currency((column_value || 0).to_f/100, :unit=>'', :precision=>2)
|
@@ -259,15 +259,21 @@ class Sequel::Model
|
|
259
259
|
end
|
260
260
|
|
261
261
|
method_view_name = method_name.to_s + "_view"
|
262
|
-
|
263
|
-
|
262
|
+
|
263
|
+
# view methods for time type
|
264
|
+
if type == :time
|
264
265
|
inst_def method_view_name do
|
265
266
|
value = send(method_name)
|
266
|
-
value.
|
267
|
+
value.strftime('%H:%M') if value
|
267
268
|
end
|
268
269
|
end
|
269
|
-
#
|
270
|
+
# view methods for date type
|
270
271
|
if type == :date
|
272
|
+
inst_def method_view_name do
|
273
|
+
value = send(method_name)
|
274
|
+
value.to_s if value
|
275
|
+
end
|
276
|
+
# extra view methods for date type
|
271
277
|
method_view_name = method_name.to_s + "_view_mdy"
|
272
278
|
# method that returns the column value as a Date in mdy format
|
273
279
|
inst_def method_view_name do
|