Skip to content

v0.7

Compare
Choose a tag to compare
@anykeyh anykeyh released this 28 May 07:44
· 237 commits to master since this release

v0.7

Features

  • Add Clear::Interval type

This type is related to the type Clear::Interval of PostgreSQL. It stores month, days and microseconds and can be used
with Time (Postgres' datetime) by adding or substracting it.

Examples:

Usage in Expression engine:

interval = Clear::Interval.new(months: 1, days: 1)

MyModel.query.where{ created_at - interval > updated_at  }.each do |model|
  # ...
end

It might be used as column definition, and added / removed to crystal Time object

class MyModel
  include Clear::Model

  column i : Clear::Interval
end

puts "Expected time: #{Time.now + MyModel.first!.i}"
  • Add Clear::TimeInDay columns type, which stands for the time object in PostgreSQL.

Examples:

Usage as stand alone:

time = Clear::TimeInDay.parse("12:33")
puts time.hour # 12
puts time.minutes # 0

Time.now.at(time) # Today at 12:33:00
time.to_s # 12:33:00
time.to_s(false) # don't show seconds => 12:33

time = time + 2.minutes #12:35

As with Interval, you might wanna use it as a column (use underlying time type in PostgreSQL):

class MyModel
  include Clear::Model

  column i : Clear::TimeInDay
end

Bug fixes