Skip to content

Commit

Permalink
Fixes #37282 - Adding the current_time macro
Browse files Browse the repository at this point in the history
  • Loading branch information
sayan3296 authored and jeremylenz committed Mar 21, 2024
1 parent 6c77d09 commit d309c1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/services/foreman/renderer/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Configuration
:shell_escape,
:join_with_line_break,
:current_date,
:current_time,
:truthy?,
:falsy?,
:previous_revision,
Expand Down
9 changes: 9 additions & 0 deletions app/services/foreman/renderer/scope/macros/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ def current_date(format: '%F')
Time.zone.today.strftime(format)
end

apipie :method, 'Returns current time' do
keyword :format, String, desc: 'Format string to format time according to the directives in this string', default: '%T %z'
returns String
example '<%= current_time %> #=> "21:05:09 +0530"'
end
def current_time(format: '%T %z')
Time.zone.now.strftime(format)
end

apipie :method, 'Checks whether a value is truthy or not' do
optional :value, Object, desc: 'Value to check'
returns one_of: [true, false], desc: 'Returns true if the value can be considered as truthy, false otherwise'
Expand Down

0 comments on commit d309c1f

Please sign in to comment.