import { Component, h, Host, Prop } from '@stencil/core';
import moment from 'moment';
import { DateDataType } from '../date';
export class DvnFieldDisplayDate {
  render() {
    let date = this.value;
    if (this.field.dateDataType === DateDataType.ISO) {
      date = new Date(this.value);
    }
    else if (this.field.dateDataType === DateDataType.Unix) {
      date = new Date(this.value * 1000);
    }
    let formattedDate = '';
    if (this.value) {
      if (this.meta.timeZone) {
        formattedDate = moment(date).tz(this.meta.timeZone).format(this.field.dateFormat);
      }
      else {
        formattedDate = moment(date).format(this.field.dateFormat);
      }
    }
    return (h(Host, null, formattedDate));
  }
  static get is() { return "dvn-field-display-date"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["dvn-field-display-date.css"]
  }; }
  static get styleUrls() { return {
    "$": ["dvn-field-display-date.css"]
  }; }
  static get properties() { return {
    "value": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "number | string | Date",
        "resolved": "Date | number | string",
        "references": {
          "Date": {
            "location": "global"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "value",
      "reflect": false
    },
    "field": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "DateField",
        "resolved": "DateField",
        "references": {
          "DateField": {
            "location": "import",
            "path": "../date"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "meta": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "{ timeZone: string }",
        "resolved": "{ timeZone: string; }",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
}
