Class: Cel::Timestamp
- Defined in:
- lib/cel/ast/elements.rb
Instance Attribute Summary
Attributes inherited from Literal
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
-
#getDate(tz = nil) ⇒ Object
Cel Functions.
- #getDayOfMonth(tz = nil) ⇒ Object
- #getDayOfWeek(tz = nil) ⇒ Object
- #getDayOfYear(tz = nil) ⇒ Object
- #getFullYear(tz = nil) ⇒ Object
- #getHours(tz = nil) ⇒ Object
- #getMilliseconds(tz = nil) ⇒ Object
- #getMinutes(tz = nil) ⇒ Object
- #getMonth(tz = nil) ⇒ Object
- #getSeconds(tz = nil) ⇒ Object
-
#initialize(value) ⇒ Timestamp
constructor
A new instance of Timestamp.
Methods inherited from Literal
Constructor Details
Instance Method Details
#+(other) ⇒ Object
356 357 358 |
# File 'lib/cel/ast/elements.rb', line 356 def +(other) Timestamp.new(@value + other.to_f) end |
#-(other) ⇒ Object
360 361 362 363 364 365 366 367 |
# File 'lib/cel/ast/elements.rb', line 360 def -(other) case other when Timestamp Duration.new(@value - other.value) when Duration Timestamp.new(@value - other.to_f) end end |
#getDate(tz = nil) ⇒ Object
Cel Functions
379 380 381 |
# File 'lib/cel/ast/elements.rb', line 379 def getDate(tz = nil) to_local_time(tz).day end |
#getDayOfMonth(tz = nil) ⇒ Object
383 384 385 |
# File 'lib/cel/ast/elements.rb', line 383 def getDayOfMonth(tz = nil) getDate(tz) - 1 end |
#getDayOfWeek(tz = nil) ⇒ Object
387 388 389 |
# File 'lib/cel/ast/elements.rb', line 387 def getDayOfWeek(tz = nil) to_local_time(tz).wday end |
#getDayOfYear(tz = nil) ⇒ Object
391 392 393 |
# File 'lib/cel/ast/elements.rb', line 391 def getDayOfYear(tz = nil) to_local_time(tz).yday - 1 end |
#getFullYear(tz = nil) ⇒ Object
399 400 401 |
# File 'lib/cel/ast/elements.rb', line 399 def getFullYear(tz = nil) to_local_time(tz).year end |
#getHours(tz = nil) ⇒ Object
403 404 405 |
# File 'lib/cel/ast/elements.rb', line 403 def getHours(tz = nil) to_local_time(tz).hour end |
#getMilliseconds(tz = nil) ⇒ Object
415 416 417 |
# File 'lib/cel/ast/elements.rb', line 415 def getMilliseconds(tz = nil) to_local_time(tz).nsec / 1_000_000 end |
#getMinutes(tz = nil) ⇒ Object
407 408 409 |
# File 'lib/cel/ast/elements.rb', line 407 def getMinutes(tz = nil) to_local_time(tz).min end |
#getMonth(tz = nil) ⇒ Object
395 396 397 |
# File 'lib/cel/ast/elements.rb', line 395 def getMonth(tz = nil) to_local_time(tz).month - 1 end |
#getSeconds(tz = nil) ⇒ Object
411 412 413 |
# File 'lib/cel/ast/elements.rb', line 411 def getSeconds(tz = nil) to_local_time(tz).sec end |