arel_extensions 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a07429d6f459dff77dc3fa56aa258f1fee94ecb7401772ec3ceaea8dc0a8c4d7
4
- data.tar.gz: d1600677cf0e63777bd8d8b656f4e17f0fa534e23579cfe3c18044e855a6115b
3
+ metadata.gz: e4f994a5cce5bea002ac1274171d392e20f9119b45609484fc7b6a97c71aeef5
4
+ data.tar.gz: 7dae52792c8713f7c129c5c8870939cfc397ec8e2fb07a980bdba318a4c5fcd5
5
5
  SHA512:
6
- metadata.gz: 752646ca62337cff68c38bcda876d5aa1f7cf6cb8f31906b6d6335237aa1a074daf4891b94b45486d758f1af035d87aac2449951aab683d35f84c123b10c39f8
7
- data.tar.gz: d3002160ab13dc1ecbdac0d863a72847a4b3f151cfe12ada6d694b4fb02d70a7e16facbe455d474a5e2ce51ca5686c8abfee26962b91f04023e2fdeb335e22e0
6
+ metadata.gz: 77c8c7c4767f2c2ee617e001c2966bf6d6ad53daa2026ceb71efd337ebdfe1a2e2af080734f522f659a71ad1569052bd1c4730cde4d34f7577899245b50915a3
7
+ data.tar.gz: 71d6d5420d2515caecddc02613819bb2b2b06a5aed6f66d06e8d9397f2af6b478f97b6798746f91cc116fb4199aca4f4c61c98b45a0aa6cca9b8a0e821b90f83
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "1.3.2".freeze
2
+ VERSION = "1.3.3".freeze
3
3
  end
@@ -14,13 +14,14 @@ module ArelExtensions
14
14
 
15
15
  LOADED_VISITOR::DATE_FORMAT_DIRECTIVES = {
16
16
  '%Y' => 'YYYY', '%C' => '', '%y' => 'YY', '%m' => 'MM', '%B' => '', '%b' => '', '%^b' => '', # year, month
17
- '%d' => 'DD', '%e' => '', '%j' => '', '%w' => 'dw', '%A' => '', # day, weekday
18
- '%H' => 'hh', '%k' => '', '%I' => '', '%l' => '', '%P' => '', '%p' => '', # hours
17
+ '%V' => 'iso_week', '%G' => '', # ISO week number and year of week
18
+ '%d' => 'DD', '%e' => '', '%j' => '', '%w' => 'dw', '%A' => '', # day, weekday
19
+ '%H' => 'hh', '%k' => '', '%I' => '', '%l' => '', '%P' => '', '%p' => '', # hours
19
20
  '%M' => 'mi', '%S' => 'ss', '%L' => 'ms', '%N' => 'ns', '%z' => 'tz'
20
21
  }.freeze
21
22
 
22
23
  LOADED_VISITOR::DATE_FORMAT_FORMAT = {
23
- 'YY' => '0#', 'MM' => '0#', 'DD' => '0#', 'hh' => '0#', 'mi' => '0#', 'ss' => '0#'
24
+ 'YY' => '0#', 'MM' => '0#', 'DD' => '0#', 'hh' => '0#', 'mi' => '0#', 'ss' => '0#', 'iso_week' => '0#'
24
25
  }
25
26
 
26
27
  LOADED_VISITOR::DATE_FORMAT_REGEX =
@@ -8,6 +8,7 @@ module ArelExtensions
8
8
 
9
9
  DATE_FORMAT_DIRECTIVES = { # ISO C / POSIX
10
10
  '%Y' => '%Y', '%C' => '', '%y' => '%y', '%m' => '%m', '%B' => '%M', '%b' => '%b', '%^b' => '%b', # year, month
11
+ '%V' => '%v', '%G' => '%x', # ISO week number and year of week
11
12
  '%d' => '%d', '%e' => '%e', '%j' => '%j', '%w' => '%w', '%A' => '%W', # day, weekday
12
13
  '%H' => '%H', '%k' => '%k', '%I' => '%I', '%l' => '%l', '%P' => '%p', '%p' => '%p', # hours
13
14
  '%M' => '%i', '%S' => '%S', '%L' => '', '%N' => '%f', '%z' => ''
@@ -6,6 +6,7 @@ module ArelExtensions
6
6
  DATE_MAPPING = {'d' => 'DAY', 'm' => 'MONTH', 'w' => 'IW', 'y' => 'YEAR', 'wd' => 'D', 'h' => 'HOUR', 'mn' => 'MINUTE', 's' => 'SECOND'}
7
7
  DATE_FORMAT_DIRECTIVES = {
8
8
  '%Y' => 'YYYY', '%C' => 'CC', '%y' => 'YY', '%m' => 'MM', '%B' => 'Month', '%^B' => 'MONTH', '%b' => 'Mon', '%^b' => 'MON',
9
+ '%V' => 'IW', '%G' => 'IYYY', # ISO week number and year of week
9
10
  '%d' => 'DD', '%e' => 'FMDD', '%j' => 'DDD', '%w' => '', '%A' => 'Day', # day, weekday
10
11
  '%H' => 'HH24', '%k' => '', '%I' => 'HH', '%l' => '', '%P' => 'am', '%p' => 'AM', # hours
11
12
  '%M' => 'MI', '%S' => 'SS', '%L' => 'MS', '%N' => 'US', '%z' => 'tz' # seconds, subseconds
@@ -9,9 +9,10 @@ module ArelExtensions
9
9
  DATE_FORMAT_DIRECTIVES = {
10
10
  '%Y' => 'YYYY', '%C' => 'CC', '%y' => 'YY',
11
11
  '%m' => 'MM', '%B' => 'Month', '%^B' => 'MONTH', '%b' => 'Mon', '%^b' => 'MON',
12
- '%d' => 'DD', '%e' => 'FMDD', '%j' => 'DDD', '%w' => '', '%A' => 'Day', # day, weekday
12
+ '%V' => 'IW', '%G' => 'IYYY', # ISO week number and year of week
13
+ '%d' => 'DD', '%e' => 'FMDD', '%j' => 'DDD', '%w' => '', '%A' => 'Day', # day, weekday
13
14
  '%H' => 'HH24', '%k' => '', '%I' => 'HH', '%l' => '', '%P' => 'am', '%p' => 'AM', # hours
14
- '%M' => 'MI', '%S' => 'SS', '%L' => 'MS', '%N' => 'US', '%z' => 'tz', # seconds, subseconds
15
+ '%M' => 'MI', '%S' => 'SS', '%L' => 'MS', '%N' => 'US', '%z' => 'tz', # seconds, subseconds
15
16
  '%%' => '%',
16
17
  }.freeze
17
18
 
@@ -438,6 +438,39 @@ module ArelExtensions
438
438
  end
439
439
  end
440
440
 
441
+ def test_format_iso_week
442
+ skip "Unsupported ISO week number for DB=#{ENV['DB']}" if ['sqlite'].include?(ENV['DB'])
443
+ assert_equal '10', t(@lucas, @updated_at.format('%V'))
444
+ {
445
+ '2024-01-01 10:42:00' => '01', # Monday
446
+ '2030-01-01 10:42:00' => '01', # Tuesday
447
+ '2025-01-01 10:42:00' => '01', # Wednesday
448
+ '2026-01-01 10:42:00' => '01', # Thursday
449
+ '2027-01-01 10:42:00' => '53', # Friday
450
+ '2028-01-01 10:42:00' => '52', # Saturday
451
+ '2034-01-01 10:42:00' => '52', # Sunday
452
+ }.each do |date, exp|
453
+ assert_equal exp, t(@lucas, Arel::Nodes.build_quoted(date).cast(:datetime).format('%V'))
454
+ end
455
+ end
456
+
457
+ def test_format_iso_year_of_week
458
+ skip "Unsupported ISO year of week for DB=#{ENV['DB']}" if ['mssql', 'sqlite'].include?(ENV['DB'])
459
+ assert_equal '2014', t(@lucas, @updated_at.format('%G'))
460
+
461
+ {
462
+ '2024-01-01 10:42:00' => '2024', # Monday
463
+ '2030-01-01 10:42:00' => '2030', # Tuesday
464
+ '2025-01-01 10:42:00' => '2025', # Wednesday
465
+ '2026-01-01 10:42:00' => '2026', # Thursday
466
+ '2027-01-01 10:42:00' => '2026', # Friday
467
+ '2028-01-01 10:42:00' => '2027', # Saturday
468
+ '2034-01-01 10:42:00' => '2033', # Sunday
469
+ }.each do |date, exp|
470
+ assert_equal exp, t(@lucas, Arel::Nodes.build_quoted(date).cast(:datetime).format('%G'))
471
+ end
472
+ end
473
+
441
474
  def test_coalesce
442
475
  assert_equal 'Camille concat', t(@camille, @name.coalesce(nil, "default") + ' concat')
443
476
 
data/version_v1.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "1.3.2".freeze
2
+ VERSION = "1.3.3".freeze
3
3
  end
data/version_v2.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ArelExtensions
2
- VERSION = "2.1.2".freeze
2
+ VERSION = "2.1.3".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arel_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yann Azoury
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-03-04 00:00:00.000000000 Z
13
+ date: 2022-03-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: arel