This repository contains MadHelix itself, along with compiled libraries with its dependencies.
Clone
HTTPS:
git clone https://vervis.peers.community/repos/ZEkyo
SSH:
git clone USERNAME@vervis.peers.community:ZEkyo
Branches
Tags
SongLogEntry.java
/*
* MadHelix is a Java Swing-based GUI frontend for SoundHelix.
* Copyright (C) 2018 UltrasonicMadness
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 only,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.ultrasonicmadness.madhelix.models;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import org.json.simple.JSONObject;
public class SongLogEntry
{
public final String SONG_NAME;
public final String STYLE_NAME;
public final int LENGTH;
public final LocalDateTime TIME_PLAYED;
public SongLogEntry(JSONObject jsonEntry)
{
SONG_NAME = (String)jsonEntry.get("name");
STYLE_NAME = (String)jsonEntry.get("style");
LENGTH = ((Long)jsonEntry.get("length")).intValue();
JSONObject jsonDate = (JSONObject)jsonEntry.get("date");
int year = ((Long)jsonDate.get("year")).intValue();
int month = ((Long)jsonDate.get("month")).intValue();
int day = ((Long)jsonDate.get("day")).intValue();
int hour = ((Long)jsonDate.get("hour")).intValue();
int minute = ((Long)jsonDate.get("minute")).intValue();
int second = ((Long)jsonDate.get("second")).intValue();
TIME_PLAYED = LocalDateTime.of(year, month, day, hour, minute, second);
}
public SongLogEntry(String songName, String style, int length, LocalDateTime timePlayed)
{
SONG_NAME = songName;
STYLE_NAME = style;
LENGTH = length;
TIME_PLAYED = timePlayed;
}
public String getLengthAsString()
{
return String.format("%02d:%02d", LENGTH / 60, LENGTH % 60);
}
public String getTimePlayedAsString()
{
return TIME_PLAYED.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM));
}
@Override
public String toString()
{
return "'" + SONG_NAME + "' with style '" + STYLE_NAME +
"' was played on " + TIME_PLAYED;
}
}