latias-date-format 0.1.2 → 0.1.7
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.
- checksums.yaml +4 -4
- data/README.md +20 -2
- data/config/locales/th.yml +3 -1
- data/lib/latias/date/format.rb +0 -11
- data/lib/latias/date/format/engine.rb +6 -2
- data/lib/latias/date/format/version.rb +1 -1
- data/lib/latias/date/formater.rb +17 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ca7372c40ccda674af94b029713832347875ff8e1593258736919d396e2b8cb
|
4
|
+
data.tar.gz: 4925ae99610072c7cd1a55cf5f70666298be3004fa7b6431e9daf1d104f700f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3b567559a2e1e0c9c04a37927298360b5e7822617bbb4468000dd71627a8c3777cc0c4dff84301f4a31d231ffec8543832edb080b728f2c586921650fafb65b
|
7
|
+
data.tar.gz: cb57d483061e6ee788ef5cd190ece7262280c37cd1f92ac4024846c901476760839769a40f3b8064bf83b93595ff314aa349bc3cc61ae4ffb8e73fae6b56c7ce
|
data/README.md
CHANGED
@@ -1,19 +1,29 @@
|
|
1
|
+
<!--
|
2
|
+
how to update
|
3
|
+
gem build latias-date-format.gemspec
|
4
|
+
gem push latias-date-format-0.1.6.gem
|
5
|
+
-->
|
6
|
+
|
1
7
|
# Latias::Date::Format
|
8
|
+
|
2
9
|
Short description and motivation.
|
3
10
|
|
4
11
|
## Usage
|
12
|
+
|
5
13
|
How to use my plugin.
|
6
14
|
|
7
15
|
## Installation
|
16
|
+
|
8
17
|
Add this line to your application's Gemfile:
|
9
18
|
|
10
19
|
```ruby
|
11
|
-
gem 'latias-date-format', '~> 0.1
|
20
|
+
gem 'latias-date-format', '~> 0.1'
|
12
21
|
# or
|
13
|
-
gem 'latias-date-format', git: 'https://nattanon:dT1Lcvf8pvGoU7LX4Uqr@gitlab.opensource-technology.com/nattanon/latias-date-format-rails.git'
|
22
|
+
gem 'latias-date-format', '~> 0.1', git: 'https://nattanon:dT1Lcvf8pvGoU7LX4Uqr@gitlab.opensource-technology.com/nattanon/latias-date-format-rails.git'
|
14
23
|
```
|
15
24
|
|
16
25
|
## Examples
|
26
|
+
|
17
27
|
```ruby
|
18
28
|
2.6.5 :001 > buddist_date_format(Date.today) # Date
|
19
29
|
=> "15 มกราคม 2564"
|
@@ -27,8 +37,16 @@ gem 'latias-date-format', git: 'https://nattanon:dT1Lcvf8pvGoU7LX4Uqr@gitlab.ope
|
|
27
37
|
=> "ม.ค. 2564 17:20:23 +0700"
|
28
38
|
```
|
29
39
|
|
40
|
+
### Manual
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
include Latias::Date::Formater
|
44
|
+
```
|
45
|
+
|
30
46
|
## Contributing
|
47
|
+
|
31
48
|
Contribution directions go here.
|
32
49
|
|
33
50
|
## License
|
51
|
+
|
34
52
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/config/locales/th.yml
CHANGED
data/lib/latias/date/format.rb
CHANGED
@@ -3,17 +3,6 @@ require 'latias/date/format/engine'
|
|
3
3
|
module Latias
|
4
4
|
module Date
|
5
5
|
module Format
|
6
|
-
def buddist_date_format(date, format: '%e %B %Y')
|
7
|
-
format = format.gsub('%Y', buddhist_year(date.year).to_s)
|
8
|
-
format = format.gsub('%y', (buddhist_year(date.year) % 100).to_s)
|
9
|
-
I18n.l(date, format: format, locale: :th)
|
10
|
-
end
|
11
|
-
|
12
|
-
def buddhist_year(year)
|
13
|
-
year + 543
|
14
|
-
end
|
15
6
|
end
|
16
7
|
end
|
17
8
|
end
|
18
|
-
|
19
|
-
extend Latias::Date::Format
|
@@ -1,10 +1,14 @@
|
|
1
|
+
require 'latias/date/formater'
|
2
|
+
|
1
3
|
module Latias
|
2
4
|
module Date
|
3
5
|
module Format
|
4
6
|
class Engine < ::Rails::Engine
|
5
7
|
isolate_namespace Latias::Date::Format
|
6
|
-
|
7
|
-
|
8
|
+
# ActionController::Base.include Latias::Date::Format
|
9
|
+
ActionView::Base.include Latias::Date::Formater
|
10
|
+
ActiveSupport.on_load(:action_controller_base) do
|
11
|
+
include Latias::Date::Formater
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Latias
|
2
|
+
module Date
|
3
|
+
module Formater
|
4
|
+
def buddist_date_format(date, format: '%e %B %Y')
|
5
|
+
format = format.gsub('%Y', buddhist_year(date.year).to_s)
|
6
|
+
format = format.gsub('%y', (buddhist_year(date.year) % 100).to_s)
|
7
|
+
I18n.l(date, format: format, locale: :th)
|
8
|
+
end
|
9
|
+
|
10
|
+
def buddhist_year(year)
|
11
|
+
year + 543
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# extend Latias::Date::Format
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: latias-date-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nattanon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/latias/date/format.rb
|
48
48
|
- lib/latias/date/format/engine.rb
|
49
49
|
- lib/latias/date/format/version.rb
|
50
|
+
- lib/latias/date/formater.rb
|
50
51
|
- lib/tasks/latias/date/format_tasks.rake
|
51
52
|
homepage: https://gitlab.opensource-technology.com/nattanon/latias-date-format-rails
|
52
53
|
licenses:
|