diff options
author | Hunter Haugen <hunter@puppetlabs.com> | 2015-06-04 09:40:52 -0700 |
---|---|---|
committer | Hunter Haugen <hunter@puppetlabs.com> | 2015-06-04 09:40:52 -0700 |
commit | ad4ca4cc3486b0eaaa813595907521ce35c970ce (patch) | |
tree | 9a1a69b4bcd18b0ac74eeb017ea47b7cbd942b7e /lib/puppet/parser/functions | |
parent | f5f72f4b5a34e7a6c099f8fabdc55f79000b9a8b (diff) | |
download | puppet-stdlib-ad4ca4cc3486b0eaaa813595907521ce35c970ce.tar.gz puppet-stdlib-ad4ca4cc3486b0eaaa813595907521ce35c970ce.tar.bz2 |
Fix time() on 1.8.7
The time() function takes an argument of a timezone, and always returns
time in epoch format. The epoch format is the number of seconds that
have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
seconds. This means that it is universally the same regardless of
timezones.
I don't know what the timezone argument is supposed to do, and it is not
documented. So lets just make 1.8.7 work like > 1.8.7
Diffstat (limited to 'lib/puppet/parser/functions')
-rw-r--r-- | lib/puppet/parser/functions/time.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/puppet/parser/functions/time.rb b/lib/puppet/parser/functions/time.rb index 0cddaf8..c574747 100644 --- a/lib/puppet/parser/functions/time.rb +++ b/lib/puppet/parser/functions/time.rb @@ -33,13 +33,14 @@ Will return something like: 1311972653 ENV['TZ'] = time_zone - time = local_time.localtime + result = local_time.localtime.strftime('%s') ENV['TZ'] = original_zone + else + result = time.localtime.strftime('%s') end # Calling Time#to_i on a receiver changes it. Trust me I am the Doctor. - result = time.strftime('%s') result = result.to_i return result |