package jfdi.ui;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import jfdi.storage.apis.TaskAttributes;

public class ListItem {

    private int index;
    private TaskAttributes item;
    private final BooleanProperty on = new SimpleBooleanProperty();

    public ListItem(int index, TaskAttributes task, boolean on) {
        setIndex(index);
        setTask(task);
        setOn(on);
    }

    public int getIndex() {
        return this.index;
    }

    public TaskAttributes getItem() {
        return this.item;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public final void setTask(TaskAttributes task) {
        this.item = task;
    }

    public final BooleanProperty onProperty() {
        return this.on;
    }

    public final boolean isOn() {
        return this.onProperty().get();
    }

    public final void setOn(final boolean on) {
        this.onProperty().set(on);
    }

    public void decIndex() {
        index--;
    }

    public void incIndex() {
        index++;
    }

    @Override
    public String toString() {
        String display = null;

        if (item.getStartDateTime() == null && item.getEndDateTime() == null) {
            // Floating Tasks
            display = " # " + index + " :  " + item.getDescription();
        } else if (item.getStartDateTime() == null && item.getEndDateTime() != null) {
            // Deadline Tasks
            display = " # " + index + " :  " + item.getDescription() + " by "
                    + item.getEndDateTime();
        } else if (item.getStartDateTime() != null && item.getEndDateTime() == null) {
            // Point Tasks
            display = " # " + index + " :  " + item.getDescription() + " at "
                    + item.getStartDateTime();
        } else if (item.getStartDateTime() != null && item.getEndDateTime() != null) {
            // Event Tasks
            display = " # " + index + " :  " + item.getDescription() + " from "
                    + item.getStartDateTime() + " to " + item.getEndDateTime();
        }

        return display;
    }

}

@@ -11,16 +11,97 @@
 di.ui;%0A%0A
+import java.time.format.DateTimeFormatter;%0Aimport java.time.format.FormatStyle;%0A%0A
 import j
@@ -130,32 +130,32 @@
 ooleanProperty;%0A
-
 import javafx.be
@@ -1245,16 +1245,103 @@
  = null;
+%0A        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(%22d MMM yyyy h:mma%22);
 %0A%0A      
@@ -1723,32 +1723,49 @@
               + 
+formatter.format(
 item.getEndDateT
@@ -1761,32 +1761,33 @@
 getEndDateTime()
+)
 ;%0A        %7D else
@@ -1978,32 +1978,49 @@
               + 
+formatter.format(
 item.getStartDat
@@ -2018,32 +2018,33 @@
 tStartDateTime()
+)
 ;%0A        %7D else
@@ -2245,16 +2245,33 @@
       + 
+formatter.format(
 item.get
@@ -2285,16 +2285,17 @@
 teTime()
+)
  + %22 to 
@@ -2294,24 +2294,41 @@
  + %22 to %22 + 
+formatter.format(
 item.getEndD
@@ -2336,16 +2336,17 @@
 teTime()
+)
 ;%0A      

Format datetime objects displayed on UI