Forge Home

datetime

Puppet function for timestamps.

2,086 downloads

1,790 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.0.1 (latest)
  • 1.0.0
released Oct 16th 2019
This version is compatible with:
  • Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2016.4.x
  • Puppet >= 4.10.0 < 7.0.0
  • , , , , , , , , , ,
This module has been deprecated by its author since Oct 31st 2019.

The reason given was: You can use the Puppet native strftime instead

Start using this module

Documentation

fervid/datetime — version 1.0.1 Oct 16th 2019

datetime

Table of Contents

  1. Description
  2. Setup - The basics of getting started with datetime
  3. Usage - Configuration options and additional functionality
  4. Limitations - OS compatibility, etc.
  5. Development - Guide for contributing to the module

Description

Function that returns 'current' timestamp as a string.

Setup

Beginning with datetime

Call the function like so datetime::date('%Y'). Passing the %Y returns the year.

$what_year_is_it = datetime::date('%Y')

Usage

Return an iso-8601 timestamp:

datetime::date() # No args

Return a YYYY-MM-DD timestamp:

datetime::date('%Y-%m-%d') # No args

Format options:

  • %a - The abbreviated weekday name (“Sun”)
  • %A - The full weekday name (“Sunday”)
  • %b - The abbreviated month name (“Jan”)
  • %B - The full month name (“January”)
  • %c - The preferred local date and time representation
  • %C - Century (20 in 2009)
  • %d - Day of the month (01..31)
  • %D - Date (%m/%d/%y)
  • %e - Day of the month, blank-padded ( 1..31)
  • %F - Equivalent to %Y-%m-%d (the ISO 8601 date format)
  • %h - Equivalent to %b
  • %H - Hour of the day, 24-hour clock (00..23)
  • %I - Hour of the day, 12-hour clock (01..12)
  • %j - Day of the year (001..366)
  • %k - hour, 24-hour clock, blank-padded ( 0..23)
  • %l - hour, 12-hour clock, blank-padded ( 0..12)
  • %L - Millisecond of the second (000..999)
  • %m - Month of the year (01..12)
  • %M - Minute of the hour (00..59)
  • %n - Newline (n)
  • %N - Fractional seconds digits
  • %p - Meridian indicator (“AM” or “PM”)
  • %P - Meridian indicator (“am” or “pm”)
  • %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
  • %r - time, 12-hour (same as %I:%M:%S %p)
  • %R - time, 24-hour (%H:%M)
  • %s - Number of seconds since 1970-01-01 00:00:00 UTC.
  • %S - Second of the minute (00..60)
  • %t - Tab character (t)
  • %T - time, 24-hour (%H:%M:%S)
  • %u - Day of the week as a decimal, Monday being 1. (1..7)
  • %U - Week number of the current year, starting with the first Sunday as the first day of the first week (00..53)
  • %v - VMS date (%e-%b-%Y)
  • %V - Week number of year according to ISO 8601 (01..53)
  • %W - Week number of the current year, starting with the first Monday as the first day of the first week (00..53)
  • %w - Day of the week (Sunday is 0, 0..6)
  • %x - Preferred representation for the date alone, no time
  • %X - Preferred representation for the time alone, no date
  • %y - Year without a century (00..99)
  • %Y - Year which may include century, if provided
  • %z - Time zone as hour offset from UTC (e.g. +0900)
  • %Z - Time zone name
  • %% - Literal “%” character
  • %+ - date(1) (%a %b %e %H:%M:%S %Z %Y)

Limitations

No limitations.

Development

We love contributions. Please make sure PDK validate passes before adding a pull request.