rails_pdate 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +18 -17
- data/README.rdoc +0 -0
- data/Rakefile +0 -0
- data/lib/core_date.rb +5 -1
- data/lib/core_date_time.rb +10 -0
- data/lib/core_string.rb +0 -0
- data/lib/rails_pdate.rb +6 -4
- data/lib/rails_pdate/base_date_time.rb +94 -0
- data/lib/rails_pdate/constants.rb +12 -8
- data/lib/rails_pdate/formats.rb +49 -0
- data/lib/rails_pdate/initializer.rb +5 -0
- data/lib/rails_pdate/p_date.rb +15 -74
- data/lib/rails_pdate/p_date_time.rb +49 -0
- data/lib/rails_pdate/pconvertor.rb +2 -0
- data/lib/rails_pdate/time_shifting.rb +76 -0
- data/lib/rails_pdate/version.rb +1 -1
- data/lib/tasks/rails_pdate_tasks.rake +0 -0
- data/test/comparisons_test.rb +34 -0
- data/test/core_date_test.rb +1 -0
- data/test/core_date_time_test.rb +21 -0
- data/test/core_string_test.rb +0 -0
- data/test/dummy/README.rdoc +0 -0
- data/test/dummy/Rakefile +0 -0
- data/test/dummy/app/assets/javascripts/application.js +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +0 -0
- data/test/dummy/app/controllers/application_controller.rb +0 -0
- data/test/dummy/app/helpers/application_helper.rb +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +0 -0
- data/test/dummy/config.ru +0 -0
- data/test/dummy/config/application.rb +0 -0
- data/test/dummy/config/boot.rb +1 -1
- data/test/dummy/config/database.yml +0 -0
- data/test/dummy/config/environment.rb +0 -0
- data/test/dummy/config/environments/development.rb +0 -0
- data/test/dummy/config/environments/production.rb +0 -0
- data/test/dummy/config/environments/test.rb +3 -1
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/test/dummy/config/initializers/inflections.rb +0 -0
- data/test/dummy/config/initializers/mime_types.rb +0 -0
- data/test/dummy/config/initializers/secret_token.rb +0 -0
- data/test/dummy/config/initializers/session_store.rb +0 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/test/dummy/config/locales/en.yml +0 -0
- data/test/dummy/config/routes.rb +0 -0
- data/test/dummy/log/test.log +22370 -80
- data/test/dummy/public/404.html +0 -0
- data/test/dummy/public/422.html +0 -0
- data/test/dummy/public/500.html +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/pconvertor_test.rb +0 -0
- data/test/rails_pdate_test.rb +28 -0
- data/test/rails_pdatetime_test.rb +15 -0
- data/test/test_helper.rb +0 -0
- data/test/time_shifting_test.rb +17 -0
- metadata +80 -81
data/test/dummy/public/404.html
CHANGED
File without changes
|
data/test/dummy/public/422.html
CHANGED
File without changes
|
data/test/dummy/public/500.html
CHANGED
File without changes
|
File without changes
|
data/test/pconvertor_test.rb
CHANGED
File without changes
|
data/test/rails_pdate_test.rb
CHANGED
@@ -62,6 +62,10 @@ class RailsPdateTest < ActiveSupport::TestCase
|
|
62
62
|
assert_equal PDate.new(1368, 11, 9).strftime("%e"), "9"
|
63
63
|
end
|
64
64
|
|
65
|
+
test "strftime format %A" do
|
66
|
+
assert_equal PDate.new(1394, 1, 1).strftime("%A"), "شنبه"
|
67
|
+
end
|
68
|
+
|
65
69
|
test "to_formatted_s method" do
|
66
70
|
assert_equal PDate.new(1368, 11, 9).to_s, "1368-11-09"
|
67
71
|
end
|
@@ -92,4 +96,28 @@ class RailsPdateTest < ActiveSupport::TestCase
|
|
92
96
|
assert_equal PDate.new(1368, 11, 9).inspect, "1368-11-09"
|
93
97
|
end
|
94
98
|
|
99
|
+
test "get day of year" do
|
100
|
+
assert_equal PDate.new(1394, 1, 1).yday, 1
|
101
|
+
assert_equal PDate.new(1394, 2, 1).yday, 32
|
102
|
+
assert_equal PDate.new(1377, 3, 4).yday, 66
|
103
|
+
assert_equal PDate.new(1368, 11, 9).yday, 315
|
104
|
+
end
|
105
|
+
|
106
|
+
test "get cwday" do
|
107
|
+
assert_equal PDate.new(1394, 1, 1).cwday, 1
|
108
|
+
assert_equal PDate.new(1394, 1, 2).cwday, 2
|
109
|
+
assert_equal PDate.new(1394, 1, 3).cwday, 3
|
110
|
+
assert_equal PDate.new(1394, 1, 4).cwday, 4
|
111
|
+
assert_equal PDate.new(1394, 1, 5).cwday, 5
|
112
|
+
assert_equal PDate.new(1394, 1, 6).cwday, 6
|
113
|
+
assert_equal PDate.new(1394, 1, 7).cwday, 7
|
114
|
+
end
|
115
|
+
|
116
|
+
test "get cweek" do
|
117
|
+
assert_equal PDate.new(1394, 1, 1).cweek, 1
|
118
|
+
assert_equal PDate.new(1394, 1, 7).cweek, 1
|
119
|
+
assert_equal PDate.new(1394, 1, 8).cweek, 2
|
120
|
+
assert_equal PDate.new(1394, 2, 1).cweek, 5
|
121
|
+
assert_equal PDate.new(1394, 12, 29).cweek, 53
|
122
|
+
end
|
95
123
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class RailsPdatetimeTest < ActiveSupport::TestCase
|
6
|
+
|
7
|
+
test "sample create persian date time object from samples" do
|
8
|
+
|
9
|
+
{
|
10
|
+
PDateTime.new(1368, 11, 9, 8, 10, 0).to_s => '1368-11-09 08:10'
|
11
|
+
}.each do |pdatetime, datetime|
|
12
|
+
assert_equal pdatetime, datetime
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/test/test_helper.rb
CHANGED
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
|
4
|
+
class TimeShiftingTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
test "time shifting" do
|
7
|
+
assert_equal "1368/11/09".to_pdate.beginning_of_year.to_a, [1368, 1, 1]
|
8
|
+
assert_equal "1368/11/09".to_pdate.beginning_of_month.to_a, [1368, 11, 1]
|
9
|
+
assert_equal "1394/05/11".to_pdate.beginning_of_week.to_a, [1394, 5, 10]
|
10
|
+
assert_equal "1394/02/02".to_pdate.beginning_of_week.to_a, [1394, 1, 29]
|
11
|
+
assert_equal "1393/01/01".to_pdate.beginning_of_week.to_a, [1392, 12, 24]
|
12
|
+
|
13
|
+
assert_equal "1368/11/09".to_pdate.end_of_year.to_a, [1368, 12, 29]
|
14
|
+
assert_equal "1368/11/09".to_pdate.end_of_month.to_a, [1368, 11, 30]
|
15
|
+
assert_equal "1394/05/11".to_pdate.end_of_week.to_a, [1394, 5, 16]
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,101 +1,96 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_pdate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mohsen Alizadeh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 4.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.0.0
|
27
|
-
|
28
|
-
name: sqlite3
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
description: A free and open source plugin for ruby and rails framework to support
|
42
|
-
persian (Shamsi) date and time
|
27
|
+
description: persian date support for ruby on rails.
|
43
28
|
email:
|
44
|
-
-
|
29
|
+
- mohsen@alizadeh.us
|
45
30
|
executables: []
|
46
31
|
extensions: []
|
47
32
|
extra_rdoc_files: []
|
48
33
|
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.rdoc
|
36
|
+
- Rakefile
|
49
37
|
- lib/core_date.rb
|
38
|
+
- lib/core_date_time.rb
|
39
|
+
- lib/core_string.rb
|
40
|
+
- lib/rails_pdate.rb
|
41
|
+
- lib/rails_pdate/base_date_time.rb
|
42
|
+
- lib/rails_pdate/constants.rb
|
43
|
+
- lib/rails_pdate/formats.rb
|
44
|
+
- lib/rails_pdate/initializer.rb
|
50
45
|
- lib/rails_pdate/p_date.rb
|
46
|
+
- lib/rails_pdate/p_date_time.rb
|
51
47
|
- lib/rails_pdate/pconvertor.rb
|
52
|
-
- lib/rails_pdate/
|
48
|
+
- lib/rails_pdate/time_shifting.rb
|
53
49
|
- lib/rails_pdate/version.rb
|
54
50
|
- lib/tasks/rails_pdate_tasks.rake
|
55
|
-
-
|
56
|
-
- lib/core_string.rb
|
57
|
-
- MIT-LICENSE
|
58
|
-
- Rakefile
|
59
|
-
- README.rdoc
|
60
|
-
- test/core_string_test.rb
|
51
|
+
- test/comparisons_test.rb
|
61
52
|
- test/core_date_test.rb
|
62
|
-
- test/
|
63
|
-
- test/
|
64
|
-
- test/pconvertor_test.rb
|
65
|
-
- test/dummy/config.ru
|
66
|
-
- test/dummy/public/404.html
|
67
|
-
- test/dummy/public/500.html
|
68
|
-
- test/dummy/public/favicon.ico
|
69
|
-
- test/dummy/public/422.html
|
70
|
-
- test/dummy/bin/rake
|
71
|
-
- test/dummy/bin/bundle
|
72
|
-
- test/dummy/bin/rails
|
73
|
-
- test/dummy/Rakefile
|
53
|
+
- test/core_date_time_test.rb
|
54
|
+
- test/core_string_test.rb
|
74
55
|
- test/dummy/README.rdoc
|
75
|
-
- test/dummy/
|
56
|
+
- test/dummy/Rakefile
|
57
|
+
- test/dummy/app/assets/javascripts/application.js
|
58
|
+
- test/dummy/app/assets/stylesheets/application.css
|
76
59
|
- test/dummy/app/controllers/application_controller.rb
|
60
|
+
- test/dummy/app/helpers/application_helper.rb
|
77
61
|
- test/dummy/app/views/layouts/application.html.erb
|
78
|
-
- test/dummy/
|
79
|
-
- test/dummy/
|
62
|
+
- test/dummy/bin/bundle
|
63
|
+
- test/dummy/bin/rails
|
64
|
+
- test/dummy/bin/rake
|
65
|
+
- test/dummy/config.ru
|
66
|
+
- test/dummy/config/application.rb
|
67
|
+
- test/dummy/config/boot.rb
|
80
68
|
- test/dummy/config/database.yml
|
69
|
+
- test/dummy/config/environment.rb
|
70
|
+
- test/dummy/config/environments/development.rb
|
71
|
+
- test/dummy/config/environments/production.rb
|
72
|
+
- test/dummy/config/environments/test.rb
|
81
73
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
82
|
-
- test/dummy/config/initializers/
|
83
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
74
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
84
75
|
- test/dummy/config/initializers/inflections.rb
|
85
76
|
- test/dummy/config/initializers/mime_types.rb
|
86
|
-
- test/dummy/config/initializers/
|
77
|
+
- test/dummy/config/initializers/secret_token.rb
|
87
78
|
- test/dummy/config/initializers/session_store.rb
|
88
|
-
- test/dummy/config/
|
89
|
-
- test/dummy/config/routes.rb
|
90
|
-
- test/dummy/config/environments/development.rb
|
91
|
-
- test/dummy/config/environments/test.rb
|
92
|
-
- test/dummy/config/environments/production.rb
|
79
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
93
80
|
- test/dummy/config/locales/en.yml
|
94
|
-
- test/dummy/config/
|
95
|
-
- test/dummy/config/application.rb
|
81
|
+
- test/dummy/config/routes.rb
|
96
82
|
- test/dummy/db/test.sqlite3
|
97
83
|
- test/dummy/log/test.log
|
98
|
-
|
84
|
+
- test/dummy/public/404.html
|
85
|
+
- test/dummy/public/422.html
|
86
|
+
- test/dummy/public/500.html
|
87
|
+
- test/dummy/public/favicon.ico
|
88
|
+
- test/pconvertor_test.rb
|
89
|
+
- test/rails_pdate_test.rb
|
90
|
+
- test/rails_pdatetime_test.rb
|
91
|
+
- test/test_helper.rb
|
92
|
+
- test/time_shifting_test.rb
|
93
|
+
homepage: https://github.com/mohsen-alizadeh/rails-pdate
|
99
94
|
licenses: []
|
100
95
|
metadata: {}
|
101
96
|
post_install_message:
|
@@ -104,56 +99,60 @@ require_paths:
|
|
104
99
|
- lib
|
105
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
101
|
requirements:
|
107
|
-
- -
|
102
|
+
- - ">="
|
108
103
|
- !ruby/object:Gem::Version
|
109
104
|
version: '0'
|
110
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
106
|
requirements:
|
112
|
-
- -
|
107
|
+
- - ">="
|
113
108
|
- !ruby/object:Gem::Version
|
114
109
|
version: '0'
|
115
110
|
requirements: []
|
116
111
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.6.6
|
118
113
|
signing_key:
|
119
114
|
specification_version: 4
|
120
115
|
summary: persian date support for ruby on rails.
|
121
116
|
test_files:
|
122
|
-
- test/
|
123
|
-
- test/core_date_test.rb
|
117
|
+
- test/time_shifting_test.rb
|
124
118
|
- test/test_helper.rb
|
125
119
|
- test/rails_pdate_test.rb
|
120
|
+
- test/core_date_time_test.rb
|
121
|
+
- test/comparisons_test.rb
|
122
|
+
- test/rails_pdatetime_test.rb
|
123
|
+
- test/core_date_test.rb
|
126
124
|
- test/pconvertor_test.rb
|
127
|
-
- test/
|
128
|
-
- test/dummy/
|
129
|
-
- test/dummy/public/500.html
|
130
|
-
- test/dummy/public/favicon.ico
|
131
|
-
- test/dummy/public/422.html
|
125
|
+
- test/core_string_test.rb
|
126
|
+
- test/dummy/bin/rails
|
132
127
|
- test/dummy/bin/rake
|
133
128
|
- test/dummy/bin/bundle
|
134
|
-
- test/dummy/
|
129
|
+
- test/dummy/log/test.log
|
135
130
|
- test/dummy/Rakefile
|
136
|
-
- test/dummy/
|
137
|
-
- test/dummy/app/
|
131
|
+
- test/dummy/app/assets/javascripts/application.js
|
132
|
+
- test/dummy/app/assets/stylesheets/application.css
|
138
133
|
- test/dummy/app/controllers/application_controller.rb
|
139
134
|
- test/dummy/app/views/layouts/application.html.erb
|
140
|
-
- test/dummy/app/
|
141
|
-
- test/dummy/
|
135
|
+
- test/dummy/app/helpers/application_helper.rb
|
136
|
+
- test/dummy/config/routes.rb
|
137
|
+
- test/dummy/config/environments/test.rb
|
138
|
+
- test/dummy/config/environments/development.rb
|
139
|
+
- test/dummy/config/environments/production.rb
|
140
|
+
- test/dummy/config/application.rb
|
141
|
+
- test/dummy/config/boot.rb
|
142
|
+
- test/dummy/config/environment.rb
|
143
|
+
- test/dummy/config/locales/en.yml
|
142
144
|
- test/dummy/config/database.yml
|
145
|
+
- test/dummy/config/initializers/inflections.rb
|
143
146
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
144
|
-
- test/dummy/config/initializers/secret_token.rb
|
145
147
|
- test/dummy/config/initializers/wrap_parameters.rb
|
146
|
-
- test/dummy/config/initializers/inflections.rb
|
147
148
|
- test/dummy/config/initializers/mime_types.rb
|
148
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
149
149
|
- test/dummy/config/initializers/session_store.rb
|
150
|
-
- test/dummy/config/
|
151
|
-
- test/dummy/config/
|
152
|
-
- test/dummy/config
|
153
|
-
- test/dummy/
|
154
|
-
- test/dummy/
|
155
|
-
- test/dummy/
|
156
|
-
- test/dummy/
|
157
|
-
- test/dummy/config/application.rb
|
150
|
+
- test/dummy/config/initializers/secret_token.rb
|
151
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
152
|
+
- test/dummy/config.ru
|
153
|
+
- test/dummy/public/500.html
|
154
|
+
- test/dummy/public/422.html
|
155
|
+
- test/dummy/public/404.html
|
156
|
+
- test/dummy/public/favicon.ico
|
158
157
|
- test/dummy/db/test.sqlite3
|
159
|
-
- test/dummy/
|
158
|
+
- test/dummy/README.rdoc
|