i18n-date 0.0.1 → 0.0.2
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/bin/release.sh +2 -2
- data/i18n-date.gemspec +1 -1
- data/lib/i18n-date/version.rb +1 -1
- data/lib/i18n-date.rb +17 -0
- data/spec/date_spec.rb +1 -0
- metadata +2 -2
data/bin/release.sh
CHANGED
@@ -10,5 +10,5 @@ rm i18n-date-${gem_version}.gem
|
|
10
10
|
|
11
11
|
#git pull origin develop
|
12
12
|
#git push origin develop
|
13
|
-
git tag -a -m "i18n-date-${gem_version}" i18n-version-${gem_version}
|
14
|
-
git push --tags
|
13
|
+
#git tag -a -m "i18n-date-${gem_version}" i18n-version-${gem_version}
|
14
|
+
#git push --tags
|
data/i18n-date.gemspec
CHANGED
data/lib/i18n-date/version.rb
CHANGED
data/lib/i18n-date.rb
CHANGED
@@ -64,7 +64,24 @@ class Date
|
|
64
64
|
month_to = MONTH_TRANSLATIONS[month_from.downcase] # search for translation
|
65
65
|
return string.sub(month_from, month_to.to_s) if month_to
|
66
66
|
end
|
67
|
+
month_from = nil
|
68
|
+
new_date = []
|
69
|
+
string.split(' ').each do | part |
|
70
|
+
if MONTH_TRANSLATIONS.include?(part.downcase)
|
71
|
+
month_from = part.downcase
|
72
|
+
new_date << month_from
|
73
|
+
end
|
74
|
+
if part[/\d{1,4}/]
|
75
|
+
new_date << part
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
if month_from
|
80
|
+
month_to = MONTH_TRANSLATIONS[month_from.downcase]
|
81
|
+
return new_date.join(' ').sub(month_from, month_to.to_s) if month_to
|
82
|
+
end
|
67
83
|
|
84
|
+
binding.pry
|
68
85
|
string
|
69
86
|
end
|
70
87
|
end
|
data/spec/date_spec.rb
CHANGED
@@ -17,6 +17,7 @@ describe Date do
|
|
17
17
|
Date.month_to_english("22 de junio de 2010").should be_eql(RESULT_DATE)
|
18
18
|
Date.month_to_english("jun 22, 2010").should be_eql("June 22, 2010")
|
19
19
|
Date.month_to_english("Martes, 22 de junio de 2010").should be_eql(RESULT_DATE)
|
20
|
+
Date.month_to_english("Viernes 14 de diciembre").should be_eql('14 December')
|
20
21
|
end
|
21
22
|
|
22
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-date
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This gems is a monkey patch to Date class, that allows to take any Spanish/Portuguese
|
15
15
|
date into a valid ruby date, to simplify operations between them.
|