5 module Puppet::Parser::Functions
6 newfunction(:time, :type => :rvalue, :doc => <<-EOS
7 This function will return the current time since epoch as an integer.
13 Will return something like: 1311972653
17 # The Time Zone argument is optional ...
18 time_zone = arguments[0] if arguments[0]
20 if (arguments.size != 0) and (arguments.size != 1) then
21 raise(Puppet::ParseError, "time(): Wrong number of arguments given #{arguments.size} for 0 or 1")
26 # There is probably a better way to handle Time Zone ...
27 if time_zone and not time_zone.empty?
28 original_zone = ENV['TZ']
30 local_time = time.clone
31 local_time = local_time.utc
35 result = local_time.localtime.strftime('%s')
37 ENV['TZ'] = original_zone
39 result = time.localtime.strftime('%s')
42 # Calling Time#to_i on a receiver changes it. Trust me I am the Doctor.
49 # vim: set ts=2 sw=2 et :