«
Rule languages supports extensions to time classes
now = ZonedDateTime.now
logger.info("<a>.equals(<b>): #{<a>.equals(<b>)}")
a | b | result | |
---|---|---|---|
now.plus(1.minutes) | now + 1.minutes | true | |
now.minus_hours(2) | now - 2.hours | true |
now = LocalTime.now
logger.info("<a>.equals(<b>): #{<a>.equals(<b>)}")
a | b | result | |
---|---|---|---|
now.plus(1.minutes) | now + 1.minutes | true | |
now.minus_hours(2) | now - 2.hours | true |
now = Time.now
logger.info("<a> == <b>: #{<a> == <b>}")
a | b | result | |
---|---|---|---|
now + 60 | now + 1.minute | true | |
now - 3600 | now - 1.hour | true |
ruby_now = Time.now
zdt_now = ruby_now.to_java(ZonedDateTime)
logger.info("Comparison result: #{<comparison>}")
logger.info("#{zdt_now} / #{ruby_now} #{ruby_now.nsec}")
comparison | result | |
---|---|---|
zdt_now < zdt_now.plus_minutes(1) | true | |
zdt_now < Time.now + 100 | true | |
Time.now < Time.now.to_zdt.plus_hours(1) | true | |
Time.now + 10 < zdt_now | false | |
zdt_now.before?(Time.now + 10) | true | |
zdt_now.before?(Time.now - 10) | false | |
zdt_now == zdt_now | true | |
zdt_now == ruby_now | true | |
ruby_now == zdt_now | true | |
ruby_now != zdt_now | false |
ruby_now = TimeOfDay.now
lt_now = ruby_now.local_time
logger.info("Comparison result: #{<comparison>}")
logger.info("#{lt_now} / #{ruby_now}")
comparison | result | |
---|---|---|
LocalTime.now < LocalTime.now.plus_minutes(1) | true | |
LocalTime.now - 1.minute < TimeOfDay.now | true | |
TimeOfDay.now < LocalTime.now.plus_hours(1) | true | |
TimeOfDay.now < LocalTime.now - 1.second | false | |
lt_now == lt_now | true | |
lt_now == ruby_now | true | |
ruby_now == lt_now | true | |
ruby_now != lt_now | false |