Class: Mediaflux::Time
- Inherits:
 - 
      Object
      
        
- Object
 - Mediaflux::Time
 
 
- Defined in:
 - app/models/mediaflux/time.rb
 
Class Method Summary collapse
- 
  
    
      .format_date_for_mediaflux(iso8601_date)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Transform iso8601 dates to MediaFlux expected format.
 
Instance Method Summary collapse
- 
  
    
      #convert(xml_snip:)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Converts the givin time snippet into local princeton time while accounting for potential time zone of the asset.
 
Class Method Details
.format_date_for_mediaflux(iso8601_date) ⇒ Object
Transform iso8601 dates to MediaFlux expected format
      28 29 30 31  | 
    
      # File 'app/models/mediaflux/time.rb', line 28 def self.format_date_for_mediaflux(iso8601_date) return if iso8601_date.nil? Object::Time.zone.parse(iso8601_date).strftime("%e-%b-%Y %H:%M:%S").upcase end  | 
  
Instance Method Details
#convert(xml_snip:) ⇒ String
Converts the givin time snippet into local princeton time while accounting for potential time zone of the asset.
      8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  | 
    
      # File 'app/models/mediaflux/time.rb', line 8 def convert(xml_snip:) xml = xml_snip time = xml.text.to_time gmt = xml.xpath("./@gmt-offset").text.to_f if gmt.zero? return time.in_time_zone("America/New_York").iso8601 elsif gmt.positive? time -= gmt.hours else time += gmt.hours end princeton_time = time.in_time_zone("America/New_York").iso8601 princeton_time end  |