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 "+
22 "given #{arguments.size} for 0 or 1")
27 # There is probably a better way to handle Time Zone ...
28 if time_zone and not time_zone.empty?
29 original_zone = ENV['TZ']
31 local_time = time.clone
32 local_time = local_time.utc
36 time = local_time.localtime
38 ENV['TZ'] = original_zone
41 # Calling Time#to_i on a receiver changes it. Trust me I am the Doctor.
42 result = time.strftime('%s')
49 # vim: set ts=2 sw=2 et :