Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-11404

Timestamp.new function doesn't support ISO 8601 week-based year and week number

    XMLWordPrintable

Details

    • Bug
    • Status: Accepted
    • Normal
    • Resolution: Unresolved
    • PUP 7.12.1
    • None
    • Types and Providers
    • None
    • Needs Assessment
    • Needs Assessment

    Description

      The following puppet code which used the ISO 8601 week-based year and week number parsing as indicated in the documentation fails

       

      notice(Timestamp.new('2022011', '%G%V%w')) 

      The error is the following:

      Error: Evaluation Error: Error while evaluating a Method call, no implicit conversion of nil into Integer (file: /tmp/test.pp, line: 1, column: 21) on node 

      Which is far from useful. This error seems to come from https://github.com/puppetlabs/puppet/blob/main/lib/puppet/pops/time/timestamp.rb#L106 where the code expect parsed datetime to have a :year entry, unfortunaly the hash doesn't have this key:

      irb(main):002:0> DateTime._strptime('2022011', '%G%V%w')
      => {:cwyear=>2022, :cweek=>1, :wday=>1} 

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            Gregoire Grégoire Menuel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Zendesk Support