Reference documentation and code samples for the Cloud Spanner API class Google::Cloud::Spanner::Interval.
Interval
Represents an interval of time by storing the time components in months, days and nanoseconds.
Inherits
- Object
Example
require "google/cloud/spanner" iso_8601_string = "P1Y2M3DT4H5M6S" interval = Google::Cloud::Spanner::Interval::parse iso_8601_string puts interval # "P1Y2M3DT4H5M6S"
Methods
.from_days
def self.from_days(days) -> Interval
Returns an Interval instance with the given days.
- days (Integer)
- (Interval)
.from_microseconds
def self.from_microseconds(microseconds) -> Interval
Returns an Interval instance with the given microseconds.
- microseconds (Integer)
- (Interval)
.from_milliseconds
def self.from_milliseconds(milliseconds) -> Interval
Returns an Interval instance with the given milliseconds.
- milliseconds (Integer)
- (Interval)
.from_months
def self.from_months(months) -> Interval
Returns an Interval instance with the given months.
- months (Integer)
- (Interval)
.from_nanoseconds
def self.from_nanoseconds(nanoseconds) -> Interval
Returns an Interval instance with the given nanoseconds.
- nanoseconds (Integer)
- (Interval)
.from_seconds
def self.from_seconds(seconds) -> Interval
Returns an Interval instance with the given seconds.
- seconds (Integer)
- (Interval)
.parse
def self.parse(interval_string) -> Google::Cloud::Spanner::Interval
Parses an ISO8601 string and returns an Interval instance.
The accepted format for the ISO8601 standard is:
P[n]Y[n]M[n]DT[n]H[n]M[n[.fraction]]S
where n
represents an integer number.
- interval_string (String) — An ISO8601 formatted string.
- (ArgumentError)
require "google/cloud/spanner" iso_8601_string = "P1Y2M3DT4H5M6S" interval = Google::Cloud::Spanner::Interval::parse iso_8601_string puts interval # "P1Y2M3DT4H5M6S"
#==
def ==(other) -> Boolean
Standard value equality check for this object.
- other (Object) — An object to compare with.
- (Boolean)
#days
def days() -> Integer
- (Integer) — The numbers of days in the time interval.
#eql?
def eql?(other) -> Boolean
Standard value equality check for this object.
- other (Object) — An object to compare with.
- (Boolean)
#hash
def hash() -> Integer
Generate standard hash code for this object.
- (Integer)
#months
def months() -> Integer
- (Integer) — The numbers of months in the time interval.
#nanoseconds
def nanoseconds() -> Integer
- (Integer) — The numbers of nanoseconds in the time interval.
#to_s
def to_s() -> String
Converts the [Interval] to an ISO8601 Standard string.
- (String) — The interval's ISO8601 string representation.