Module: Vortex
- Defined in:
- lib/vortex_client.rb,
lib/vortex_client/person.rb,
lib/vortex_client/utilities.rb,
lib/vortex_client/string_utils.rb
Overview
Utilities for managing content in the web content management system Vortex. All calls are done with the webdav protocol.
Defined Under Namespace
Classes: ArticleListingCollection, Collection, Connection, EventListingCollection, HtmlArticle, HtmlEvent, Person, PersonListingCollection, PlainFile, Resource, StringUtils, StructuredArticle, Utils
Instance Method Summary collapse
-
#norwegian_date(date) ⇒ Object
Utilities.
Instance Method Details
#norwegian_date(date) ⇒ Object
Utilities
Convert norwegian date to Time object with a forgiven regexp
TODO: Move this somewhere.
Examples:
t = norwegian_date('1.1.2010')
t = norwegian_date('22.01.2010')
t = norwegian_date('22.01.2010 12:15')
t = norwegian_date('22.01.2010 12:15:20')
760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 |
# File 'lib/vortex_client.rb', line 760 def norwegian_date(date) if /\A\s* (\d\d?).(\d\d?).(-?\d+) \s? (\d\d?)?:?(\d\d?)?:?(\d\d?)? \s*\z/ix =~ date year = $3.to_i mon = $2.to_i day = $1.to_i hour = $4.to_i min = $5.to_i sec = $6.to_i # puts "Debug: #{year} #{mon} #{day} #{hour}:#{min}:#{sec}" usec = 0 usec = $7.to_f * 1000000 if $7 if $8 zone = $8 year, mon, day, hour, min, sec = apply_offset(year, mon, day, hour, min, sec, zone_offset(zone)) Time.utc(year, mon, day, hour, min, sec, usec) else Time.local(year, mon, day, hour, min, sec, usec) end else raise ArgumentError.new("invalid date: #{date.inspect}") end end |