Module: Vortex
- Defined in:
- lib/vortex_client.rb,
lib/vortex_client/person.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
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')
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
# File 'lib/vortex_client.rb', line 718 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 |