timerizer 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/timerizer.rb +13 -6
  2. metadata +1 -1
data/lib/timerizer.rb CHANGED
@@ -444,7 +444,7 @@ class WallClock
444
444
  raise TimeOutOfBoundsError
445
445
  end
446
446
 
447
- hour += 12 if meridiem == :pm
447
+ hour += 12 if (meridiem == :pm and !(hour == 12))
448
448
  end
449
449
 
450
450
  @seconds =
@@ -513,8 +513,14 @@ class WallClock
513
513
  # @return [Fixnum] The hour component of the WallClock
514
514
  def hour(system = :twenty_four_hour)
515
515
  hour = self.to_relative.hours
516
- if (system == :twelve_hour) && hour > 12
517
- hour - 12
516
+ if system == :twelve_hour
517
+ if hour == 0
518
+ 12
519
+ elsif hour > 12
520
+ hour - 12
521
+ else
522
+ hour
523
+ end
518
524
  elsif (system == :twenty_four_hour)
519
525
  hour
520
526
  else
@@ -525,7 +531,7 @@ class WallClock
525
531
  # Get the meridiem of the WallClock.
526
532
  # @return [Symbol] The meridiem (either `:am` or `:pm`)
527
533
  def meridiem
528
- if self.hour > 12
534
+ if self.hour > 12 || self.hour == 0
529
535
  :pm
530
536
  else
531
537
  :am
@@ -564,11 +570,12 @@ class WallClock
564
570
  # => "17:37:00"
565
571
  # @raise ArgumentError Argument isn't a proper system
566
572
  def to_s(system = :twelve_hour)
573
+ pad = "%02d"
567
574
  if(system == :twelve_hour)
568
575
  meridiem = self.meridiem.to_s.upcase
569
- "#{self.hour(system)}:#{self.minute}:#{self.second} #{meridiem}"
576
+ "#{self.hour(system)}:#{pad % self.minute}:#{pad % self.second} #{meridiem}"
570
577
  elsif(system == :twenty_four_hour)
571
- "#{self.hour(system)}:#{self.minute}:#{self.second}"
578
+ "#{self.hour(system)}:#{pad % self.minute}:#{pad % self.second}"
572
579
  else
573
580
  raise ArgumentError, "system should be :twelve_hour or :twenty_four_hour"
574
581
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timerizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: