#######################################################
#
# Test strftime() against some GMT classes
#
#######################################################
body common control
{
  inputs => { "../../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

#######################################################
bundle agent init
{
  vars:
    # These classes don't depend on the locale
    # we require two digits to filter out GMT_Hr0 through 9
    # (note that %k has a leading space, so we can't use it below)
    "results" slist => classesmatching("^GMT_(Hr|Min|Yr)\d\d+$");

  files:
    "$(G.testfile).expected"
      create => "true",
      edit_line => init_insert;
}

bundle edit_line init_insert
{
  insert_lines:
    "$(init.results)";
}

#######################################################
bundle agent test
{
  vars:
    "vals"
      slist => {
        # note that %k has a leading space, don't use it
        strftime('gmtime', 'GMT_Hr%H', now()),
        strftime('gmtime', 'GMT_Min%M', now()),
        strftime('gmtime', 'GMT_Yr%Y', now()),
      };

  files:
    "$(G.testfile).actual"
      create => "true",
      edit_line => test_insert;
}

bundle edit_line test_insert
{
  insert_lines:
    "$(test.vals)";
}

#######################################################
bundle agent check
{
  methods:
    "any"
      usebundle => sorted_check_diff(
        "$(G.testfile).actual",
        "$(G.testfile).expected",
        "$(this.promise_filename)"
      );
}
