<commit_before><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../kwc-i18n/kwc-i18n.html">

<dom-module id="kwc-date-format">
  <template>[[output]]</template>

  <script src="../moment/min/moment-with-locales.min.js"></script>
  <script>
    Polymer({
      is: "kwc-date-format",

      properties: {
        date: {
          type: String,
          value: null
        },

        inputFormat: {
          type: String,
          value: null
        },

        format: {
          type: String,
          value: null
        },

        locale: {
          type: String,
          value: null
        },

        output: {
          type: String,
          reflectToAttribute: true,
          readOnly: true,
          computed: "_computeOutput(date, inputFormat, format, locale)"
        }
      },

      _computeOutput: function(date, inputFormat, format, locale) {
        var datetime;
        if (date) {
          if (inputFormat) {
            datetime = moment(date, inputFormat);
          } else {
            datetime = moment(date);
          }
        } else {
          datetime = moment();
        }

        if (locale) {
          datetime.locale(locale);
        } else if (window.kwc_i18n.locale) {
          datetime.locale(window.kwc_i18n.locale);
        }

        if (format) {
          return datetime.format(format);
        } else {
          return datetime.toString();
        }
      }
    });
  </script>
</dom-module><commit_msg>Adds notify because of unchanged dates.<commit_after><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../kwc-i18n/kwc-i18n.html">

<dom-module id="kwc-date-format">
  <template>[[output]]</template>

  <script src="../moment/min/moment-with-locales.min.js"></script>
  <script>
    Polymer({
      is: "kwc-date-format",

      properties: {
        date: {
          type: String,
          value: null
        },

        inputFormat: {
          type: String,
          value: null
        },

        format: {
          type: String,
          value: null
        },

        locale: {
          type: String,
          value: null
        },

        output: {
          type: String,
          reflectToAttribute: true,
          readOnly: true,
          notify: true,
          computed: "_computeOutput(date, inputFormat, format, locale)"
        }
      },

      _computeOutput: function(date, inputFormat, format, locale) {
        var datetime;
        if (date) {
          if (inputFormat) {
            datetime = moment(date, inputFormat);
          } else {
            datetime = moment(date);
          }
        } else {
          datetime = moment();
        }

        if (locale) {
          datetime.locale(locale);
        } else if (window.kwc_i18n.locale) {
          datetime.locale(window.kwc_i18n.locale);
        }

        if (format) {
          return datetime.format(format);
        } else {
          return datetime.toString();
        }
      }
    });
  </script>
</dom-module>
{'fraction_non_alphanumeric': 0.13379355687047995, 'fraction_numerical': 0.005259697567389875, 'mean_word_length': 1.5127993393889347, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5731974', 'n_tokens_mistral': 899, 'n_tokens_neox': 869, 'n_words': 174}