decentworks-date-support 0.1.0
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 +7 -0
- data/.gem_rbs_collection/actionpack/7.2/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/actionpack/7.2/actioncontroller-7.2.rbs +14 -0
- data/.gem_rbs_collection/actionpack/7.2/actioncontroller.rbs +290 -0
- data/.gem_rbs_collection/actionpack/7.2/actiondispatch.rbs +349 -0
- data/.gem_rbs_collection/actionpack/7.2/actionpack-generated.rbs +11497 -0
- data/.gem_rbs_collection/actionpack/7.2/patch.rbs +77 -0
- data/.gem_rbs_collection/actionview/6.0/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/actionview/6.0/actionview-generated.rbs +8976 -0
- data/.gem_rbs_collection/actionview/6.0/actionview.rbs +1940 -0
- data/.gem_rbs_collection/actionview/6.0/patch.rbs +57 -0
- data/.gem_rbs_collection/activesupport/7.0/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/activesupport/7.0/activesupport-7.0.rbs +381 -0
- data/.gem_rbs_collection/activesupport/7.0/activesupport-generated.rbs +11633 -0
- data/.gem_rbs_collection/activesupport/7.0/activesupport.rbs +724 -0
- data/.gem_rbs_collection/activesupport/7.0/manifest.yaml +15 -0
- data/.gem_rbs_collection/activesupport/7.0/patch.rbs +55 -0
- data/.gem_rbs_collection/ast/2.4/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/ast/2.4/ast.rbs +73 -0
- data/.gem_rbs_collection/cgi/0.5/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/cgi/0.5/core.rbs +925 -0
- data/.gem_rbs_collection/cgi/0.5/manifest.yaml +3 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/array.rbs +4 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/atomic_reference.rbs +16 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/executor.rbs +96 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/hash.rbs +4 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/map.rbs +68 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/promises.rbs +249 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/set.rbs +4 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/timer_task.rbs +47 -0
- data/.gem_rbs_collection/concurrent-ruby/1.1/utility/processor_counter.rbs +5 -0
- data/.gem_rbs_collection/connection_pool/2.4/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/connection_pool/2.4/connection_pool.rbs +34 -0
- data/.gem_rbs_collection/connection_pool/2.4/manifest.yaml +2 -0
- data/.gem_rbs_collection/diff-lcs/1.5/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/diff-lcs/1.5/diff-lcs.rbs +11 -0
- data/.gem_rbs_collection/faker/3.4.2/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/faker/3.4.2/faker-2.23.rbs +90 -0
- data/.gem_rbs_collection/faker/3.4.2/faker.rbs +18 -0
- data/.gem_rbs_collection/i18n/1.10/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/i18n/1.10/backend.rbs +274 -0
- data/.gem_rbs_collection/i18n/1.10/i18n.rbs +116 -0
- data/.gem_rbs_collection/lint_roller/1.1/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/lint_roller/1.1/lint_roller.rbs +48 -0
- data/.gem_rbs_collection/minitest/5.25/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/abstract_reporter.rbs +52 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/assertion.rbs +17 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/assertions.rbs +590 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/backtrace_filter.rbs +23 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/bench_spec.rbs +102 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/benchmark.rbs +259 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/composite_reporter.rbs +25 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/compress.rbs +13 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/error_on_warning.rbs +3 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/expectation.rbs +2 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/expectations.rbs +21 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/guard.rbs +64 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/mock.rbs +64 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/parallel/executor.rbs +46 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/parallel/test/class_methods.rbs +5 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/parallel/test.rbs +3 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/parallel.rbs +2 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/pride_io.rbs +62 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/pride_lol.rbs +19 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/progress_reporter.rbs +11 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/reportable.rbs +53 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/reporter.rbs +5 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/result.rbs +28 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/runnable.rbs +163 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/skip.rbs +6 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/spec/dsl/instance_methods.rbs +48 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/spec/dsl.rbs +129 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/spec.rbs +11 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/statistics_reporter.rbs +81 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/summary_reporter.rbs +18 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/test/lifecycle_hooks.rbs +92 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/test.rbs +69 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/unexpected_error.rbs +12 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/unexpected_warning.rbs +6 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/unit/test_case.rbs +3 -0
- data/.gem_rbs_collection/minitest/5.25/minitest/unit.rbs +4 -0
- data/.gem_rbs_collection/minitest/5.25/minitest.rbs +115 -0
- data/.gem_rbs_collection/nokogiri/1.11/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/nokogiri/1.11/nokogiri.rbs +2332 -0
- data/.gem_rbs_collection/nokogiri/1.11/patch.rbs +4 -0
- data/.gem_rbs_collection/parallel/1.20/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/parallel/1.20/parallel.rbs +86 -0
- data/.gem_rbs_collection/parser/3.2/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/parser/3.2/manifest.yaml +7 -0
- data/.gem_rbs_collection/parser/3.2/parser.rbs +194 -0
- data/.gem_rbs_collection/parser/3.2/polyfill.rbs +4 -0
- data/.gem_rbs_collection/rack/2.2/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/rack/2.2/manifest.yaml +3 -0
- data/.gem_rbs_collection/rack/2.2/rack.rbs +1480 -0
- data/.gem_rbs_collection/rails-dom-testing/2.0/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/rails-dom-testing/2.0/rails-dom-testing.rbs +51 -0
- data/.gem_rbs_collection/rails-html-sanitizer/1.6/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/rails-html-sanitizer/1.6/rails-html-sanitizer.rbs +53 -0
- data/.gem_rbs_collection/railties/6.0/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/railties/6.0/manifest.yaml +2 -0
- data/.gem_rbs_collection/railties/6.0/patch.rbs +17 -0
- data/.gem_rbs_collection/railties/6.0/railties-generated.rbs +4822 -0
- data/.gem_rbs_collection/railties/6.0/railties.rbs +44 -0
- data/.gem_rbs_collection/rainbow/3.0/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/rainbow/3.0/global.rbs +7 -0
- data/.gem_rbs_collection/rainbow/3.0/presenter.rbs +209 -0
- data/.gem_rbs_collection/rainbow/3.0/rainbow.rbs +5 -0
- data/.gem_rbs_collection/rake/13.0/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/rake/13.0/manifest.yaml +2 -0
- data/.gem_rbs_collection/rake/13.0/rake.rbs +39 -0
- data/.gem_rbs_collection/regexp_parser/2.8/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/regexp_parser/2.8/regexp_parser.rbs +17 -0
- data/.gem_rbs_collection/rubocop/1.57/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/rubocop/1.57/rubocop.rbs +208 -0
- data/.gem_rbs_collection/rubocop-ast/1.46/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/rubocop-ast/1.46/rubocop-ast.rbs +903 -0
- data/.gem_rbs_collection/thor/1.2/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/thor/1.2/thor.rbs +62 -0
- data/.gem_rbs_collection/tzinfo/2.0/.rbs_meta.yaml +9 -0
- data/.gem_rbs_collection/tzinfo/2.0/manifest.yaml +7 -0
- data/.gem_rbs_collection/tzinfo/2.0/tzinfo.rbs +600 -0
- data/.rspec +3 -0
- data/.rubocop.yml +8 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/Rakefile +12 -0
- data/Steepfile +43 -0
- data/lib/decentworks/active_support/time_with_zone_support.rb +327 -0
- data/lib/decentworks/date/support/version.rb +9 -0
- data/lib/decentworks/date_support.rb +323 -0
- data/lib/decentworks_date_support.rb +4 -0
- data/rbs_collection.lock.yaml +288 -0
- data/rbs_collection.yaml +41 -0
- data/sig/decentworks/active_support/time_with_zone_support.rbs +109 -0
- data/sig/decentworks/date/support.rbs +8 -0
- data/sig/decentworks/date_support.rbs +107 -0
- metadata +197 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module ActionView
|
|
2
|
+
class Resolver
|
|
3
|
+
# Defined with meta-programming
|
|
4
|
+
def self.caching: () -> untyped
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Remove the fake type for I18n::Config
|
|
9
|
+
# if the real types are available.
|
|
10
|
+
module I18n
|
|
11
|
+
class Config
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Remove the fake type for Erubi::Engine
|
|
16
|
+
# if the real types are available.
|
|
17
|
+
module Erubi
|
|
18
|
+
class Engine
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Remove the fake rails-dom-testing type
|
|
23
|
+
# if the real types are available.
|
|
24
|
+
module Rails
|
|
25
|
+
module Dom
|
|
26
|
+
module Testing
|
|
27
|
+
module Assertions
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Remove the fake rails-dom-testing type
|
|
34
|
+
# if the real types are available.
|
|
35
|
+
module Rails
|
|
36
|
+
module Dom
|
|
37
|
+
module Testing
|
|
38
|
+
module Assertions
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Remove the fake types for Gem::Version
|
|
45
|
+
# if the real types are available.
|
|
46
|
+
module Gem
|
|
47
|
+
class Version
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class SimpleDelegator
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
module Rails
|
|
55
|
+
class Engine
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
module ActiveSupport
|
|
2
|
+
module Cache
|
|
3
|
+
module Strategy
|
|
4
|
+
module LocalCache
|
|
5
|
+
module LocalCacheRegistry
|
|
6
|
+
def cache_for: (untyped local_cache_key) -> untyped
|
|
7
|
+
def set_cache_for: (untyped local_cache_key, untyped value) -> untyped
|
|
8
|
+
extend LocalCacheRegistry
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
module Notifications
|
|
15
|
+
interface _Callable5
|
|
16
|
+
def call: (String, Time, Time, String, Hash[untyped, untyped]) -> void
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
interface _Callable1
|
|
20
|
+
def call: (untyped event) -> void
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Subscribe to a given event name with the passed +block+.
|
|
24
|
+
#
|
|
25
|
+
# You can subscribe to events by passing a String to match exact event
|
|
26
|
+
# names, or by passing a Regexp to match all events that match a pattern.
|
|
27
|
+
#
|
|
28
|
+
# ActiveSupport::Notifications.subscribe(/render/) do |*args|
|
|
29
|
+
# @event = ActiveSupport::Notifications::Event.new(*args)
|
|
30
|
+
# end
|
|
31
|
+
#
|
|
32
|
+
# The +block+ will receive five parameters with information about the event:
|
|
33
|
+
#
|
|
34
|
+
# ActiveSupport::Notifications.subscribe('render') do |name, start, finish, id, payload|
|
|
35
|
+
# name # => String, name of the event (such as 'render' from above)
|
|
36
|
+
# start # => Time, when the instrumented block started execution
|
|
37
|
+
# finish # => Time, when the instrumented block ended execution
|
|
38
|
+
# id # => String, unique ID for the instrumenter that fired the event
|
|
39
|
+
# payload # => Hash, the payload
|
|
40
|
+
# end
|
|
41
|
+
#
|
|
42
|
+
# If the block passed to the method only takes one parameter,
|
|
43
|
+
# it will yield an event object to the block:
|
|
44
|
+
#
|
|
45
|
+
# ActiveSupport::Notifications.subscribe(/render/) do |event|
|
|
46
|
+
# @event = event
|
|
47
|
+
# end
|
|
48
|
+
def self.subscribe: (String | Regexp, _Callable5 | _Callable1) -> Subscriber
|
|
49
|
+
| ...
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class TimeWithZone
|
|
53
|
+
# Returns a string of the object's date and time.
|
|
54
|
+
#
|
|
55
|
+
# This method is aliased to <tt>to_formatted_s</tt>.
|
|
56
|
+
#
|
|
57
|
+
# Accepts an optional <tt>format</tt>:
|
|
58
|
+
# * <tt>:default</tt> - default value, mimics Ruby Time#to_s format.
|
|
59
|
+
# * <tt>:db</tt> - format outputs time in UTC :db time. See Time#to_fs(:db).
|
|
60
|
+
# * Any key in +Time::DATE_FORMATS+ can be used. See active_support/core_ext/time/conversions.rb.
|
|
61
|
+
def to_fs: (?Symbol format) -> String
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class TimeZone
|
|
65
|
+
# Locate a specific time zone object. If the argument is a string, it
|
|
66
|
+
# is interpreted to mean the name of the timezone to locate. If it is a
|
|
67
|
+
# numeric value it is either the hour offset, or the second offset, of the
|
|
68
|
+
# timezone to find. (The first one with that offset will be returned.)
|
|
69
|
+
# Returns +nil+ if no such time zone is known to the system.
|
|
70
|
+
def self.[]: (instance | TZInfo::Timezone | String | real | Duration) -> instance?
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# activesupport/lib/active_support/core_ext/time/zones.rb
|
|
75
|
+
class Time
|
|
76
|
+
# Returns a TimeZone instance matching the time zone provided.
|
|
77
|
+
# Accepts the time zone in any format supported by <tt>Time.zone=</tt>.
|
|
78
|
+
# Raises an +ArgumentError+ for invalid time zones.
|
|
79
|
+
#
|
|
80
|
+
# Time.find_zone! "America/New_York" # => #<ActiveSupport::TimeZone @name="America/New_York" ...>
|
|
81
|
+
# Time.find_zone! "EST" # => #<ActiveSupport::TimeZone @name="EST" ...>
|
|
82
|
+
# Time.find_zone! -5.hours # => #<ActiveSupport::TimeZone @name="Bogota" ...>
|
|
83
|
+
# Time.find_zone! nil # => nil
|
|
84
|
+
# Time.find_zone! false # => false
|
|
85
|
+
# Time.find_zone! "NOT-A-TIMEZONE" # => ArgumentError: Invalid Timezone: NOT-A-TIMEZONE
|
|
86
|
+
def self.find_zone!: (ActiveSupport::TimeZone | TZInfo::Timezone | String | real | ActiveSupport::Duration) -> ActiveSupport::TimeZone
|
|
87
|
+
|
|
88
|
+
# Returns a TimeZone instance matching the time zone provided.
|
|
89
|
+
# Accepts the time zone in any format supported by <tt>Time.zone=</tt>.
|
|
90
|
+
# Returns +nil+ for invalid time zones.
|
|
91
|
+
#
|
|
92
|
+
# Time.find_zone "America/New_York" # => #<ActiveSupport::TimeZone @name="America/New_York" ...>
|
|
93
|
+
# Time.find_zone "NOT-A-TIMEZONE" # => nil
|
|
94
|
+
def self.find_zone: (ActiveSupport::TimeZone | TZInfo::Timezone | String | real | ActiveSupport::Duration | nil) -> ActiveSupport::TimeZone?
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
module Enumerable[unchecked out Elem]
|
|
98
|
+
# Returns a new +Array+ without the blank items.
|
|
99
|
+
# Uses Object#blank? for determining if an item is blank.
|
|
100
|
+
#
|
|
101
|
+
# [1, "", nil, 2, " ", [], {}, false, true].compact_blank
|
|
102
|
+
# # => [1, 2, true]
|
|
103
|
+
#
|
|
104
|
+
# Set.new([nil, "", 1, false]).compact_blank
|
|
105
|
+
# # => [1]
|
|
106
|
+
#
|
|
107
|
+
# When called on a +Hash+, returns a new +Hash+ without the blank values.
|
|
108
|
+
#
|
|
109
|
+
# { a: "", b: 1, c: nil, d: [], e: false, f: true }.compact_blank
|
|
110
|
+
# # => { b: 1, f: true }
|
|
111
|
+
def compact_blank: () -> Array[Elem]
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
class Hash[unchecked out K, unchecked out V]
|
|
115
|
+
# Hash#reject has its own definition, so this needs one too.
|
|
116
|
+
def compact_blank: () -> Hash[K, V]
|
|
117
|
+
|
|
118
|
+
# Removes all blank values from the +Hash+ in place and returns self.
|
|
119
|
+
# Uses Object#blank? for determining if a value is blank.
|
|
120
|
+
#
|
|
121
|
+
# h = { a: "", b: 1, c: nil, d: [], e: false, f: true }
|
|
122
|
+
# h.compact_blank!
|
|
123
|
+
# # => { b: 1, f: true }
|
|
124
|
+
def compact_blank!: () -> Hash[K, V]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
class Array[unchecked out Elem]
|
|
128
|
+
# Removes all blank elements from the +Array+ in place and returns self.
|
|
129
|
+
# Uses Object#blank? for determining if an item is blank.
|
|
130
|
+
#
|
|
131
|
+
# a = [1, "", nil, 2, " ", [], {}, false, true]
|
|
132
|
+
# a.compact_blank!
|
|
133
|
+
# # => [1, 2, true]
|
|
134
|
+
def compact_blank!: () -> Array[Elem]
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# active_support/core_ext/string/inflections.rb
|
|
138
|
+
class String
|
|
139
|
+
def downcase_first: () -> String
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# active_support/core_ext/array/conversions.rb
|
|
143
|
+
class Array[unchecked out Elem]
|
|
144
|
+
# Extends <tt>Array#to_s</tt> to convert a collection of elements into a
|
|
145
|
+
# comma separated id list if <tt>:db</tt> argument is given as the format.
|
|
146
|
+
#
|
|
147
|
+
# This method is aliased to <tt>to_formatted_s</tt>.
|
|
148
|
+
#
|
|
149
|
+
# Blog.all.to_fs(:db) # => "1,2,3"
|
|
150
|
+
# Blog.none.to_fs(:db) # => "null"
|
|
151
|
+
# [1,2].to_fs # => "[1, 2]"
|
|
152
|
+
def to_fs: (?Symbol format) -> String
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# active_support/core_ext/numeric/conversions.rb
|
|
156
|
+
class Numeric
|
|
157
|
+
# \Numeric With Format
|
|
158
|
+
#
|
|
159
|
+
# Provides options for converting numbers into formatted strings.
|
|
160
|
+
# Options are provided for phone numbers, currency, percentage,
|
|
161
|
+
# precision, positional notation, file size, and pretty printing.
|
|
162
|
+
#
|
|
163
|
+
# This method is aliased to <tt>to_formatted_s</tt>.
|
|
164
|
+
#
|
|
165
|
+
# ==== Options
|
|
166
|
+
#
|
|
167
|
+
# For details on which formats use which options, see ActiveSupport::NumberHelper
|
|
168
|
+
#
|
|
169
|
+
# ==== Examples
|
|
170
|
+
#
|
|
171
|
+
# Phone Numbers:
|
|
172
|
+
# 5551234.to_fs(:phone) # => "555-1234"
|
|
173
|
+
# 1235551234.to_fs(:phone) # => "123-555-1234"
|
|
174
|
+
# 1235551234.to_fs(:phone, area_code: true) # => "(123) 555-1234"
|
|
175
|
+
# 1235551234.to_fs(:phone, delimiter: ' ') # => "123 555 1234"
|
|
176
|
+
# 1235551234.to_fs(:phone, area_code: true, extension: 555) # => "(123) 555-1234 x 555"
|
|
177
|
+
# 1235551234.to_fs(:phone, country_code: 1) # => "+1-123-555-1234"
|
|
178
|
+
# 1235551234.to_fs(:phone, country_code: 1, extension: 1343, delimiter: '.')
|
|
179
|
+
# # => "+1.123.555.1234 x 1343"
|
|
180
|
+
#
|
|
181
|
+
# Currency:
|
|
182
|
+
# 1234567890.50.to_fs(:currency) # => "$1,234,567,890.50"
|
|
183
|
+
# 1234567890.506.to_fs(:currency) # => "$1,234,567,890.51"
|
|
184
|
+
# 1234567890.506.to_fs(:currency, precision: 3) # => "$1,234,567,890.506"
|
|
185
|
+
# 1234567890.506.to_fs(:currency, round_mode: :down) # => "$1,234,567,890.50"
|
|
186
|
+
# 1234567890.506.to_fs(:currency, locale: :fr) # => "1 234 567 890,51 €"
|
|
187
|
+
# -1234567890.50.to_fs(:currency, negative_format: '(%u%n)')
|
|
188
|
+
# # => "($1,234,567,890.50)"
|
|
189
|
+
# 1234567890.50.to_fs(:currency, unit: '£', separator: ',', delimiter: '')
|
|
190
|
+
# # => "£1234567890,50"
|
|
191
|
+
# 1234567890.50.to_fs(:currency, unit: '£', separator: ',', delimiter: '', format: '%n %u')
|
|
192
|
+
# # => "1234567890,50 £"
|
|
193
|
+
#
|
|
194
|
+
# Percentage:
|
|
195
|
+
# 100.to_fs(:percentage) # => "100.000%"
|
|
196
|
+
# 100.to_fs(:percentage, precision: 0) # => "100%"
|
|
197
|
+
# 1000.to_fs(:percentage, delimiter: '.', separator: ',') # => "1.000,000%"
|
|
198
|
+
# 302.24398923423.to_fs(:percentage, precision: 5) # => "302.24399%"
|
|
199
|
+
# 302.24398923423.to_fs(:percentage, round_mode: :down) # => "302.243%"
|
|
200
|
+
# 1000.to_fs(:percentage, locale: :fr) # => "1 000,000%"
|
|
201
|
+
# 100.to_fs(:percentage, format: '%n %') # => "100.000 %"
|
|
202
|
+
#
|
|
203
|
+
# Delimited:
|
|
204
|
+
# 12345678.to_fs(:delimited) # => "12,345,678"
|
|
205
|
+
# 12345678.05.to_fs(:delimited) # => "12,345,678.05"
|
|
206
|
+
# 12345678.to_fs(:delimited, delimiter: '.') # => "12.345.678"
|
|
207
|
+
# 12345678.to_fs(:delimited, delimiter: ',') # => "12,345,678"
|
|
208
|
+
# 12345678.05.to_fs(:delimited, separator: ' ') # => "12,345,678 05"
|
|
209
|
+
# 12345678.05.to_fs(:delimited, locale: :fr) # => "12 345 678,05"
|
|
210
|
+
# 98765432.98.to_fs(:delimited, delimiter: ' ', separator: ',')
|
|
211
|
+
# # => "98 765 432,98"
|
|
212
|
+
#
|
|
213
|
+
# Rounded:
|
|
214
|
+
# 111.2345.to_fs(:rounded) # => "111.235"
|
|
215
|
+
# 111.2345.to_fs(:rounded, precision: 2) # => "111.23"
|
|
216
|
+
# 111.2345.to_fs(:rounded, precision: 2, round_mode: :up) # => "111.24"
|
|
217
|
+
# 13.to_fs(:rounded, precision: 5) # => "13.00000"
|
|
218
|
+
# 389.32314.to_fs(:rounded, precision: 0) # => "389"
|
|
219
|
+
# 111.2345.to_fs(:rounded, significant: true) # => "111"
|
|
220
|
+
# 111.2345.to_fs(:rounded, precision: 1, significant: true) # => "100"
|
|
221
|
+
# 13.to_fs(:rounded, precision: 5, significant: true) # => "13.000"
|
|
222
|
+
# 111.234.to_fs(:rounded, locale: :fr) # => "111,234"
|
|
223
|
+
# 13.to_fs(:rounded, precision: 5, significant: true, strip_insignificant_zeros: true)
|
|
224
|
+
# # => "13"
|
|
225
|
+
# 389.32314.to_fs(:rounded, precision: 4, significant: true) # => "389.3"
|
|
226
|
+
# 1111.2345.to_fs(:rounded, precision: 2, separator: ',', delimiter: '.')
|
|
227
|
+
# # => "1.111,23"
|
|
228
|
+
#
|
|
229
|
+
# Human-friendly size in Bytes:
|
|
230
|
+
# 123.to_fs(:human_size) # => "123 Bytes"
|
|
231
|
+
# 1234.to_fs(:human_size) # => "1.21 KB"
|
|
232
|
+
# 12345.to_fs(:human_size) # => "12.1 KB"
|
|
233
|
+
# 1234567.to_fs(:human_size) # => "1.18 MB"
|
|
234
|
+
# 1234567890.to_fs(:human_size) # => "1.15 GB"
|
|
235
|
+
# 1234567890123.to_fs(:human_size) # => "1.12 TB"
|
|
236
|
+
# 1234567890123456.to_fs(:human_size) # => "1.1 PB"
|
|
237
|
+
# 1234567890123456789.to_fs(:human_size) # => "1.07 EB"
|
|
238
|
+
# 1234567.to_fs(:human_size, precision: 2) # => "1.2 MB"
|
|
239
|
+
# 1234567.to_fs(:human_size, precision: 2, round_mode: :up) # => "1.3 MB"
|
|
240
|
+
# 483989.to_fs(:human_size, precision: 2) # => "470 KB"
|
|
241
|
+
# 1234567.to_fs(:human_size, precision: 2, separator: ',') # => "1,2 MB"
|
|
242
|
+
# 1234567890123.to_fs(:human_size, precision: 5) # => "1.1228 TB"
|
|
243
|
+
# 524288000.to_fs(:human_size, precision: 5) # => "500 MB"
|
|
244
|
+
#
|
|
245
|
+
# Human-friendly format:
|
|
246
|
+
# 123.to_fs(:human) # => "123"
|
|
247
|
+
# 1234.to_fs(:human) # => "1.23 Thousand"
|
|
248
|
+
# 12345.to_fs(:human) # => "12.3 Thousand"
|
|
249
|
+
# 1234567.to_fs(:human) # => "1.23 Million"
|
|
250
|
+
# 1234567890.to_fs(:human) # => "1.23 Billion"
|
|
251
|
+
# 1234567890123.to_fs(:human) # => "1.23 Trillion"
|
|
252
|
+
# 1234567890123456.to_fs(:human) # => "1.23 Quadrillion"
|
|
253
|
+
# 1234567890123456789.to_fs(:human) # => "1230 Quadrillion"
|
|
254
|
+
# 489939.to_fs(:human, precision: 2) # => "490 Thousand"
|
|
255
|
+
# 489939.to_fs(:human, precision: 2, round_mode: :down) # => "480 Thousand"
|
|
256
|
+
# 489939.to_fs(:human, precision: 4) # => "489.9 Thousand"
|
|
257
|
+
# 1234567.to_fs(:human, precision: 4,
|
|
258
|
+
# significant: false) # => "1.2346 Million"
|
|
259
|
+
# 1234567.to_fs(:human, precision: 1,
|
|
260
|
+
# separator: ',',
|
|
261
|
+
# significant: false) # => "1,2 Million"
|
|
262
|
+
def to_fs: (?Symbol format, **untyped) -> String
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# active_support/core_ext/range/conversions.rb
|
|
266
|
+
class Range[out Elem]
|
|
267
|
+
# Convert range to a formatted string. See RANGE_FORMATS for predefined formats.
|
|
268
|
+
#
|
|
269
|
+
# This method is aliased to <tt>to_formatted_s</tt>.
|
|
270
|
+
#
|
|
271
|
+
# range = (1..100) # => 1..100
|
|
272
|
+
#
|
|
273
|
+
# range.to_s # => "1..100"
|
|
274
|
+
# range.to_fs(:db) # => "BETWEEN '1' AND '100'"
|
|
275
|
+
#
|
|
276
|
+
# range = (1..) # => 1..
|
|
277
|
+
# range.to_fs(:db) # => ">= '1'"
|
|
278
|
+
#
|
|
279
|
+
# range = (..100) # => ..100
|
|
280
|
+
# range.to_fs(:db) # => "<= '100'"
|
|
281
|
+
#
|
|
282
|
+
# == Adding your own range formats to to_fs
|
|
283
|
+
# You can add your own formats to the Range::RANGE_FORMATS hash.
|
|
284
|
+
# Use the format name as the hash key and a Proc instance.
|
|
285
|
+
#
|
|
286
|
+
# # config/initializers/range_formats.rb
|
|
287
|
+
# Range::RANGE_FORMATS[:short] = ->(start, stop) { "Between #{start.to_fs(:db)} and #{stop.to_fs(:db)}" }
|
|
288
|
+
def to_fs: (?Symbol format) -> String
|
|
289
|
+
|
|
290
|
+
alias to_formatted_s to_fs
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# active_support/core_ext/date/conversions.rb
|
|
294
|
+
class Date
|
|
295
|
+
# Convert to a formatted string. See DATE_FORMATS for predefined formats.
|
|
296
|
+
#
|
|
297
|
+
# This method is aliased to <tt>to_formatted_s</tt>.
|
|
298
|
+
#
|
|
299
|
+
# date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
|
|
300
|
+
#
|
|
301
|
+
# date.to_fs(:db) # => "2007-11-10"
|
|
302
|
+
# date.to_formatted_s(:db) # => "2007-11-10"
|
|
303
|
+
#
|
|
304
|
+
# date.to_fs(:short) # => "10 Nov"
|
|
305
|
+
# date.to_fs(:number) # => "20071110"
|
|
306
|
+
# date.to_fs(:long) # => "November 10, 2007"
|
|
307
|
+
# date.to_fs(:long_ordinal) # => "November 10th, 2007"
|
|
308
|
+
# date.to_fs(:rfc822) # => "10 Nov 2007"
|
|
309
|
+
# date.to_fs(:iso8601) # => "2007-11-10"
|
|
310
|
+
#
|
|
311
|
+
# == Adding your own date formats to to_fs
|
|
312
|
+
# You can add your own formats to the Date::DATE_FORMATS hash.
|
|
313
|
+
# Use the format name as the hash key and either a strftime string
|
|
314
|
+
# or Proc instance that takes a date argument as the value.
|
|
315
|
+
#
|
|
316
|
+
# # config/initializers/date_formats.rb
|
|
317
|
+
# Date::DATE_FORMATS[:month_and_year] = '%B %Y'
|
|
318
|
+
# Date::DATE_FORMATS[:short_ordinal] = ->(date) { date.strftime("%B #{date.day.ordinalize}") }
|
|
319
|
+
def to_fs: (?Symbol format) -> String
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
# active_support/core_ext/time/conversions.rb
|
|
323
|
+
class Time
|
|
324
|
+
# Converts to a formatted string. See DATE_FORMATS for built-in formats.
|
|
325
|
+
#
|
|
326
|
+
# This method is aliased to <tt>to_formatted_s</tt>.
|
|
327
|
+
#
|
|
328
|
+
# time = Time.now # => 2007-01-18 06:10:17 -06:00
|
|
329
|
+
#
|
|
330
|
+
# time.to_fs(:time) # => "06:10"
|
|
331
|
+
# time.to_formatted_s(:time) # => "06:10"
|
|
332
|
+
#
|
|
333
|
+
# time.to_fs(:db) # => "2007-01-18 06:10:17"
|
|
334
|
+
# time.to_fs(:number) # => "20070118061017"
|
|
335
|
+
# time.to_fs(:short) # => "18 Jan 06:10"
|
|
336
|
+
# time.to_fs(:long) # => "January 18, 2007 06:10"
|
|
337
|
+
# time.to_fs(:long_ordinal) # => "January 18th, 2007 06:10"
|
|
338
|
+
# time.to_fs(:rfc822) # => "Thu, 18 Jan 2007 06:10:17 -0600"
|
|
339
|
+
# time.to_fs(:rfc2822) # => "Thu, 18 Jan 2007 06:10:17 -0600"
|
|
340
|
+
# time.to_fs(:iso8601) # => "2007-01-18T06:10:17-06:00"
|
|
341
|
+
#
|
|
342
|
+
# == Adding your own time formats to +to_fs+
|
|
343
|
+
# You can add your own formats to the Time::DATE_FORMATS hash.
|
|
344
|
+
# Use the format name as the hash key and either a strftime string
|
|
345
|
+
# or Proc instance that takes a time argument as the value.
|
|
346
|
+
#
|
|
347
|
+
# # config/initializers/time_formats.rb
|
|
348
|
+
# Time::DATE_FORMATS[:month_and_year] = '%B %Y'
|
|
349
|
+
# Time::DATE_FORMATS[:short_ordinal] = ->(time) { time.strftime("%B #{time.day.ordinalize}") }
|
|
350
|
+
def to_fs: (?Symbol format) -> String
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
# active_support/core_ext/date_time/conversions.rb
|
|
354
|
+
class DateTime
|
|
355
|
+
# Convert to a formatted string. See Time::DATE_FORMATS for predefined formats.
|
|
356
|
+
#
|
|
357
|
+
# This method is aliased to <tt>to_formatted_s</tt>.
|
|
358
|
+
#
|
|
359
|
+
# === Examples
|
|
360
|
+
# datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0) # => Tue, 04 Dec 2007 00:00:00 +0000
|
|
361
|
+
#
|
|
362
|
+
# datetime.to_fs(:db) # => "2007-12-04 00:00:00"
|
|
363
|
+
# datetime.to_formatted_s(:db) # => "2007-12-04 00:00:00"
|
|
364
|
+
# datetime.to_fs(:number) # => "20071204000000"
|
|
365
|
+
# datetime.to_fs(:short) # => "04 Dec 00:00"
|
|
366
|
+
# datetime.to_fs(:long) # => "December 04, 2007 00:00"
|
|
367
|
+
# datetime.to_fs(:long_ordinal) # => "December 4th, 2007 00:00"
|
|
368
|
+
# datetime.to_fs(:rfc822) # => "Tue, 04 Dec 2007 00:00:00 +0000"
|
|
369
|
+
# datetime.to_fs(:iso8601) # => "2007-12-04T00:00:00+00:00"
|
|
370
|
+
#
|
|
371
|
+
# == Adding your own datetime formats to to_fs
|
|
372
|
+
# DateTime formats are shared with Time. You can add your own to the
|
|
373
|
+
# Time::DATE_FORMATS hash. Use the format name as the hash key and
|
|
374
|
+
# either a strftime string or Proc instance that takes a time or
|
|
375
|
+
# datetime argument as the value.
|
|
376
|
+
#
|
|
377
|
+
# # config/initializers/time_formats.rb
|
|
378
|
+
# Time::DATE_FORMATS[:month_and_year] = '%B %Y'
|
|
379
|
+
# Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") }
|
|
380
|
+
def to_fs: (?Symbol format) -> String
|
|
381
|
+
end
|