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

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')


688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# File 'lib/vortex_client.rb', line 688

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