lib/hcl/day_entry.rb in zenhob-hcl-0.1.3 vs lib/hcl/day_entry.rb in zenhob-hcl-0.2.0

- old
+ new

@@ -1,23 +1,24 @@ class HCl class DayEntry < TimesheetResource + include Utility # Get the time sheet entries for a given day. If no date is provided # defaults to today. def self.all date = nil url = date.nil? ? 'daily' : "daily/#{date.strftime '%j/%Y'}" from_xml get(url) end def to_s - "#{client} #{project} #{task} (#{hours})" + "#{client} #{project} #{task} (#{formatted_hours})" end def self.from_xml xml doc = REXML::Document.new xml Task.cache_tasks doc - doc.root.elements.collect('*/day_entry') do |day| + doc.root.elements.collect('//day_entry') do |day| new xml_to_hash(day) end end # Append a string to the notes for this task. @@ -47,7 +48,13 @@ def toggle DayEntry.get("daily/timer/#{id}") self end + + # Returns the hours formatted as "HH:MM" + def formatted_hours + as_hours hours + end + end end