|
4 | 4 |
|
5 | 5 | module Puppet::Parser::Functions
|
6 | 6 | newfunction(:strftime, :type => :rvalue, :doc => <<-EOS
|
| 7 | +This function returns formatted time. |
| 8 | +
|
| 9 | +*Examples:* |
| 10 | +
|
| 11 | +To return the time since epoch: |
| 12 | +
|
| 13 | + strftime("%s") |
| 14 | +
|
| 15 | +To return the date: |
| 16 | +
|
| 17 | + strftime("%Y-%m-%d") |
| 18 | +
|
| 19 | +*Format meaning:* |
| 20 | +
|
| 21 | + %a - The abbreviated weekday name (``Sun'') |
| 22 | + %A - The full weekday name (``Sunday'') |
| 23 | + %b - The abbreviated month name (``Jan'') |
| 24 | + %B - The full month name (``January'') |
| 25 | + %c - The preferred local date and time representation |
| 26 | + %C - Century (20 in 2009) |
| 27 | + %d - Day of the month (01..31) |
| 28 | + %D - Date (%m/%d/%y) |
| 29 | + %e - Day of the month, blank-padded ( 1..31) |
| 30 | + %F - Equivalent to %Y-%m-%d (the ISO 8601 date format) |
| 31 | + %h - Equivalent to %b |
| 32 | + %H - Hour of the day, 24-hour clock (00..23) |
| 33 | + %I - Hour of the day, 12-hour clock (01..12) |
| 34 | + %j - Day of the year (001..366) |
| 35 | + %k - hour, 24-hour clock, blank-padded ( 0..23) |
| 36 | + %l - hour, 12-hour clock, blank-padded ( 0..12) |
| 37 | + %L - Millisecond of the second (000..999) |
| 38 | + %m - Month of the year (01..12) |
| 39 | + %M - Minute of the hour (00..59) |
| 40 | + %n - Newline (\n) |
| 41 | + %N - Fractional seconds digits, default is 9 digits (nanosecond) |
| 42 | + %3N millisecond (3 digits) |
| 43 | + %6N microsecond (6 digits) |
| 44 | + %9N nanosecond (9 digits) |
| 45 | + %p - Meridian indicator (``AM'' or ``PM'') |
| 46 | + %P - Meridian indicator (``am'' or ``pm'') |
| 47 | + %r - time, 12-hour (same as %I:%M:%S %p) |
| 48 | + %R - time, 24-hour (%H:%M) |
| 49 | + %s - Number of seconds since 1970-01-01 00:00:00 UTC. |
| 50 | + %S - Second of the minute (00..60) |
| 51 | + %t - Tab character (\t) |
| 52 | + %T - time, 24-hour (%H:%M:%S) |
| 53 | + %u - Day of the week as a decimal, Monday being 1. (1..7) |
| 54 | + %U - Week number of the current year, |
| 55 | + starting with the first Sunday as the first |
| 56 | + day of the first week (00..53) |
| 57 | + %v - VMS date (%e-%b-%Y) |
| 58 | + %V - Week number of year according to ISO 8601 (01..53) |
| 59 | + %W - Week number of the current year, |
| 60 | + starting with the first Monday as the first |
| 61 | + day of the first week (00..53) |
| 62 | + %w - Day of the week (Sunday is 0, 0..6) |
| 63 | + %x - Preferred representation for the date alone, no time |
| 64 | + %X - Preferred representation for the time alone, no date |
| 65 | + %y - Year without a century (00..99) |
| 66 | + %Y - Year with century |
| 67 | + %z - Time zone as hour offset from UTC (e.g. +0900) |
| 68 | + %Z - Time zone name |
| 69 | + %% - Literal ``%'' character |
7 | 70 | EOS
|
8 | 71 | ) do |arguments|
|
9 | 72 |
|
|
0 commit comments