All files / nodes_items DateInfo.vue

100% Statements 23/23
100% Branches 4/4
100% Functions 3/3
100% Lines 23/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42      1x     1x 1x                     3x 3x 3x 4x               4x 4x   3x       3x       3x  
<template>
  <div>
    <div 
      v-if="date.start" 
      class="row mb-2"
    >
      <div class="col-4 text-left">
        <b>Start Date:</b>
      </div>
      <div class="col-8 text-right">
        {{ formatDate(props.date.start) }}
      </div>
    </div>
    <div 
      v-if="date.end" 
      class="row mb-2"
    >
      <div class="col-4 text-left">
        <b>End Date:</b>
      </div>
      <div class="col-8 text-right">
        {{ formatDate(props.date.end) }}
      </div>
    </div>
  </div>
</template>
 
<script setup>
  const props = defineProps({
    date: {
      type: Object,
      required: true,
    },
  });
 
  const formatDate = (dateString) => {
    const options = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', hour12: false };
    const formattedDate = new Date(dateString).toLocaleString('en-US', options);
    return formattedDate;
  }
</script>