rhodes 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +4 -1
- data/generators/rhogen.rb +40 -35
- data/generators/templates/application/index.erb +11 -0
- data/generators/templates/application/layout.erb +17 -0
- data/generators/templates/model/controller.rb +4 -4
- data/lib/builtinME.rb +63 -2
- data/lib/date/format.rb +8 -4
- data/lib/date.rb +25 -14
- data/lib/rationalME.rb +530 -0
- data/lib/rho/render.rb +46 -13
- data/lib/rho/rho.rb +26 -0
- data/lib/rho/rhocontroller.rb +14 -23
- data/lib/rho/rhoviewhelpers.rb +45 -0
- data/lib/rhodes.rb +1 -1
- data/lib/time.rb +4 -1
- data/spec/app_generator_spec.rb +9 -9
- metadata +6 -3
- data/generators/templates/application/index.html +0 -25
data/Manifest.txt
CHANGED
@@ -6,7 +6,8 @@ Rakefile
|
|
6
6
|
bin/rhogen
|
7
7
|
generators/rhogen.rb
|
8
8
|
generators/templates/application/application.rb
|
9
|
-
generators/templates/application/index.
|
9
|
+
generators/templates/application/index.erb
|
10
|
+
generators/templates/application/layout.erb
|
10
11
|
generators/templates/model/config.rb
|
11
12
|
generators/templates/model/controller.rb
|
12
13
|
generators/templates/model/edit.erb
|
@@ -21,6 +22,7 @@ lib/date/format.rb
|
|
21
22
|
lib/erb.rb
|
22
23
|
lib/find.rb
|
23
24
|
lib/rational.rb
|
25
|
+
lib/rationalME.rb
|
24
26
|
lib/rho.rb
|
25
27
|
lib/rho/render.rb
|
26
28
|
lib/rho/rho.rb
|
@@ -29,6 +31,7 @@ lib/rho/rhocontact.rb
|
|
29
31
|
lib/rho/rhocontroller.rb
|
30
32
|
lib/rho/rhofsconnector.rb
|
31
33
|
lib/rho/rhosupport.rb
|
34
|
+
lib/rho/rhoviewhelpers.rb
|
32
35
|
lib/rho/settings_controller.rb
|
33
36
|
lib/rhodes.rb
|
34
37
|
lib/rhoframework.rb
|
data/generators/rhogen.rb
CHANGED
@@ -2,119 +2,124 @@ require 'rubygems'
|
|
2
2
|
require 'templater'
|
3
3
|
|
4
4
|
module Rhogen
|
5
|
-
|
5
|
+
|
6
6
|
extend Templater::Manifold
|
7
|
-
|
7
|
+
|
8
8
|
desc <<-DESC
|
9
9
|
Generate rhodes application
|
10
10
|
DESC
|
11
|
-
|
11
|
+
|
12
12
|
class BaseGenerator < Templater::Generator
|
13
13
|
def class_name
|
14
14
|
name.gsub('-', '_').camel_case
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
alias_method :module_name, :class_name
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
class AppGenerator < BaseGenerator
|
21
|
-
|
21
|
+
|
22
22
|
def self.source_root
|
23
23
|
File.join(File.dirname(__FILE__), 'templates', 'application')
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
desc <<-DESC
|
27
27
|
Generates a new rhodes application. This will create a new directory with two files:
|
28
28
|
application.rb and index.html
|
29
29
|
DESC
|
30
|
-
|
30
|
+
|
31
31
|
#option :testing_framework, :desc => 'Specify which testing framework to use (spec, test_unit)'
|
32
|
-
|
32
|
+
|
33
33
|
first_argument :name, :required => true, :desc => "application name"
|
34
|
-
|
34
|
+
|
35
35
|
template :application do |template|
|
36
36
|
template.source = 'application.rb'
|
37
37
|
template.destination = "#{name}/application.rb"
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
template :index do |template|
|
41
|
-
template.source = 'index.
|
42
|
-
template.destination = "#{name}/index.
|
41
|
+
template.source = 'index.erb'
|
42
|
+
template.destination = "#{name}/index.erb"
|
43
|
+
end
|
44
|
+
|
45
|
+
template :layout do |template|
|
46
|
+
template.source = 'layout.erb'
|
47
|
+
template.destination = "#{name}/layout.erb"
|
43
48
|
end
|
44
|
-
|
49
|
+
|
45
50
|
end
|
46
|
-
|
51
|
+
|
47
52
|
class ModelGenerator < BaseGenerator
|
48
|
-
|
53
|
+
|
49
54
|
def self.source_root
|
50
55
|
File.join(File.dirname(__FILE__), 'templates', 'model')
|
51
56
|
end
|
52
|
-
|
57
|
+
|
53
58
|
desc <<-DESC
|
54
|
-
Generates a new model for a given source. You must specify name, source_url, and source_id.
|
59
|
+
Generates a new model for a given source. You must specify name, source_url, and source_id.
|
55
60
|
You can also specify an optional attribute list in the form: 'attribute1', 'attribute2', 'attribute3'...
|
56
61
|
DESC
|
57
|
-
|
62
|
+
|
58
63
|
#option :testing_framework, :desc => 'Specify which testing framework to use (spec, test_unit)'
|
59
|
-
|
64
|
+
|
60
65
|
first_argument :name, :required => true, :desc => "model name"
|
61
66
|
second_argument :source_url, :required => true, :desc => "source url"
|
62
67
|
third_argument :source_id, :required => true, :desc => "source id"
|
63
68
|
fourth_argument :attributes, :as => :array, :default => [], :required => false, :desc => "array of attributes (only string suppported right now)"
|
64
|
-
|
69
|
+
|
65
70
|
template :config do |template|
|
66
71
|
template.source = 'config.rb'
|
67
72
|
template.destination = "#{name.camel_case}/config.rb"
|
68
73
|
end
|
69
|
-
|
74
|
+
|
70
75
|
template :index do |template|
|
71
76
|
template.source = 'index.erb'
|
72
77
|
template.destination = "#{name.camel_case}/index.erb"
|
73
78
|
end
|
74
|
-
|
79
|
+
|
75
80
|
template :edit do |template|
|
76
81
|
template.source = 'edit.erb'
|
77
82
|
template.destination = "#{name.camel_case}/edit.erb"
|
78
83
|
end
|
79
|
-
|
84
|
+
|
80
85
|
template :new do |template|
|
81
86
|
template.source = 'new.erb'
|
82
87
|
template.destination = "#{name.camel_case}/new.erb"
|
83
88
|
end
|
84
|
-
|
89
|
+
|
85
90
|
template :controller do |template|
|
86
91
|
template.source = 'controller.rb'
|
87
92
|
template.destination = "#{name.camel_case}/controller.rb"
|
88
93
|
end
|
89
|
-
|
94
|
+
|
90
95
|
def attributes?
|
91
96
|
self.attributes && !self.attributes.empty?
|
92
97
|
end
|
93
|
-
|
98
|
+
|
94
99
|
end
|
95
|
-
|
100
|
+
|
96
101
|
class SourceGenerator < BaseGenerator
|
97
102
|
def self.source_root
|
98
103
|
File.join(File.dirname(__FILE__), 'templates', 'source')
|
99
104
|
end
|
100
|
-
|
105
|
+
|
101
106
|
desc <<-DESC
|
102
|
-
Generates a new source adapter with the given name and attributes. You must specify name.
|
107
|
+
Generates a new source adapter with the given name and attributes. You must specify name.
|
103
108
|
You can also specify an optional attribute list in the form: 'attribute1', 'attribute2', 'attribute3'...
|
104
109
|
DESC
|
105
|
-
|
110
|
+
|
106
111
|
first_argument :name, :required => true, :desc => "model name"
|
107
112
|
second_argument :attributes, :as => :array, :default => [], :required => false, :desc => "array of attributes (only string suppported right now)"
|
108
|
-
|
113
|
+
|
109
114
|
template :config do |template|
|
110
115
|
template.source = 'source_adapter.rb'
|
111
116
|
template.destination = "lib/#{name.snake_case}.rb"
|
112
117
|
end
|
113
|
-
|
118
|
+
|
114
119
|
end
|
115
|
-
|
120
|
+
|
116
121
|
add :app, AppGenerator
|
117
122
|
add :model, ModelGenerator
|
118
123
|
add :source, SourceGenerator
|
119
|
-
|
124
|
+
|
120
125
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class="toolbar">
|
2
|
+
<h1 id="pageTitle">
|
3
|
+
<script language="JavaScript">
|
4
|
+
document.write(document.title)
|
5
|
+
</script>
|
6
|
+
</h1>
|
7
|
+
<a id="backButton" class="button" href="./"></a>
|
8
|
+
</div>
|
9
|
+
<ul id="home" selected="true" title="<%= class_name %>">
|
10
|
+
<li>Something interesting here...</li>
|
11
|
+
</ul>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
4
|
+
<head>
|
5
|
+
<title><%= class_name %></title>
|
6
|
+
<% if System::get_property('platform') == 'APPLE' %>
|
7
|
+
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
|
8
|
+
<style type="text/css" media="screen">@import "/shared/js/iui/iui.css"; @import "/shared/css/rho.css";</style>
|
9
|
+
<script type="application/x-javascript" src="/shared/js/iui/iui.js"></script>
|
10
|
+
<script src="/shared/js/jquery-1.2.6.min.js"></script>
|
11
|
+
<script src="/shared/js/rho.js"></script>
|
12
|
+
<% end %>
|
13
|
+
</head>
|
14
|
+
<body>
|
15
|
+
<%= @content %>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'rho/rhocontroller'
|
2
2
|
|
3
3
|
class <%= class_name %>Controller < Rho::RhoController
|
4
|
-
|
4
|
+
|
5
5
|
#GET /<%= class_name %>
|
6
6
|
def index
|
7
7
|
@<%= name.pluralize %> = <%= class_name %>.find(:all)
|
8
|
-
render
|
8
|
+
render
|
9
9
|
end
|
10
10
|
|
11
11
|
# GET /<%= class_name %>/1
|
@@ -16,13 +16,13 @@ class <%= class_name %>Controller < Rho::RhoController
|
|
16
16
|
# GET /<%= class_name %>/new
|
17
17
|
def new
|
18
18
|
@<%= name %> = <%= class_name %>.new
|
19
|
-
render :new
|
19
|
+
render :action => :new
|
20
20
|
end
|
21
21
|
|
22
22
|
# GET /<%= class_name %>/1/edit
|
23
23
|
def edit
|
24
24
|
@<%= name %> = <%= class_name %>.find(@params['id'])
|
25
|
-
render :edit
|
25
|
+
render :action => :edit
|
26
26
|
end
|
27
27
|
|
28
28
|
# POST /<%= class_name %>/create
|
data/lib/builtinME.rb
CHANGED
@@ -99,10 +99,38 @@ module Enumerable
|
|
99
99
|
|
100
100
|
alias map :collect
|
101
101
|
|
102
|
+
def max(&proc)
|
103
|
+
proc = lambda { |a, b| a <=> b } unless block_given?
|
104
|
+
max = nil
|
105
|
+
each {|obj| max = obj if max.nil? || proc.call(max, obj) < 0}
|
106
|
+
max
|
107
|
+
end
|
108
|
+
|
109
|
+
def min(&proc)
|
110
|
+
proc = lambda { |a, b| a <=> b } unless block_given?
|
111
|
+
min = nil
|
112
|
+
each {|obj| min = obj if min.nil? || proc.call(min, obj) > 0}
|
113
|
+
min
|
114
|
+
end
|
115
|
+
|
102
116
|
end
|
103
117
|
|
104
118
|
class Array
|
105
|
-
alias
|
119
|
+
alias reject! delete_if
|
120
|
+
|
121
|
+
def reject
|
122
|
+
a = []
|
123
|
+
each {|x|
|
124
|
+
if !yield x
|
125
|
+
a << x
|
126
|
+
end
|
127
|
+
}
|
128
|
+
a
|
129
|
+
end
|
130
|
+
|
131
|
+
def to_a
|
132
|
+
self
|
133
|
+
end
|
106
134
|
|
107
135
|
def join(sepString="")
|
108
136
|
return to_s if sepString.nil? || sepString == ""
|
@@ -116,6 +144,9 @@ class Array
|
|
116
144
|
end
|
117
145
|
|
118
146
|
alias map! collect!
|
147
|
+
alias size length
|
148
|
+
alias to_ary to_a
|
149
|
+
alias to_s inspect
|
119
150
|
|
120
151
|
def inspect
|
121
152
|
str = "["
|
@@ -129,7 +160,6 @@ class Array
|
|
129
160
|
}
|
130
161
|
str << "]"
|
131
162
|
end
|
132
|
-
alias to_s inspect
|
133
163
|
|
134
164
|
end
|
135
165
|
|
@@ -501,6 +531,37 @@ class String
|
|
501
531
|
def inspect
|
502
532
|
'"' + to_s + '"'
|
503
533
|
end
|
534
|
+
|
535
|
+
#from rubinius
|
536
|
+
# justify left = -1, center = 0, right = 1
|
537
|
+
def justify_string(width, str, justify)
|
538
|
+
return self if width <= length
|
539
|
+
pad = width - length
|
540
|
+
out = str.to_str * (pad / str.length)
|
541
|
+
out << str[0, pad - out.length] if out.length < pad
|
542
|
+
# Left justification
|
543
|
+
return self << out if justify == -1
|
544
|
+
# Right justification
|
545
|
+
return out << self if justify == 1
|
546
|
+
# and finially center
|
547
|
+
split = (width / 2) - (length / 2)
|
548
|
+
return out.insert(split-((width-length)%2), self)
|
549
|
+
end
|
550
|
+
|
551
|
+
#from rubinius
|
552
|
+
def rjust(width, str=" ")
|
553
|
+
justify_string(width, str, 1)
|
554
|
+
end
|
555
|
+
|
556
|
+
#from rubinius
|
557
|
+
def ljust(width, str=" ")
|
558
|
+
justify_string(width, str, -1)
|
559
|
+
end
|
560
|
+
|
561
|
+
#from rubinius
|
562
|
+
def center(width, str=" ")
|
563
|
+
justify_string(width, str, 0)
|
564
|
+
end
|
504
565
|
|
505
566
|
alias to_str to_s
|
506
567
|
alias size length
|
data/lib/date/format.rb
CHANGED
@@ -5,8 +5,12 @@ require 'rational'
|
|
5
5
|
|
6
6
|
class Date
|
7
7
|
|
8
|
+
#SECONDS_IN_DAY = 60*60*24
|
9
|
+
#SECONDS_IN_DAY = Rational(1, 86400)
|
10
|
+
|
8
11
|
module Format # :nodoc:
|
9
12
|
|
13
|
+
|
10
14
|
MONTHS = {
|
11
15
|
'january' => 1, 'february' => 2, 'march' => 3, 'april' => 4,
|
12
16
|
'may' => 5, 'june' => 6, 'july' => 7, 'august' => 8,
|
@@ -245,7 +249,7 @@ class Date
|
|
245
249
|
when 'e', 'Oe'; emit_a(mday, 2, f)
|
246
250
|
when 'F'
|
247
251
|
if m == '%F'
|
248
|
-
format('%.4d-%02d-%02d', year, mon, mday) # 4p
|
252
|
+
format('%.4d-%02d-%02d', year(), mon(), mday()) # 4p
|
249
253
|
else
|
250
254
|
emit_a(strftime('%Y-%m-%d'), 0, f)
|
251
255
|
end
|
@@ -277,11 +281,11 @@ class Date
|
|
277
281
|
when 'r'; emit_a(strftime('%I:%M:%S %p'), 0, f)
|
278
282
|
when 'S', 'OS'; emit_n(sec, 2, f)
|
279
283
|
when 's'
|
280
|
-
s = ((ajd - UNIX_EPOCH_IN_AJD) /
|
284
|
+
s = ((ajd - UNIX_EPOCH_IN_AJD) / Rational(1, 86400)).round
|
281
285
|
emit_sn(s, 1, f)
|
282
286
|
when 'T'
|
283
287
|
if m == '%T'
|
284
|
-
format('%02d:%02d:%02d', hour, min, sec) # 4p
|
288
|
+
format('%02d:%02d:%02d', hour(), min(), sec()) # 4p
|
285
289
|
else
|
286
290
|
emit_a(strftime('%H:%M:%S'), 0, f)
|
287
291
|
end
|
@@ -301,7 +305,7 @@ class Date
|
|
301
305
|
t = $1.size
|
302
306
|
sign = if offset < 0 then -1 else +1 end
|
303
307
|
fr = offset.abs
|
304
|
-
ss = fr.div(
|
308
|
+
ss = fr.div(Rational(1, 86400)) # 4p
|
305
309
|
hh, ss = ss.divmod(3600)
|
306
310
|
mm, ss = ss.divmod(60)
|
307
311
|
if t == 3
|
data/lib/date.rb
CHANGED
@@ -193,6 +193,10 @@
|
|
193
193
|
#
|
194
194
|
# puts secs_to_new_year()
|
195
195
|
|
196
|
+
if defined? RHO_ME
|
197
|
+
require 'rationalME'
|
198
|
+
end
|
199
|
+
|
196
200
|
require 'rational'
|
197
201
|
require 'date/format'
|
198
202
|
|
@@ -387,8 +391,8 @@ class Date
|
|
387
391
|
end
|
388
392
|
a = (y / 100.0).floor
|
389
393
|
b = 2 - a + (a / 4.0).floor
|
390
|
-
jd = (365.25 * (y + 4716)).floor +
|
391
|
-
(30.6001 * (m + 1)).floor +
|
394
|
+
jd = (365.25 * (y + 4716)).floor() +
|
395
|
+
(30.6001 * (m + 1)).floor() +
|
392
396
|
d + b - 1524
|
393
397
|
if jd < sg
|
394
398
|
jd -= b
|
@@ -499,7 +503,7 @@ class Date
|
|
499
503
|
# Returns the Astronomical Julian Day Number as a single
|
500
504
|
# numeric value.
|
501
505
|
def jd_to_ajd(jd, fr, of=0) jd + fr - of - 1.to_r/2 end # :nodoc:
|
502
|
-
|
506
|
+
|
503
507
|
# Convert a fractional day +fr+ to [hours, minutes, seconds,
|
504
508
|
# fraction_of_a_second]
|
505
509
|
def day_fraction_to_time(fr) # :nodoc:
|
@@ -1137,7 +1141,7 @@ class Date
|
|
1137
1141
|
#trv once :jd, :day_fraction, :mjd, :ld
|
1138
1142
|
|
1139
1143
|
# Get the date as a Civil Date, [year, month, day_of_month]
|
1140
|
-
def civil() jd_to_civil(jd, @sg) end # :nodoc:
|
1144
|
+
def civil() jd_to_civil(jd(), @sg) end # :nodoc:
|
1141
1145
|
|
1142
1146
|
# Get the date as an Ordinal Date, [year, day_of_year]
|
1143
1147
|
def ordinal() jd_to_ordinal(jd, @sg) end # :nodoc:
|
@@ -1393,7 +1397,7 @@ class Date
|
|
1393
1397
|
def next_year(n=1) self >> n * 12 end
|
1394
1398
|
def prev_year(n=1) self << n * 12 end
|
1395
1399
|
|
1396
|
-
require 'enumerator'
|
1400
|
+
#require 'enumerator'
|
1397
1401
|
|
1398
1402
|
# Step the current date forward +step+ days at a
|
1399
1403
|
# time (or backward, if +step+ is negative) until
|
@@ -1517,8 +1521,9 @@ class DateTime < Date
|
|
1517
1521
|
#
|
1518
1522
|
# All day/time values default to 0.
|
1519
1523
|
def self.jd(jd=0, h=0, min=0, s=0, of=0, sg=ITALY)
|
1524
|
+
fr = _valid_time?(h, min, s)
|
1520
1525
|
unless (jd = _valid_jd?(jd, sg)) &&
|
1521
|
-
(fr
|
1526
|
+
(fr)
|
1522
1527
|
raise ArgumentError, 'invalid date'
|
1523
1528
|
end
|
1524
1529
|
if String === of
|
@@ -1542,8 +1547,9 @@ class DateTime < Date
|
|
1542
1547
|
# +y+ defaults to -4712, and +d+ to 1; this is Julian Day Number
|
1543
1548
|
# day 0. The time values default to 0.
|
1544
1549
|
def self.ordinal(y=-4712, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
|
1550
|
+
fr = _valid_time?(h, min, s)
|
1545
1551
|
unless (jd = _valid_ordinal?(y, d, sg)) &&
|
1546
|
-
(fr
|
1552
|
+
(fr)
|
1547
1553
|
raise ArgumentError, 'invalid date'
|
1548
1554
|
end
|
1549
1555
|
if String === of
|
@@ -1567,8 +1573,9 @@ class DateTime < Date
|
|
1567
1573
|
# +y+ defaults to -4712, +m+ to 1, and +d+ to 1; this is Julian Day
|
1568
1574
|
# Number day 0. The time values default to 0.
|
1569
1575
|
def self.civil(y=-4712, m=1, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
|
1576
|
+
fr = _valid_time?(h, min, s)
|
1570
1577
|
unless (jd = _valid_civil?(y, m, d, sg)) &&
|
1571
|
-
(fr
|
1578
|
+
(fr)
|
1572
1579
|
raise ArgumentError, 'invalid date'
|
1573
1580
|
end
|
1574
1581
|
if String === of
|
@@ -1595,8 +1602,9 @@ class DateTime < Date
|
|
1595
1602
|
# Julian Day Number day 0.
|
1596
1603
|
# The time values default to 0.
|
1597
1604
|
def self.commercial(y=-4712, w=1, d=1, h=0, min=0, s=0, of=0, sg=ITALY)
|
1605
|
+
fr = _valid_time?(h, min, s)
|
1598
1606
|
unless (jd = _valid_commercial?(y, w, d, sg)) &&
|
1599
|
-
(fr
|
1607
|
+
(fr)
|
1600
1608
|
raise ArgumentError, 'invalid date'
|
1601
1609
|
end
|
1602
1610
|
if String === of
|
@@ -1606,8 +1614,9 @@ class DateTime < Date
|
|
1606
1614
|
end
|
1607
1615
|
|
1608
1616
|
def self.weeknum(y=-4712, w=0, d=1, f=0, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
|
1617
|
+
fr = _valid_time?(h, min, s)
|
1609
1618
|
unless (jd = _valid_weeknum?(y, w, d, f, sg)) &&
|
1610
|
-
(fr
|
1619
|
+
(fr)
|
1611
1620
|
raise ArgumentError, 'invalid date'
|
1612
1621
|
end
|
1613
1622
|
if String === of
|
@@ -1619,8 +1628,9 @@ class DateTime < Date
|
|
1619
1628
|
private_class_method :weeknum
|
1620
1629
|
|
1621
1630
|
def self.nth_kday(y=-4712, m=1, n=1, k=1, h=0, min=0, s=0, of=0, sg=ITALY) # :nodoc:
|
1631
|
+
fr = _valid_time?(h, min, s)
|
1622
1632
|
unless (jd = _valid_nth_kday?(y, m, n, k, sg)) &&
|
1623
|
-
(fr
|
1633
|
+
(fr)
|
1624
1634
|
raise ArgumentError, 'invalid date'
|
1625
1635
|
end
|
1626
1636
|
if String === of
|
@@ -1634,8 +1644,9 @@ class DateTime < Date
|
|
1634
1644
|
def self.new_by_frags(elem, sg) # :nodoc:
|
1635
1645
|
elem = rewrite_frags(elem)
|
1636
1646
|
elem = complete_frags(elem)
|
1647
|
+
fr = valid_time_frags?(elem)
|
1637
1648
|
unless (jd = valid_date_frags?(elem, sg)) &&
|
1638
|
-
(fr
|
1649
|
+
(fr)
|
1639
1650
|
raise ArgumentError, 'invalid date'
|
1640
1651
|
end
|
1641
1652
|
sf = (elem[:sec_fraction] || 0)
|
@@ -1732,8 +1743,8 @@ class Time
|
|
1732
1743
|
end
|
1733
1744
|
|
1734
1745
|
def to_datetime
|
1735
|
-
jd = DateTime.__send__(:civil_to_jd, year, mon, mday, DateTime::ITALY)
|
1736
|
-
fr = DateTime.__send__(:time_to_day_fraction, hour, min, [sec, 59].min) +
|
1746
|
+
jd = DateTime.__send__(:civil_to_jd, year(), mon(), mday(), DateTime::ITALY)
|
1747
|
+
fr = DateTime.__send__(:time_to_day_fraction, hour(), min(), [sec, 59].min) +
|
1737
1748
|
nsec.to_r/86400_000_000_000
|
1738
1749
|
of = utc_offset.to_r/86400
|
1739
1750
|
DateTime.new!(DateTime.__send__(:jd_to_ajd, jd, fr, of),
|