Sha256: 7b772cf20088c00b23f8e1c3a30d1e5cb4ba9c6361b5ec42ad2103aa56eea5a3

Contents?: true

Size: 1.14 KB

Versions: 23

Compression:

Stored size: 1.14 KB

Contents

# (Documentation in 3.x stub)
#
# @since 4.8.0
#
Puppet::Functions.create_function(:strftime) do
  dispatch :format_timespan do
    param 'Timespan', :time_object
    param 'String', :format
  end

  dispatch :format_timestamp do
    param 'Timestamp', :time_object
    param 'String', :format
    optional_param 'String', :timezone
  end

  dispatch :legacy_strftime do
    param 'String', :format
    optional_param 'String', :timezone
  end

  def format_timespan(time_object, format)
    time_object.format(format)
  end

  def format_timestamp(time_object, format, timezone = nil)
    time_object.format(format, timezone)
  end

  def legacy_strftime(format, timezone = nil)
    stacktrace = Puppet::Pops::PuppetStack.stacktrace()
    if stacktrace.size > 0
      file, line = stacktrace[0]
    else
      file = nil
      line = nil
    end
    Puppet.warn_once('deprecations', 'legacy#strftime',
      _('The argument signature (String format, [String timezone]) is deprecated for #strftime. See #strftime documentation and Timespan type for more info'),
      file, line)
    Puppet::Pops::Time::Timestamp.format_time(format, Time.now.utc, timezone)
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
puppet-5.3.7 lib/puppet/functions/strftime.rb
puppet-5.3.7-x86-mingw32 lib/puppet/functions/strftime.rb
puppet-5.3.7-x64-mingw32 lib/puppet/functions/strftime.rb
puppet-5.3.7-universal-darwin lib/puppet/functions/strftime.rb
puppet-5.3.6 lib/puppet/functions/strftime.rb
puppet-5.3.6-x86-mingw32 lib/puppet/functions/strftime.rb
puppet-5.3.6-x64-mingw32 lib/puppet/functions/strftime.rb
puppet-5.3.6-universal-darwin lib/puppet/functions/strftime.rb
bolt-0.17.1 vendored/puppet/lib/puppet/functions/strftime.rb
bolt-0.17.0 vendored/puppet/lib/puppet/functions/strftime.rb
bolt-0.16.4 vendored/puppet/lib/puppet/functions/strftime.rb
bolt-0.16.3 vendored/puppet/lib/puppet/functions/strftime.rb
bolt-0.16.2 vendored/puppet/lib/puppet/functions/strftime.rb
puppet-5.4.0 lib/puppet/functions/strftime.rb
puppet-5.4.0-x86-mingw32 lib/puppet/functions/strftime.rb
puppet-5.4.0-x64-mingw32 lib/puppet/functions/strftime.rb
puppet-5.4.0-universal-darwin lib/puppet/functions/strftime.rb
puppet-5.3.5 lib/puppet/functions/strftime.rb
puppet-5.3.5-x86-mingw32 lib/puppet/functions/strftime.rb
puppet-5.3.5-x64-mingw32 lib/puppet/functions/strftime.rb