code
stringlengths
26
124k
docstring
stringlengths
23
125k
func_name
stringlengths
1
98
language
stringclasses
1 value
repo
stringlengths
5
53
path
stringlengths
7
151
url
stringlengths
50
211
license
stringclasses
7 values
def initialize @timezones = Concurrent::Map.new end
Initializes a new {DataSource} instance. Typically only called via subclasses of {DataSource}.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def get_timezone_info(identifier) result = @timezones[identifier] unless result # Thread-safety: It is possible that multiple equivalent TimezoneInfo # instances could be created here in concurrently executing threads. The # consequences of this are that the data may be loaded more than once # (depending on the data source). The performance benefit of ensuring # that only a single instance is created is unlikely to be worth the # overhead of only allowing one TimezoneInfo to be loaded at a time. result = load_timezone_info(identifier) @timezones[result.identifier] = result end result end
Returns a {DataSources::TimezoneInfo} instance for the given identifier. The result will derive from either {DataSources::DataTimezoneInfo} for time zones that define their own data or {DataSources::LinkedTimezoneInfo} for links or aliases to other time zones. {get_timezone_info} calls {load_timezone_info} to create the {DataSources::TimezoneInfo} instance. The returned instance is cached and returned in subsequent calls to {get_timezone_info} for the identifier. @param identifier [String] A time zone identifier. @return [DataSources::TimezoneInfo] a {DataSources::TimezoneInfo} instance for a given identifier. @raise [InvalidTimezoneIdentifier] if the time zone is not found or the identifier is invalid.
get_timezone_info
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def timezone_identifiers # Thread-safety: It is possible that the value of @timezone_identifiers # may be calculated multiple times in concurrently executing threads. It # is not worth the overhead of locking to ensure that # @timezone_identifiers is only calculated once. @timezone_identifiers ||= build_timezone_identifiers end
@return [Array<String>] a frozen `Array`` of all the available time zone identifiers. The identifiers are sorted according to `String#<=>`.
timezone_identifiers
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def eager_load! timezone_identifiers.each {|identifier| load_timezone_info(identifier) } country_codes.each {|code| load_country_info(code) } nil end
Loads all timezone and country data into memory. This may be desirable in production environments to improve copy-on-write performance and to avoid flushing the constant cache every time a new timezone or country is loaded from {DataSources::RubyDataSource}.
eager_load!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def to_s "Default DataSource" end
@return [String] a description of the {DataSource}.
to_s
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def validate_timezone_identifier(identifier) raise InvalidTimezoneIdentifier, "Invalid identifier: #{identifier.nil? ? 'nil' : identifier}" unless identifier.kind_of?(String) valid_identifier = try_with_encoding(identifier, timezone_identifier_encoding) {|id| find_timezone_identifier(id) } return valid_identifier if valid_identifier raise InvalidTimezoneIdentifier, "Invalid identifier: #{identifier.encode(Encoding::UTF_8)}" end
Checks that the given identifier is a valid time zone identifier (can be found in the {timezone_identifiers} `Array`). If the identifier is valid, the `String` instance representing that identifier from `timezone_identifiers` is returned. Otherwise an {InvalidTimezoneIdentifier} exception is raised. @param identifier [String] a time zone identifier to be validated. @return [String] the `String` instance equivalent to `identifier` from {timezone_identifiers}. @raise [InvalidTimezoneIdentifier] if `identifier` was not found in {timezone_identifiers}.
validate_timezone_identifier
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def lookup_country_info(hash, code, encoding = Encoding::UTF_8) raise InvalidCountryCode, "Invalid country code: #{code.nil? ? 'nil' : code}" unless code.kind_of?(String) info = try_with_encoding(code, encoding) {|c| hash[c] } return info if info raise InvalidCountryCode, "Invalid country code: #{code.encode(Encoding::UTF_8)}" end
Looks up a given code in the given hash of code to {DataSources::CountryInfo} mappings. If the code is found the {DataSources::CountryInfo} is returned. Otherwise an {InvalidCountryCode} exception is raised. @param hash [String, DataSources::CountryInfo] a mapping from ISO 3166-1 alpha-2 country codes to {DataSources::CountryInfo} instances. @param code [String] a country code to lookup. @param encoding [Encoding] the encoding used for the country codes in `hash`. @return [DataSources::CountryInfo] the {DataSources::CountryInfo} instance corresponding to `code`. @raise [InvalidCountryCode] if `code` was not found in `hash`.
lookup_country_info
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def raise_invalid_data_source(method_name) raise InvalidDataSource, "#{method_name} not defined" end
Raises {InvalidDataSource} to indicate that a method has not been overridden by a particular data source implementation. @raise [InvalidDataSource] always.
raise_invalid_data_source
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def build_timezone_identifiers data = data_timezone_identifiers linked = linked_timezone_identifiers linked.empty? ? data : (data + linked).sort!.freeze end
Combines {data_timezone_identifiers} and {linked_timezone_identifiers} to create an `Array` containing all valid time zone identifiers. If {linked_timezone_identifiers} is empty, the {data_timezone_identifiers} instance is returned. The returned `Array` is frozen. The identifiers are sorted according to `String#<=>`. @return [Array<String>] an `Array` containing all valid time zone identifiers.
build_timezone_identifiers
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def find_timezone_identifier(identifier) result = timezone_identifiers.bsearch {|i| i >= identifier } result == identifier ? result : nil end
If the given `identifier` is contained within the {timezone_identifiers} `Array`, the `String` instance representing that identifier from {timezone_identifiers} is returned. Otherwise, `nil` is returned. @param identifier [String] A time zone identifier to search for. @return [String] the `String` instance representing `identifier` from {timezone_identifiers} if found, or `nil` if not found. :nocov_no_array_bsearch:
find_timezone_identifier
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def find_timezone_identifier(identifier) identifiers = timezone_identifiers low = 0 high = identifiers.length while low < high do mid = (low + high).div(2) mid_identifier = identifiers[mid] cmp = mid_identifier <=> identifier return mid_identifier if cmp == 0 if cmp > 0 high = mid else low = mid + 1 end end nil end
If the given `identifier` is contained within the {timezone_identifiers} `Array`, the `String` instance representing that identifier from {timezone_identifiers} is returned. Otherwise, `nil` is returned. @param identifier [String] A time zone identifier to search for. @return [String] the `String` instance representing `identifier` from {timezone_identifiers} if found, or `nil` if not found. :nocov_array_bsearch:
find_timezone_identifier
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def try_with_encoding(string, encoding) result = yield string return result if result unless encoding == string.encoding string = string.encode(encoding) yield string end end
Tries an operation using `string` directly. If the operation fails, the string is copied and encoded with `encoding` and the operation is tried again. @param string [String] The `String` to perform the operation on. @param encoding [Encoding] The `Encoding` to use if the initial attempt fails. @yield [s] the caller will be yielded to once or twice to attempt the operation. @yieldparam s [String] either `string` or an encoded copy of `string`. @yieldreturn [Object] The result of the operation. Must be truthy if successful. @return [Object] the result of the operation or `nil` if the first attempt fails and `string` is already encoded with `encoding`.
try_with_encoding
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/data_source.rb
Apache-2.0
def set_timezone_offset(timezone_offset) raise ArgumentError, 'timezone_offset must be specified' unless timezone_offset raise ArgumentError, 'timezone_offset.observed_utc_offset does not match self.utc_offset' if offset * 86400 != timezone_offset.observed_utc_offset @timezone_offset = timezone_offset self end
Sets the associated {TimezoneOffset}. @param timezone_offset [TimezoneOffset] a {TimezoneOffset} valid at the time and for the offset of this {DateTimeWithOffset}. @return [DateTimeWithOffset] `self`. @raise [ArgumentError] if `timezone_offset` is `nil`. @raise [ArgumentError] if `timezone_offset.observed_utc_offset` does not equal `self.offset * 86400`.
set_timezone_offset
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def to_time if_timezone_offset(super) do |o,t| # Ruby 2.4.0 changed the behaviour of to_time so that it preserves the # offset instead of converting to the system local timezone. # # When self has an associated TimezonePeriod, this implementation will # preserve the offset on all versions of Ruby. TimeWithOffset.at(t.to_i, t.subsec * 1_000_000).set_timezone_offset(o) end end
An overridden version of `DateTime#to_time` that, if there is an associated {TimezoneOffset}, returns a {DateTimeWithOffset} with that offset. @return [Time] if there is an associated {TimezoneOffset}, a {TimeWithOffset} representation of this {DateTimeWithOffset}, otherwise a `Time` representation.
to_time
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def downto(min) if block_given? super {|dt| yield dt.clear_timezone_offset } else enum = super enum.each {|dt| dt.clear_timezone_offset } enum end end
An overridden version of `DateTime#downto` that clears the associated {TimezoneOffset} of the returned or yielded instances.
downto
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def england # super doesn't call #new_start on MRI, so each method has to be # individually overridden. if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) } end
An overridden version of `DateTime#england` that preserves the associated {TimezoneOffset}. @return [DateTime]
england
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def gregorian # super doesn't call #new_start on MRI, so each method has to be # individually overridden. if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) } end
An overridden version of `DateTime#gregorian` that preserves the associated {TimezoneOffset}. @return [DateTime]
gregorian
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def italy # super doesn't call #new_start on MRI, so each method has to be # individually overridden. if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) } end
An overridden version of `DateTime#italy` that preserves the associated {TimezoneOffset}. @return [DateTime]
italy
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def julian # super doesn't call #new_start on MRI, so each method has to be # individually overridden. if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) } end
An overridden version of `DateTime#julian` that preserves the associated {TimezoneOffset}. @return [DateTime]
julian
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def new_start(start = Date::ITALY) if_timezone_offset(super) {|o,dt| dt.set_timezone_offset(o) } end
An overridden version of `DateTime#new_start` that preserves the associated {TimezoneOffset}. @return [DateTime]
new_start
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def step(limit, step = 1) if block_given? super {|dt| yield dt.clear_timezone_offset } else enum = super enum.each {|dt| dt.clear_timezone_offset } enum end end
An overridden version of `DateTime#step` that clears the associated {TimezoneOffset} of the returned or yielded instances.
step
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def upto(max) if block_given? super {|dt| yield dt.clear_timezone_offset } else enum = super enum.each {|dt| dt.clear_timezone_offset } enum end end
An overridden version of `DateTime#upto` that clears the associated {TimezoneOffset} of the returned or yielded instances.
upto
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def clear_timezone_offset @timezone_offset = nil self end
Clears the associated {TimezoneOffset}. @return [DateTimeWithOffset] `self`.
clear_timezone_offset
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/datetime_with_offset.rb
Apache-2.0
def initialize(info) super() @info = info end
Initializes a new {InfoTimezone}. {InfoTimezone} instances should not normally be created directly. Use the {Timezone.get} method to obtain {Timezone} instances. @param info [DataSources::TimezoneInfo] a {DataSources::TimezoneInfo} instance supplied by a {DataSource} that will be used as the source of data for this {InfoTimezone}.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/info_timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/info_timezone.rb
Apache-2.0
def initialize(info) super @linked_timezone = Timezone.get(info.link_to_identifier) end
Initializes a new {LinkedTimezone}. {LinkedTimezone} instances should not normally be created directly. Use the {Timezone.get} method to obtain {Timezone} instances. @param info [DataSources::LinkedTimezoneInfo] a {DataSources::LinkedTimezoneInfo} instance supplied by a {DataSource} that will be used as the source of data for this {LinkedTimezone}.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/linked_timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/linked_timezone.rb
Apache-2.0
def dedupe(string) return string if string.frozen? @strings[string] end
@param string [String] the string to deduplicate. @return [bool] `string` if it is frozen, otherwise a frozen, possibly pre-existing copy of `string`.
dedupe
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/string_deduper.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/string_deduper.rb
Apache-2.0
def dedupe(string) # String#-@ on Ruby 2.6 will dedupe a frozen non-literal String. Ruby # 2.5 will just return frozen strings. # # The pooled implementation can't tell the difference between frozen # literals and frozen non-literals, so must always return frozen String # instances to avoid doing unncessary work when loading format 2 # TZInfo::Data modules. # # For compatibility with the pooled implementation, just return frozen # string instances (acting like Ruby 2.5). return string if string.frozen? -string end
@param string [String] the string to deduplicate. @return [bool] `string` if it is frozen, otherwise a frozen, possibly pre-existing copy of `string`.
dedupe
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/string_deduper.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/string_deduper.rb
Apache-2.0
def create(year, month = 1, day = 1, hour = 0, minute = 0, second = 0, sub_second = 0, utc_offset = nil) raise ArgumentError, 'year must be an Integer' unless year.kind_of?(Integer) raise ArgumentError, 'month must be an Integer' unless month.kind_of?(Integer) raise ArgumentError, 'day must be an Integer' unless day.kind_of?(Integer) raise ArgumentError, 'hour must be an Integer' unless hour.kind_of?(Integer) raise ArgumentError, 'minute must be an Integer' unless minute.kind_of?(Integer) raise ArgumentError, 'second must be an Integer' unless second.kind_of?(Integer) raise RangeError, 'month must be between 1 and 12' if month < 1 || month > 12 raise RangeError, 'day must be between 1 and 31' if day < 1 || day > 31 raise RangeError, 'hour must be between 0 and 23' if hour < 0 || hour > 23 raise RangeError, 'minute must be between 0 and 59' if minute < 0 || minute > 59 raise RangeError, 'second must be between 0 and 59' if second < 0 || second > 59 # Based on days_from_civil from https://howardhinnant.github.io/date_algorithms.html#days_from_civil after_february = month > 2 year -= 1 unless after_february era = year / 400 year_of_era = year - era * 400 day_of_year = (153 * (month + (after_february ? -3 : 9)) + 2) / 5 + day - 1 day_of_era = year_of_era * 365 + year_of_era / 4 - year_of_era / 100 + day_of_year days_since_epoch = era * 146097 + day_of_era - 719468 value = ((days_since_epoch * 24 + hour) * 60 + minute) * 60 + second value -= utc_offset if utc_offset.kind_of?(Integer) new(value, sub_second, utc_offset) end
Returns a new {Timestamp} representing the (proleptic Gregorian calendar) date and time specified by the supplied parameters. If `utc_offset` is `nil`, `:utc` or 0, the date and time parameters will be interpreted as representing a UTC date and time. Otherwise the date and time parameters will be interpreted as a local date and time with the given offset. @param year [Integer] the year. @param month [Integer] the month (1-12). @param day [Integer] the day of the month (1-31). @param hour [Integer] the hour (0-23). @param minute [Integer] the minute (0-59). @param second [Integer] the second (0-59). @param sub_second [Numeric] the fractional part of the second as either a `Rational` that is greater than or equal to 0 and less than 1, or the `Integer` 0. @param utc_offset [Object] either `nil` for a {Timestamp} without a specified offset, an offset from UTC specified as an `Integer` number of seconds or the `Symbol` `:utc`). @return [Timestamp] a new {Timestamp} representing the specified (proleptic Gregorian calendar) date and time. @raise [ArgumentError] if either of `year`, `month`, `day`, `hour`, `minute`, or `second` is not an `Integer`. @raise [ArgumentError] if `sub_second` is not a `Rational`, or the `Integer` 0. @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer` and not the `Symbol` `:utc`. @raise [RangeError] if `month` is not between 1 and 12. @raise [RangeError] if `day` is not between 1 and 31. @raise [RangeError] if `hour` is not between 0 and 23. @raise [RangeError] if `minute` is not between 0 and 59. @raise [RangeError] if `second` is not between 0 and 59. @raise [RangeError] if `sub_second` is a `Rational` but that is less than 0 or greater than or equal to 1.
create
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def for(value, offset = :preserve) raise ArgumentError, 'value must be specified' unless value case offset when :ignore ignore_offset = true target_utc_offset = nil when :treat_as_utc ignore_offset = true target_utc_offset = :utc when :preserve ignore_offset = false target_utc_offset = nil else raise ArgumentError, 'offset must be :preserve, :ignore or :treat_as_utc' end time_like = false timestamp = case value when Time for_time(value, ignore_offset, target_utc_offset) when DateTime for_datetime(value, ignore_offset, target_utc_offset) when Timestamp for_timestamp(value, ignore_offset, target_utc_offset) else raise ArgumentError, "#{value.class} values are not supported" unless is_time_like?(value) time_like = true for_time_like(value, ignore_offset, target_utc_offset) end if block_given? result = yield timestamp raise ArgumentError, 'block must return a Timestamp' unless result.kind_of?(Timestamp) case value when Time result.to_time when DateTime result.to_datetime else # A Time-like value or a Timestamp time_like ? result.to_time : result end else timestamp end end
When used without a block, returns a {Timestamp} representation of a given `Time`, `DateTime` or {Timestamp}. When called with a block, the {Timestamp} representation of `value` is passed to the block. The block must then return a {Timestamp}, which will be converted back to the type of the initial value. If the initial value was a {Timestamp}, the block result will be returned. If the initial value was a `DateTime`, a Gregorian `DateTime` will be returned. The UTC offset of `value` can either be preserved (the {Timestamp} representation will have the same UTC offset as `value`), ignored (the {Timestamp} representation will have no defined UTC offset), or treated as though it were UTC (the {Timestamp} representation will have a {utc_offset} of 0 and {utc?} will return `true`). @param value [Object] a `Time`, `DateTime` or {Timestamp}. @param offset [Symbol] either `:preserve` to preserve the offset of `value`, `:ignore` to ignore the offset of `value` and create a {Timestamp} with an unspecified offset, or `:treat_as_utc` to treat the offset of `value` as though it were UTC and create a UTC {Timestamp}. @yield [timestamp] if a block is provided, the {Timestamp} representation is passed to the block. @yieldparam timestamp [Timestamp] the {Timestamp} representation of `value`. @yieldreturn [Timestamp] a {Timestamp} to be converted back to the type of `value`. @return [Object] if called without a block, the {Timestamp} representation of `value`, otherwise the result of the block, converted back to the type of `value`.
for
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def utc(value, sub_second = 0) new(value, sub_second, :utc) end
Creates a new UTC {Timestamp}. @param value [Integer] the number of seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds. @param sub_second [Numeric] the fractional part of the second as either a `Rational` that is greater than or equal to 0 and less than 1, or the `Integer` 0. @raise [ArgumentError] if `value` is not an `Integer`. @raise [ArgumentError] if `sub_second` is not a `Rational`, or the `Integer` 0. @raise [RangeError] if `sub_second` is a `Rational` but that is less than 0 or greater than or equal to 1.
utc
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def new!(value, sub_second = 0, utc_offset = nil) result = allocate result.send(:initialize!, value, sub_second, utc_offset) result end
Constructs a new instance of `self` (i.e. {Timestamp} or a subclass of {Timestamp}) without validating the parameters. This method is used internally within {Timestamp} to avoid the overhead of checking parameters. @param value [Integer] the number of seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds. @param sub_second [Numeric] the fractional part of the second as either a `Rational` that is greater than or equal to 0 and less than 1, or the `Integer` 0. @param utc_offset [Object] either `nil` for a {Timestamp} without a specified offset, an offset from UTC specified as an `Integer` number of seconds or the `Symbol` `:utc`). @return [Timestamp] a new instance of `self`.
new!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def for_time(time, ignore_offset, target_utc_offset) value = time.to_i sub_second = time.subsec if ignore_offset utc_offset = target_utc_offset value += time.utc_offset elsif time.utc? utc_offset = :utc else utc_offset = time.utc_offset end new!(value, sub_second, utc_offset) end
Creates a {Timestamp} that represents a given `Time`, optionally ignoring the offset. @param time [Time] a `Time`. @param ignore_offset [Boolean] whether to ignore the offset of `time`. @param target_utc_offset [Object] if `ignore_offset` is `true`, the UTC offset of the result (`:utc`, `nil` or an `Integer`). @return [Timestamp] the {Timestamp} representation of `time`.
for_time
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def for_datetime(datetime, ignore_offset, target_utc_offset) value = (datetime.jd - JD_EPOCH) * 86400 + datetime.sec + datetime.min * 60 + datetime.hour * 3600 sub_second = datetime.sec_fraction if ignore_offset utc_offset = target_utc_offset else utc_offset = (datetime.offset * 86400).to_i value -= utc_offset end new!(value, sub_second, utc_offset) end
Creates a {Timestamp} that represents a given `DateTime`, optionally ignoring the offset. @param datetime [DateTime] a `DateTime`. @param ignore_offset [Boolean] whether to ignore the offset of `datetime`. @param target_utc_offset [Object] if `ignore_offset` is `true`, the UTC offset of the result (`:utc`, `nil` or an `Integer`). @return [Timestamp] the {Timestamp} representation of `datetime`.
for_datetime
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def for_timestamp(timestamp, ignore_offset, target_utc_offset) if ignore_offset if target_utc_offset unless target_utc_offset == :utc && timestamp.utc? || timestamp.utc_offset == target_utc_offset return new!(timestamp.value + (timestamp.utc_offset || 0), timestamp.sub_second, target_utc_offset) end elsif timestamp.utc_offset return new!(timestamp.value + timestamp.utc_offset, timestamp.sub_second) end end unless timestamp.instance_of?(Timestamp) # timestamp is identical in value, sub_second and utc_offset but is a # subclass (i.e. TimestampWithOffset). Return a new Timestamp # instance. return new!(timestamp.value, timestamp.sub_second, timestamp.utc? ? :utc : timestamp.utc_offset) end timestamp end
Returns a {Timestamp} that represents another {Timestamp}, optionally ignoring the offset. If the result would be identical to `value`, the same instance is returned. If the passed in value is an instance of a subclass of {Timestamp}, then a new {Timestamp} will always be returned. @param timestamp [Timestamp] a {Timestamp}. @param ignore_offset [Boolean] whether to ignore the offset of `timestamp`. @param target_utc_offset [Object] if `ignore_offset` is `true`, the UTC offset of the result (`:utc`, `nil` or an `Integer`). @return [Timestamp] a [Timestamp] representation of `timestamp`.
for_timestamp
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def is_time_like?(value) value.respond_to?(:to_i) && value.respond_to?(:subsec) end
Determines if an object is like a `Time` (for the purposes of converting to a {Timestamp} with {for}), responding to `to_i` and `subsec`. @param value [Object] an object to test. @return [Boolean] `true` if the object is `Time`-like, otherwise `false`.
is_time_like?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def for_time_like(time_like, ignore_offset, target_utc_offset) value = time_like.to_i sub_second = time_like.subsec.to_r if ignore_offset utc_offset = target_utc_offset value += time_like.utc_offset.to_i if time_like.respond_to?(:utc_offset) elsif time_like.respond_to?(:utc_offset) utc_offset = time_like.utc_offset.to_i else utc_offset = 0 end new(value, sub_second, utc_offset) end
Creates a {Timestamp} that represents a given `Time`-like object, optionally ignoring the offset (if the `time_like` responds to `utc_offset`). @param time_like [Object] a `Time`-like object. @param ignore_offset [Boolean] whether to ignore the offset of `time`. @param target_utc_offset [Object] if `ignore_offset` is `true`, the UTC offset of the result (`:utc`, `nil` or an `Integer`). @return [Timestamp] the {Timestamp} representation of `time_like`.
for_time_like
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def initialize(value, sub_second = 0, utc_offset = nil) raise ArgumentError, 'value must be an Integer' unless value.kind_of?(Integer) raise ArgumentError, 'sub_second must be a Rational or the Integer 0' unless (sub_second.kind_of?(Integer) && sub_second == 0) || sub_second.kind_of?(Rational) raise RangeError, 'sub_second must be >= 0 and < 1' if sub_second < 0 || sub_second >= 1 raise ArgumentError, 'utc_offset must be an Integer, :utc or nil' if utc_offset && utc_offset != :utc && !utc_offset.kind_of?(Integer) initialize!(value, sub_second, utc_offset) end
Initializes a new {Timestamp}. @param value [Integer] the number of seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds. @param sub_second [Numeric] the fractional part of the second as either a `Rational` that is greater than or equal to 0 and less than 1, or the `Integer` 0. @param utc_offset [Object] either `nil` for a {Timestamp} without a specified offset, an offset from UTC specified as an `Integer` number of seconds or the `Symbol` `:utc`). @raise [ArgumentError] if `value` is not an `Integer`. @raise [ArgumentError] if `sub_second` is not a `Rational`, or the `Integer` 0. @raise [RangeError] if `sub_second` is a `Rational` but that is less than 0 or greater than or equal to 1. @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer` and not the `Symbol` `:utc`.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def add_and_set_utc_offset(seconds, utc_offset) raise ArgumentError, 'seconds must be an Integer' unless seconds.kind_of?(Integer) raise ArgumentError, 'utc_offset must be an Integer, :utc or nil' if utc_offset && utc_offset != :utc && !utc_offset.kind_of?(Integer) return self if seconds == 0 && utc_offset == (@utc ? :utc : @utc_offset) Timestamp.send(:new!, @value + seconds, @sub_second, utc_offset) end
Adds a number of seconds to the {Timestamp} value, setting the UTC offset of the result. @param seconds [Integer] the number of seconds to be added. @param utc_offset [Object] either `nil` for a {Timestamp} without a specified offset, an offset from UTC specified as an `Integer` number of seconds or the `Symbol` `:utc`). @return [Timestamp] the result of adding `seconds` to the {Timestamp} value as a new {Timestamp} instance with the chosen `utc_offset`. @raise [ArgumentError] if `seconds` is not an `Integer`. @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer` and not the `Symbol` `:utc`.
add_and_set_utc_offset
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def utc return self if @utc Timestamp.send(:new!, @value, @sub_second, :utc) end
@return [Timestamp] a UTC {Timestamp} equivalent to this instance. Returns `self` if {#utc? self.utc?} is `true`.
utc
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def to_time time = new_time if @utc_offset && !@utc time.localtime(@utc_offset) else time.utc end end
Converts this {Timestamp} to a `Time`. @return [Time] a `Time` representation of this {Timestamp}. If the UTC offset of this {Timestamp} is not specified, a UTC `Time` will be returned.
to_time
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def strftime(format) raise ArgumentError, 'format must be specified' unless format to_time.strftime(format) end
Formats this {Timestamp} according to the directives in the given format string. @param format [String] the format string. Please refer to `Time#strftime` for a list of supported format directives. @return [String] the formatted {Timestamp}. @raise [ArgumentError] if `format` is not specified.
strftime
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def to_s return value_and_sub_second_to_s unless @utc_offset return "#{value_and_sub_second_to_s} UTC" if @utc sign = @utc_offset >= 0 ? '+' : '-' min, sec = @utc_offset.abs.divmod(60) hour, min = min.divmod(60) "#{value_and_sub_second_to_s(@utc_offset)} #{sign}#{'%02d' % hour}:#{'%02d' % min}#{sec > 0 ? ':%02d' % sec : nil}#{@utc_offset != 0 ? " (#{value_and_sub_second_to_s} UTC)" : nil}" end
@return [String] a `String` representation of this {Timestamp}.
to_s
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def hash [@value, @sub_second, !!@utc_offset].hash end
@return [Integer] a hash based on the value, sub-second and whether there is a defined UTC offset.
hash
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def inspect "#<#{self.class}: @value=#{@value}, @sub_second=#{@sub_second}, @utc_offset=#{@utc_offset.inspect}, @utc=#{@utc.inspect}>" end
@return [String] the internal object state as a programmer-readable `String`.
inspect
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def new_time(klass = Time) klass.at(@value, @sub_second * 1_000_000) end
Creates a new instance of a `Time` or `Time`-like class matching the {value} and {sub_second} of this {Timestamp}, but not setting the offset. @param klass [Class] the class to instantiate. @private
new_time
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def new_datetime(klass = DateTime) # Can't specify the start parameter unless the jd parameter is an exact number of days. # Use #gregorian instead. datetime = klass.jd(JD_EPOCH + ((@value.to_r + @sub_second) / 86400)).gregorian @utc_offset && @utc_offset != 0 ? datetime.new_offset(Rational(@utc_offset, 86400)) : datetime end
Constructs a new instance of a `DateTime` or `DateTime`-like class with the same {value}, {sub_second} and {utc_offset} as this {Timestamp}. @param klass [Class] the class to instantiate. @private
new_datetime
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def value_and_sub_second_to_s(offset = 0) "#{@value + offset}#{sub_second_to_s}" end
Converts the value and sub-seconds to a `String`, adding on the given offset. @param offset [Integer] the offset to add to the value. @return [String] the value and sub-seconds.
value_and_sub_second_to_s
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def sub_second_to_s if @sub_second == 0 '' else " #{@sub_second.numerator}/#{@sub_second.denominator}" end end
Converts the {sub_second} value to a `String` suitable for appending to the `String` representation of a {Timestamp}. @return [String] a `String` representation of {sub_second}.
sub_second_to_s
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def initialize!(value, sub_second = 0, utc_offset = nil) @value = value # Convert Rational(0,1) to 0. @sub_second = sub_second == 0 ? 0 : sub_second if utc_offset @utc = utc_offset == :utc @utc_offset = @utc ? 0 : utc_offset else @utc = @utc_offset = nil end end
Initializes a new {Timestamp} without validating the parameters. This method is used internally within {Timestamp} to avoid the overhead of checking parameters. @param value [Integer] the number of seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds. @param sub_second [Numeric] the fractional part of the second as either a `Rational` that is greater than or equal to 0 and less than 1, or the `Integer` 0. @param utc_offset [Object] either `nil` for a {Timestamp} without a specified offset, an offset from UTC specified as an `Integer` number of seconds or the `Symbol` `:utc`).
initialize!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp.rb
Apache-2.0
def set_timezone_offset(timezone_offset) raise ArgumentError, 'timezone_offset must be specified' unless timezone_offset raise ArgumentError, 'timezone_offset.observed_utc_offset does not match self.utc_offset' if utc? || utc_offset != timezone_offset.observed_utc_offset @timezone_offset = timezone_offset self end
Sets the associated {TimezoneOffset} of this {TimestampWithOffset}. @param timezone_offset [TimezoneOffset] a {TimezoneOffset} valid at the time and for the offset of this {TimestampWithOffset}. @return [TimestampWithOffset] `self`. @raise [ArgumentError] if `timezone_offset` is `nil`. @raise [ArgumentError] if {utc? self.utc?} is `true`. @raise [ArgumentError] if `timezone_offset.observed_utc_offset` does not equal `self.utc_offset`.
set_timezone_offset
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp_with_offset.rb
Apache-2.0
def to_time to = timezone_offset if to new_time(TimeWithOffset).set_timezone_offset(to) else super end end
An overridden version of {Timestamp#to_time} that, if there is an associated {TimezoneOffset}, returns a {TimeWithOffset} with that offset. @return [Time] if there is an associated {TimezoneOffset}, a {TimeWithOffset} representation of this {TimestampWithOffset}, otherwise a `Time` representation.
to_time
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp_with_offset.rb
Apache-2.0
def to_datetime to = timezone_offset if to new_datetime(DateTimeWithOffset).set_timezone_offset(to) else super end end
An overridden version of {Timestamp#to_datetime}, if there is an associated {TimezoneOffset}, returns a {DateTimeWithOffset} with that offset. @return [DateTime] if there is an associated {TimezoneOffset}, a {DateTimeWithOffset} representation of this {TimestampWithOffset}, otherwise a `DateTime` representation.
to_datetime
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timestamp_with_offset.rb
Apache-2.0
def get_proxies(identifiers) identifiers.collect {|identifier| get_proxy(identifier)} end
@param [Enumerable<String>] identifiers an `Enumerable` of time zone identifiers. @return [Array<TimezoneProxy>] an `Array` of {TimezoneProxy} instances corresponding to the given identifiers.
get_proxies
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def name # Don't use alias, as identifier gets overridden. identifier end
@return [String] the identifier of the time zone, for example, `"Europe/Paris"`.
name
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def inspect "#<#{self.class}: #{identifier}>" end
@return [String] the internal object state as a programmer-readable `String`.
inspect
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def period_for_utc(utc_time) raise ArgumentError, 'utc_time must be specified' unless utc_time period_for(Timestamp.for(utc_time, :treat_as_utc)) end
Returns the {TimezonePeriod} that is valid at a given time. The UTC offset of the `utc_time` parameter is ignored (it is treated as a UTC time). Use the {period_for} method instead if the UTC offset of the time needs to be taken into consideration. @param utc_time [Object] a `Time`, `DateTime` or {Timestamp}. @return [TimezonePeriod] the {TimezonePeriod} that is valid at `utc_time`. @raise [ArgumentError] if `utc_time` is `nil`.
period_for_utc
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def period_for_local(local_time, dst = Timezone.default_dst) raise ArgumentError, 'local_time must be specified' unless local_time local_time = Timestamp.for(local_time, :ignore) results = periods_for_local(local_time) if results.empty? raise PeriodNotFound, "#{local_time.strftime('%Y-%m-%d %H:%M:%S')} is an invalid local time." elsif results.size < 2 results.first else # ambiguous result try to resolve if !dst.nil? matches = results.find_all {|period| period.dst? == dst} results = matches if !matches.empty? end if results.size < 2 results.first else # still ambiguous, try the block if block_given? results = yield results end if results.is_a?(TimezonePeriod) results elsif results && results.size == 1 results.first else raise AmbiguousTime, "#{local_time.strftime('%Y-%m-%d %H:%M:%S')} is an ambiguous local time." end end end end
Returns the {TimezonePeriod} that is valid at the given local time. The UTC offset of the `local_time` parameter is ignored (it is treated as a time in the time zone represented by `self`). Use the {period_for} method instead if the the UTC offset of the time needs to be taken into consideration. _Warning:_ There are local times that have no equivalent UTC times (for example, during the transition from standard time to daylight savings time). There are also local times that have more than one UTC equivalent (for example, during the transition from daylight savings time to standard time). In the first case (no equivalent UTC time), a {PeriodNotFound} exception will be raised. In the second case (more than one equivalent UTC time), an {AmbiguousTime} exception will be raised unless the optional `dst` parameter or block handles the ambiguity. If the ambiguity is due to a transition from daylight savings time to standard time, the `dst` parameter can be used to select whether the daylight savings time or local time is used. For example, the following code would raise an {AmbiguousTime} exception: tz = TZInfo::Timezone.get('America/New_York') tz.period_for_local(Time.new(2004,10,31,1,30,0)) Specifying `dst = true` would select the daylight savings period from April to October 2004. Specifying `dst = false` would return the standard time period from October 2004 to April 2005. The `dst` parameter will not be able to resolve an ambiguity resulting from the clocks being set back without changing from daylight savings time to standard time. In this case, if a block is specified, it will be called to resolve the ambiguity. The block must take a single parameter - an `Array` of {TimezonePeriod}s that need to be resolved. The block can select and return a single {TimezonePeriod} or return `nil` or an empty `Array` to cause an {AmbiguousTime} exception to be raised. The default value of the `dst` parameter can be specified using {Timezone.default_dst=}. @param local_time [Object] a `Time`, `DateTime` or {Timestamp}. @param dst [Boolean] whether to resolve ambiguous local times by always selecting the period observing daylight savings time (`true`), always selecting the period observing standard time (`false`), or leaving the ambiguity unresolved (`nil`). @yield [periods] if the `dst` parameter did not resolve an ambiguity, an optional block is yielded to. @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all the {TimezonePeriod}s that still match `local_time` after applying the `dst` parameter. @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod} or an `Array` containing a chosen {TimezonePeriod}; to leave the ambiguity unresolved: an empty `Array`, an `Array` containing more than one {TimezonePeriod}, or `nil`. @return [TimezonePeriod] the {TimezonePeriod} that is valid at `local_time`. @raise [ArgumentError] if `local_time` is `nil`. @raise [PeriodNotFound] if `local_time` is not valid for the time zone (there is no equivalent UTC time). @raise [AmbiguousTime] if `local_time` was ambiguous for the time zone and the `dst` parameter or block did not resolve the ambiguity.
period_for_local
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def to_local(time) raise ArgumentError, 'time must be specified' unless time Timestamp.for(time) do |ts| TimestampWithOffset.set_timezone_offset(ts, period_for(ts).offset) end end
Converts a time to the local time for the time zone. The result will be of type {TimeWithOffset} (if passed a `Time`), {DateTimeWithOffset} (if passed a `DateTime`) or {TimestampWithOffset} (if passed a {Timestamp}). {TimeWithOffset}, {DateTimeWithOffset} and {TimestampWithOffset} are subclasses of `Time`, `DateTime` and {Timestamp} that provide additional information about the local result. Unlike {utc_to_local}, {to_local} takes the UTC offset of the given time into consideration. @param time [Object] a `Time`, `DateTime` or {Timestamp}. @return [Object] the local equivalent of `time` as a {TimeWithOffset}, {DateTimeWithOffset} or {TimestampWithOffset}. @raise [ArgumentError] if `time` is `nil`. @raise [ArgumentError] if `time` is a {Timestamp} that does not have a specified UTC offset.
to_local
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def utc_to_local(utc_time) raise ArgumentError, 'utc_time must be specified' unless utc_time Timestamp.for(utc_time, :treat_as_utc) do |ts| to_local(ts) end end
Converts a time in UTC to the local time for the time zone. The result will be of type {TimeWithOffset} (if passed a `Time`), {DateTimeWithOffset} (if passed a `DateTime`) or {TimestampWithOffset} (if passed a {Timestamp}). {TimeWithOffset}, {DateTimeWithOffset} and {TimestampWithOffset} are subclasses of `Time`, `DateTime` and {Timestamp} that provide additional information about the local result. The UTC offset of the `utc_time` parameter is ignored (it is treated as a UTC time). Use the {to_local} method instead if the the UTC offset of the time needs to be taken into consideration. @param utc_time [Object] a `Time`, `DateTime` or {Timestamp}. @return [Object] the local equivalent of `utc_time` as a {TimeWithOffset}, {DateTimeWithOffset} or {TimestampWithOffset}. @raise [ArgumentError] if `utc_time` is `nil`.
utc_to_local
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def local_to_utc(local_time, dst = Timezone.default_dst) raise ArgumentError, 'local_time must be specified' unless local_time Timestamp.for(local_time, :ignore) do |ts| period = if block_given? period_for_local(ts, dst) {|periods| yield periods } else period_for_local(ts, dst) end ts.add_and_set_utc_offset(-period.observed_utc_offset, :utc) end end
Converts a local time for the time zone to UTC. The result will either be a `Time`, `DateTime` or {Timestamp} according to the type of the `local_time` parameter. The UTC offset of the `local_time` parameter is ignored (it is treated as a time in the time zone represented by `self`). _Warning:_ There are local times that have no equivalent UTC times (for example, during the transition from standard time to daylight savings time). There are also local times that have more than one UTC equivalent (for example, during the transition from daylight savings time to standard time). In the first case (no equivalent UTC time), a {PeriodNotFound} exception will be raised. In the second case (more than one equivalent UTC time), an {AmbiguousTime} exception will be raised unless the optional `dst` parameter or block handles the ambiguity. If the ambiguity is due to a transition from daylight savings time to standard time, the `dst` parameter can be used to select whether the daylight savings time or local time is used. For example, the following code would raise an {AmbiguousTime} exception: tz = TZInfo::Timezone.get('America/New_York') tz.period_for_local(Time.new(2004,10,31,1,30,0)) Specifying `dst = true` would select the daylight savings period from April to October 2004. Specifying `dst = false` would return the standard time period from October 2004 to April 2005. The `dst` parameter will not be able to resolve an ambiguity resulting from the clocks being set back without changing from daylight savings time to standard time. In this case, if a block is specified, it will be called to resolve the ambiguity. The block must take a single parameter - an `Array` of {TimezonePeriod}s that need to be resolved. The block can select and return a single {TimezonePeriod} or return `nil` or an empty `Array` to cause an {AmbiguousTime} exception to be raised. The default value of the `dst` parameter can be specified using {Timezone.default_dst=}. @param local_time [Object] a `Time`, `DateTime` or {Timestamp}. @param dst [Boolean] whether to resolve ambiguous local times by always selecting the period observing daylight savings time (`true`), always selecting the period observing standard time (`false`), or leaving the ambiguity unresolved (`nil`). @yield [periods] if the `dst` parameter did not resolve an ambiguity, an optional block is yielded to. @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all the {TimezonePeriod}s that still match `local_time` after applying the `dst` parameter. @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod} or an `Array` containing a chosen {TimezonePeriod}; to leave the ambiguity unresolved: an empty `Array`, an `Array` containing more than one {TimezonePeriod}, or `nil`. @return [Object] the UTC equivalent of `local_time` as a `Time`, `DateTime` or {Timestamp}. @raise [ArgumentError] if `local_time` is `nil`. @raise [PeriodNotFound] if `local_time` is not valid for the time zone (there is no equivalent UTC time). @raise [AmbiguousTime] if `local_time` was ambiguous for the time zone and the `dst` parameter or block did not resolve the ambiguity.
local_to_utc
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def local_time(year, month = 1, day = 1, hour = 0, minute = 0, second = 0, sub_second = 0, dst = Timezone.default_dst, &block) local_timestamp(year, month, day, hour, minute, second, sub_second, dst, &block).to_time end
Creates a `Time` object based on the given (Gregorian calendar) date and time parameters. The parameters are interpreted as a local time in the time zone. The result has the appropriate `utc_offset`, `zone` and {TimeWithOffset#timezone_offset timezone_offset}. _Warning:_ There are time values that are not valid as local times in a time zone (for example, during the transition from standard time to daylight savings time). There are also time values that are ambiguous, occurring more than once with different offsets to UTC (for example, during the transition from daylight savings time to standard time). In the first case (an invalid local time), a {PeriodNotFound} exception will be raised. In the second case (more than one occurrence), an {AmbiguousTime} exception will be raised unless the optional `dst` parameter or block handles the ambiguity. If the ambiguity is due to a transition from daylight savings time to standard time, the `dst` parameter can be used to select whether the daylight savings time or local time is used. For example, the following code would raise an {AmbiguousTime} exception: tz = TZInfo::Timezone.get('America/New_York') tz.local_time(2004,10,31,1,30,0,0) Specifying `dst = true` would return a `Time` with a UTC offset of -4 hours and abbreviation EDT (Eastern Daylight Time). Specifying `dst = false` would return a `Time` with a UTC offset of -5 hours and abbreviation EST (Eastern Standard Time). The `dst` parameter will not be able to resolve an ambiguity resulting from the clocks being set back without changing from daylight savings time to standard time. In this case, if a block is specified, it will be called to resolve the ambiguity. The block must take a single parameter - an `Array` of {TimezonePeriod}s that need to be resolved. The block can select and return a single {TimezonePeriod} or return `nil` or an empty `Array` to cause an {AmbiguousTime} exception to be raised. The default value of the `dst` parameter can be specified using {Timezone.default_dst=}. @param year [Integer] the year. @param month [Integer] the month (1-12). @param day [Integer] the day of the month (1-31). @param hour [Integer] the hour (0-23). @param minute [Integer] the minute (0-59). @param second [Integer] the second (0-59). @param sub_second [Numeric] the fractional part of the second as either a `Rational` that is greater than or equal to 0 and less than 1, or the `Integer` 0. @param dst [Boolean] whether to resolve ambiguous local times by always selecting the period observing daylight savings time (`true`), always selecting the period observing standard time (`false`), or leaving the ambiguity unresolved (`nil`). @yield [periods] if the `dst` parameter did not resolve an ambiguity, an optional block is yielded to. @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all the {TimezonePeriod}s that still match `local_time` after applying the `dst` parameter. @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod} or an `Array` containing a chosen {TimezonePeriod}; to leave the ambiguity unresolved: an empty `Array`, an `Array` containing more than one {TimezonePeriod}, or `nil`. @return [TimeWithOffset] a new `Time` object based on the given values, interpreted as a local time in the time zone. @raise [ArgumentError] if either of `year`, `month`, `day`, `hour`, `minute`, or `second` is not an `Integer`. @raise [ArgumentError] if `sub_second` is not a `Rational`, or the `Integer` 0. @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer` and not the `Symbol` `:utc`. @raise [RangeError] if `month` is not between 1 and 12. @raise [RangeError] if `day` is not between 1 and 31. @raise [RangeError] if `hour` is not between 0 and 23. @raise [RangeError] if `minute` is not between 0 and 59. @raise [RangeError] if `second` is not between 0 and 59. @raise [RangeError] if `sub_second` is a `Rational` but that is less than 0 or greater than or equal to 1. @raise [PeriodNotFound] if the date and time parameters do not specify a valid local time in the time zone. @raise [AmbiguousTime] if the date and time parameters are ambiguous for the time zone and the `dst` parameter or block did not resolve the ambiguity.
local_time
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def local_datetime(year, month = 1, day = 1, hour = 0, minute = 0, second = 0, sub_second = 0, dst = Timezone.default_dst, &block) local_timestamp(year, month, day, hour, minute, second, sub_second, dst, &block).to_datetime end
Creates a `DateTime` object based on the given (Gregorian calendar) date and time parameters. The parameters are interpreted as a local time in the time zone. The result has the appropriate `offset` and {DateTimeWithOffset#timezone_offset timezone_offset}. _Warning:_ There are time values that are not valid as local times in a time zone (for example, during the transition from standard time to daylight savings time). There are also time values that are ambiguous, occurring more than once with different offsets to UTC (for example, during the transition from daylight savings time to standard time). In the first case (an invalid local time), a {PeriodNotFound} exception will be raised. In the second case (more than one occurrence), an {AmbiguousTime} exception will be raised unless the optional `dst` parameter or block handles the ambiguity. If the ambiguity is due to a transition from daylight savings time to standard time, the `dst` parameter can be used to select whether the daylight savings time or local time is used. For example, the following code would raise an {AmbiguousTime} exception: tz = TZInfo::Timezone.get('America/New_York') tz.local_datetime(2004,10,31,1,30,0,0) Specifying `dst = true` would return a `Time` with a UTC offset of -4 hours and abbreviation EDT (Eastern Daylight Time). Specifying `dst = false` would return a `Time` with a UTC offset of -5 hours and abbreviation EST (Eastern Standard Time). The `dst` parameter will not be able to resolve an ambiguity resulting from the clocks being set back without changing from daylight savings time to standard time. In this case, if a block is specified, it will be called to resolve the ambiguity. The block must take a single parameter - an `Array` of {TimezonePeriod}s that need to be resolved. The block can select and return a single {TimezonePeriod} or return `nil` or an empty `Array` to cause an {AmbiguousTime} exception to be raised. The default value of the `dst` parameter can be specified using {Timezone.default_dst=}. @param year [Integer] the year. @param month [Integer] the month (1-12). @param day [Integer] the day of the month (1-31). @param hour [Integer] the hour (0-23). @param minute [Integer] the minute (0-59). @param second [Integer] the second (0-59). @param sub_second [Numeric] the fractional part of the second as either a `Rational` that is greater than or equal to 0 and less than 1, or the `Integer` 0. @param dst [Boolean] whether to resolve ambiguous local times by always selecting the period observing daylight savings time (`true`), always selecting the period observing standard time (`false`), or leaving the ambiguity unresolved (`nil`). @yield [periods] if the `dst` parameter did not resolve an ambiguity, an optional block is yielded to. @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all the {TimezonePeriod}s that still match `local_time` after applying the `dst` parameter. @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod} or an `Array` containing a chosen {TimezonePeriod}; to leave the ambiguity unresolved: an empty `Array`, an `Array` containing more than one {TimezonePeriod}, or `nil`. @return [DateTimeWithOffset] a new `DateTime` object based on the given values, interpreted as a local time in the time zone. @raise [ArgumentError] if either of `year`, `month`, `day`, `hour`, `minute`, or `second` is not an `Integer`. @raise [ArgumentError] if `sub_second` is not a `Rational`, or the `Integer` 0. @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer` and not the `Symbol` `:utc`. @raise [RangeError] if `month` is not between 1 and 12. @raise [RangeError] if `day` is not between 1 and 31. @raise [RangeError] if `hour` is not between 0 and 23. @raise [RangeError] if `minute` is not between 0 and 59. @raise [RangeError] if `second` is not between 0 and 59. @raise [RangeError] if `sub_second` is a `Rational` but that is less than 0 or greater than or equal to 1. @raise [PeriodNotFound] if the date and time parameters do not specify a valid local time in the time zone. @raise [AmbiguousTime] if the date and time parameters are ambiguous for the time zone and the `dst` parameter or block did not resolve the ambiguity.
local_datetime
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def local_timestamp(year, month = 1, day = 1, hour = 0, minute = 0, second = 0, sub_second = 0, dst = Timezone.default_dst, &block) ts = Timestamp.create(year, month, day, hour, minute, second, sub_second) timezone_offset = period_for_local(ts, dst, &block).offset utc_offset = timezone_offset.observed_utc_offset TimestampWithOffset.new(ts.value - utc_offset, sub_second, utc_offset).set_timezone_offset(timezone_offset) end
Creates a {Timestamp} object based on the given (Gregorian calendar) date and time parameters. The parameters are interpreted as a local time in the time zone. The result has the appropriate {Timestamp#utc_offset utc_offset} and {TimestampWithOffset#timezone_offset timezone_offset}. _Warning:_ There are time values that are not valid as local times in a time zone (for example, during the transition from standard time to daylight savings time). There are also time values that are ambiguous, occurring more than once with different offsets to UTC (for example, during the transition from daylight savings time to standard time). In the first case (an invalid local time), a {PeriodNotFound} exception will be raised. In the second case (more than one occurrence), an {AmbiguousTime} exception will be raised unless the optional `dst` parameter or block handles the ambiguity. If the ambiguity is due to a transition from daylight savings time to standard time, the `dst` parameter can be used to select whether the daylight savings time or local time is used. For example, the following code would raise an {AmbiguousTime} exception: tz = TZInfo::Timezone.get('America/New_York') tz.local_timestamp(2004,10,31,1,30,0,0) Specifying `dst = true` would return a `Time` with a UTC offset of -4 hours and abbreviation EDT (Eastern Daylight Time). Specifying `dst = false` would return a `Time` with a UTC offset of -5 hours and abbreviation EST (Eastern Standard Time). The `dst` parameter will not be able to resolve an ambiguity resulting from the clocks being set back without changing from daylight savings time to standard time. In this case, if a block is specified, it will be called to resolve the ambiguity. The block must take a single parameter - an `Array` of {TimezonePeriod}s that need to be resolved. The block can select and return a single {TimezonePeriod} or return `nil` or an empty `Array` to cause an {AmbiguousTime} exception to be raised. The default value of the `dst` parameter can be specified using {Timezone.default_dst=}. @param year [Integer] the year. @param month [Integer] the month (1-12). @param day [Integer] the day of the month (1-31). @param hour [Integer] the hour (0-23). @param minute [Integer] the minute (0-59). @param second [Integer] the second (0-59). @param sub_second [Numeric] the fractional part of the second as either a `Rational` that is greater than or equal to 0 and less than 1, or the `Integer` 0. @param dst [Boolean] whether to resolve ambiguous local times by always selecting the period observing daylight savings time (`true`), always selecting the period observing standard time (`false`), or leaving the ambiguity unresolved (`nil`). @yield [periods] if the `dst` parameter did not resolve an ambiguity, an optional block is yielded to. @yieldparam periods [Array<TimezonePeriod>] an `Array` containing all the {TimezonePeriod}s that still match `local_time` after applying the `dst` parameter. @yieldreturn [Object] to resolve the ambiguity: a chosen {TimezonePeriod} or an `Array` containing a chosen {TimezonePeriod}; to leave the ambiguity unresolved: an empty `Array`, an `Array` containing more than one {TimezonePeriod}, or `nil`. @return [TimestampWithOffset] a new {Timestamp} object based on the given values, interpreted as a local time in the time zone. @raise [ArgumentError] if either of `year`, `month`, `day`, `hour`, `minute`, or `second` is not an `Integer`. @raise [ArgumentError] if `sub_second` is not a `Rational`, or the `Integer` 0. @raise [ArgumentError] if `utc_offset` is not `nil`, not an `Integer` and not the `Symbol` `:utc`. @raise [RangeError] if `month` is not between 1 and 12. @raise [RangeError] if `day` is not between 1 and 31. @raise [RangeError] if `hour` is not between 0 and 23. @raise [RangeError] if `minute` is not between 0 and 59. @raise [RangeError] if `second` is not between 0 and 59. @raise [RangeError] if `sub_second` is a `Rational` but that is less than 0 or greater than or equal to 1. @raise [PeriodNotFound] if the date and time parameters do not specify a valid local time in the time zone. @raise [AmbiguousTime] if the date and time parameters are ambiguous for the time zone and the `dst` parameter or block did not resolve the ambiguity.
local_timestamp
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def offsets_up_to(to, from = nil) raise ArgumentError, 'to must be specified' unless to to_timestamp = Timestamp.for(to) from_timestamp = from && Timestamp.for(from) transitions = transitions_up_to(to_timestamp, from_timestamp) if transitions.empty? # No transitions in the range, find the period that covers it. if from_timestamp # Use the from date as it is inclusive. period = period_for(from_timestamp) else # to is exclusive, so this can't be used with period_for. However, any # time earlier than to can be used. Subtract 1 hour. period = period_for(to_timestamp.add_and_set_utc_offset(-3600, :utc)) end [period.offset] else result = Set.new first = transitions.first result << first.previous_offset unless from_timestamp && first.at == from_timestamp transitions.each do |t| result << t.offset end result.to_a end end
Returns the unique offsets used by the time zone up to a given time (`to`) as an `Array` of {TimezoneOffset} instances. A from time may also be supplied using the `from` parameter. If from is not `nil`, only offsets used from that time onwards will be returned. Comparisons with `to` are exclusive. Comparisons with `from` are inclusive. @param to [Object] a `Time`, `DateTime` or {Timestamp} specifying the latest (exclusive) offset to return. @param from [Object] an optional `Time`, `DateTime` or {Timestamp} specifying the earliest (inclusive) offset to return. @return [Array<TimezoneOffsets>] the offsets that are used earlier than `to` and, if specified, at or later than `from`. Offsets may be returned in any order. @raise [ArgumentError] if `from` is specified and `to` is not greater than `from`. @raise [ArgumentError] is raised if `to` is `nil`. @raise [ArgumentError] if either `to` or `from` is a {Timestamp} with an unspecified offset.
offsets_up_to
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def current_time_and_period period = nil local_time = Timestamp.for(Time.now) do |ts| period = period_for(ts) TimestampWithOffset.set_timezone_offset(ts, period.offset) end [local_time, period] end
Returns the current local time and {TimezonePeriod} for the time zone as an `Array`. The first element is the time as a {TimeWithOffset}. The second element is the period. @return [Array] an `Array` containing the current {TimeWithOffset} for the time zone as the first element and the current {TimezonePeriod} for the time zone as the second element.
current_time_and_period
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def eql?(tz) self == tz end
@param tz [Object] an `Object` to compare this {Timezone} with. @return [Boolean] `true` if `tz` is an instance of {Timezone} and has the same {identifier} as `self`, otherwise `false`.
eql?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def raise_unknown_timezone raise UnknownTimezone, 'TZInfo::Timezone should not be constructed directly (use TZInfo::Timezone.get instead)' end
Raises an {UnknownTimezone} exception. @raise [UnknownTimezone] always.
raise_unknown_timezone
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone.rb
Apache-2.0
def initialize(base_utc_offset, std_offset, abbreviation) @base_utc_offset = base_utc_offset @std_offset = std_offset @abbreviation = abbreviation.freeze @observed_utc_offset = @base_utc_offset + @std_offset end
Initializes a new {TimezoneOffset}. {TimezoneOffset} instances should not normally be constructed manually. The passed in `abbreviation` instance will be frozen. @param base_utc_offset [Integer] the base offset from UTC in seconds. @param std_offset [Integer] the offset from standard time in seconds. @param abbreviation [String] the abbreviation identifying the offset.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_offset.rb
Apache-2.0
def dst? @std_offset != 0 end
Determines if daylight savings is in effect (i.e. if {std_offset} is non-zero). @return [Boolean] `true` if {std_offset} is non-zero, otherwise `false`.
dst?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_offset.rb
Apache-2.0
def eql?(toi) self == toi end
Determines if this {TimezoneOffset} is equal to another instance. @param toi [Object] the instance to test for equality. @return [Boolean] `true` if `toi` is a {TimezoneOffset} with the same {utc_offset}, {std_offset} and {abbreviation} as this {TimezoneOffset}, otherwise `false`.
eql?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_offset.rb
Apache-2.0
def hash [@base_utc_offset, @std_offset, @abbreviation].hash end
@return [Integer] a hash based on {utc_offset}, {std_offset} and {abbreviation}.
hash
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_offset.rb
Apache-2.0
def inspect "#<#{self.class}: @base_utc_offset=#{@base_utc_offset}, @std_offset=#{@std_offset}, @abbreviation=#{@abbreviation}>" end
@return [String] the internal object state as a programmer-readable `String`.
inspect
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_offset.rb
Apache-2.0
def initialize(offset) raise ArgumentError, 'offset must be specified' unless offset @offset = offset end
Initializes a {TimezonePeriod}. @param offset [TimezoneOffset] the offset that is observed for the period of time. @raise [ArgumentError] if `offset` is `nil`.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_period.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_period.rb
Apache-2.0
def raise_not_implemented(method_name) raise NotImplementedError, "Subclasses must override #{method_name}" end
Raises a {NotImplementedError} to indicate that subclasses should override a method. @raise [NotImplementedError] always.
raise_not_implemented
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_period.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_period.rb
Apache-2.0
def timestamp(transition) transition ? transition.at : nil end
@param transition [TimezoneTransition] a transition or `nil`. @return [Timestamp] the {Timestamp} representing when a transition occurs, or `nil` if `transition` is `nil`.
timestamp
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_period.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_period.rb
Apache-2.0
def timestamp_with_offset(transition) transition ? TimestampWithOffset.set_timezone_offset(transition.at, offset) : nil end
@param transition [TimezoneTransition] a transition or `nil`. @return [TimestampWithOffset] a {Timestamp} representing when a transition occurs with offset set to {#offset}, or `nil` if `transition` is `nil`.
timestamp_with_offset
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_period.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_period.rb
Apache-2.0
def initialize(identifier) super() @identifier = identifier @real_timezone = nil end
Initializes a new {TimezoneProxy}. The `identifier` parameter is not checked when initializing the proxy. It will be validated when the real {Timezone} instance is loaded. @param identifier [String] an IANA Time Zone Database time zone identifier.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_proxy.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_proxy.rb
Apache-2.0
def real_timezone # Thread-safety: It is possible that the value of @real_timezone may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @real_timezone is only # calculated once. unless @real_timezone result = Timezone.get(@identifier) return result if frozen? @real_timezone = result end @real_timezone end
Returns the real {Timezone} instance being proxied. The real {Timezone} is loaded using {Timezone.get} on the first access. @return [Timezone] the real {Timezone} instance being proxied.
real_timezone
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_proxy.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_proxy.rb
Apache-2.0
def initialize(offset, previous_offset, timestamp_value) @offset = offset @previous_offset = previous_offset @timestamp_value = timestamp_value end
Initializes a new {TimezoneTransition}. {TimezoneTransition} instances should not normally be constructed manually. @param offset [TimezoneOffset] the offset the transition changes to. @param previous_offset [TimezoneOffset] the offset the transition changes from. @param timestamp_value [Integer] when the transition occurs as a number of seconds since 1970-01-01 00:00:00 UTC ignoring leap seconds (i.e. each day is treated as if it were 86,400 seconds long).
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_transition.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_transition.rb
Apache-2.0
def local_end_at TimestampWithOffset.new(@timestamp_value, 0, @previous_offset.observed_utc_offset).set_timezone_offset(@previous_offset) end
Returns a {TimestampWithOffset} instance representing the local time when this transition causes the previous observance to end (calculated from {at} using {previous_offset}). To obtain the result as a `Time` or `DateTime`, call either {TimestampWithOffset#to_time to_time} or {TimestampWithOffset#to_datetime to_datetime} on the {TimestampWithOffset} instance that is returned. @return [TimestampWithOffset] the local time when this transition causes the previous observance to end.
local_end_at
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_transition.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_transition.rb
Apache-2.0
def local_start_at TimestampWithOffset.new(@timestamp_value, 0, @offset.observed_utc_offset).set_timezone_offset(@offset) end
Returns a {TimestampWithOffset} instance representing the local time when this transition causes the next observance to start (calculated from {at} using {offset}). To obtain the result as a `Time` or `DateTime`, call either {TimestampWithOffset#to_time to_time} or {TimestampWithOffset#to_datetime to_datetime} on the {TimestampWithOffset} instance that is returned. @return [TimestampWithOffset] the local time when this transition causes the next observance to start.
local_start_at
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_transition.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_transition.rb
Apache-2.0
def hash [@offset, @previous_offset, @timestamp_value].hash end
@return [Integer] a hash based on {offset}, {previous_offset} and {timestamp_value}.
hash
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_transition.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/timezone_transition.rb
Apache-2.0
def set_timezone_offset(timezone_offset) raise ArgumentError, 'timezone_offset must be specified' unless timezone_offset localtime(timezone_offset.observed_utc_offset) @timezone_offset = timezone_offset self end
Marks this {TimeWithOffset} as a local time with the UTC offset of a given {TimezoneOffset} and sets the associated {TimezoneOffset}. @param timezone_offset [TimezoneOffset] the {TimezoneOffset} to use to set the offset of this {TimeWithOffset}. @return [TimeWithOffset] `self`. @raise [ArgumentError] if `timezone_offset` is `nil`.
set_timezone_offset
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def dst? to = timezone_offset to ? to.dst? : super end
An overridden version of `Time#dst?` that, if there is an associated {TimezoneOffset}, returns the result of calling {TimezoneOffset#dst? dst?} on that offset. @return [Boolean] `true` if daylight savings time is being observed, otherwise `false`.
dst?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def getlocal(*args) # JRuby < 9.3 returns a Time in all cases. # JRuby >= 9.3 returns a Time when called with no arguments and a # TimeWithOffset with a timezone_offset assigned when called with an # offset argument. result = super result.clear_timezone_offset if result.kind_of?(TimeWithOffset) result end
An overridden version of `Time#getlocal` that clears the associated {TimezoneOffset} if the base implementation of `getlocal` returns a {TimeWithOffset}. @return [Time] a representation of the {TimeWithOffset} using either the local time zone or the given offset.
getlocal
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def gmtime super @timezone_offset = nil self end
An overridden version of `Time#gmtime` that clears the associated {TimezoneOffset}. @return [TimeWithOffset] `self`.
gmtime
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def localtime(*args) super @timezone_offset = nil self end
An overridden version of `Time#localtime` that clears the associated {TimezoneOffset}. @return [TimeWithOffset] `self`.
localtime
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def round(ndigits = 0) if_timezone_offset(super) {|o,t| self.class.at(t.to_i, t.subsec * 1_000_000).set_timezone_offset(o) } end
An overridden version of `Time#round` that, if there is an associated {TimezoneOffset}, returns a {TimeWithOffset} preserving that offset. @return [Time] the rounded time.
round
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def to_a if_timezone_offset(super) do |o,a| a[8] = o.dst? a[9] = o.abbreviation a end end
An overridden version of `Time#to_a`. The `isdst` (index 8) and `zone` (index 9) elements of the array are set according to the associated {TimezoneOffset}. @return [Array] an `Array` representation of the {TimeWithOffset}.
to_a
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def utc super @timezone_offset = nil self end
An overridden version of `Time#utc` that clears the associated {TimezoneOffset}. @return [TimeWithOffset] `self`.
utc
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def zone to = timezone_offset to ? to.abbreviation : super end
An overridden version of `Time#zone` that, if there is an associated {TimezoneOffset}, returns the {TimezoneOffset#abbreviation abbreviation} of that offset. @return [String] the {TimezoneOffset#abbreviation abbreviation} of the associated {TimezoneOffset}, or the result from `Time#zone` if there is no such offset.
zone
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def to_datetime if_timezone_offset(super) do |o,dt| offset = dt.offset result = DateTimeWithOffset.jd(dt.jd + dt.day_fraction - offset) result = result.new_offset(offset) unless offset == 0 result.set_timezone_offset(o) end end
An overridden version of `Time#to_datetime` that, if there is an associated {TimezoneOffset}, returns a {DateTimeWithOffset} with that offset. @return [DateTime] if there is an associated {TimezoneOffset}, a {DateTimeWithOffset} representation of this {TimeWithOffset}, otherwise a `Time` representation.
to_datetime
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def clear_timezone_offset @timezone_offset = nil self end
Clears the associated {TimezoneOffset}. @return [TimeWithOffset] `self`.
clear_timezone_offset
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/time_with_offset.rb
Apache-2.0
def initialize(start_transition, end_transition) if start_transition super(start_transition.offset) elsif end_transition super(end_transition.previous_offset) else raise ArgumentError, 'At least one of start_transition and end_transition must be specified' end @start_transition = start_transition @end_transition = end_transition end
Initializes a {TransitionsTimezonePeriod}. At least one of `start_transition` and `end_transition` must be specified. @param start_transition [TimezoneTransition] the transition that defines the start of the period, or `nil` if the start is unbounded. @param end_transition [TimezoneTransition] the transition that defines the end of the period, or `nil` if the end is unbounded. @raise [ArgumentError] if both `start_transition` and `end_transition` are `nil`.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transitions_timezone_period.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transitions_timezone_period.rb
Apache-2.0
def hash [@start_transition, @end_transition].hash end
@return [Integer] a hash based on {start_transition} and {end_transition}.
hash
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transitions_timezone_period.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transitions_timezone_period.rb
Apache-2.0
def inspect "#<#{self.class}: @start_transition=#{@start_transition.inspect}, @end_transition=#{@end_transition.inspect}>" end
@return [String] the internal object state as a programmer-readable `String`.
inspect
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transitions_timezone_period.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transitions_timezone_period.rb
Apache-2.0
def initialize(transition_at) raise ArgumentError, 'Invalid transition_at' unless transition_at.kind_of?(Integer) @transition_at = transition_at end
Initializes a new {TransitionRule}. @param transition_at [Integer] the time in seconds after midnight local time at which the transition occurs. @raise [ArgumentError] if `transition_at` is not an `Integer`.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transition_rule.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transition_rule.rb
Apache-2.0
def at(offset, year) day = get_day(offset, year) TimestampWithOffset.set_timezone_offset(Timestamp.for(day + @transition_at), offset) end
Calculates the time of the transition from a given offset on a given year. @param offset [TimezoneOffset] the current offset at the time the rule will transition. @param year [Integer] the year in which the transition occurs (local time). @return [TimestampWithOffset] the time at which the transition occurs.
at
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transition_rule.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transition_rule.rb
Apache-2.0
def initialize(day, transition_at) super(transition_at) raise ArgumentError, 'Invalid day' unless day.kind_of?(Integer) @seconds = day * 86400 end
Initializes a new {DayOfYearTransitionRule}. @param day [Integer] the day of the year on which the transition occurs. The precise meaning is defined by subclasses. @param transition_at [Integer] the time in seconds after midnight local time at which the transition occurs. @raise [ArgumentError] if `transition_at` is not an `Integer`. @raise [ArgumentError] if `day` is not an `Integer`.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transition_rule.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transition_rule.rb
Apache-2.0
def initialize(day, transition_at = 0) super(day, transition_at) raise ArgumentError, 'Invalid day' unless day >= 0 && day <= 365 end
Initializes a new {AbsoluteDayOfYearTransitionRule}. @param day [Integer] the zero-based day of the year on which the transition occurs (0 to 365 inclusive). @param transition_at [Integer] the time in seconds after midnight local time at which the transition occurs. @raise [ArgumentError] if `transition_at` is not an `Integer`. @raise [ArgumentError] if `day` is not an `Integer`. @raise [ArgumentError] if `day` is less than 0 or greater than 365.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transition_rule.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/tzinfo-2.0.6/lib/tzinfo/transition_rule.rb
Apache-2.0