diff --git a/Assets/Scripts/Date.cs b/Assets/Scripts/Date.cs index c87730d..5886c5d 100644 --- a/Assets/Scripts/Date.cs +++ b/Assets/Scripts/Date.cs @@ -8,6 +8,18 @@ public class Date private int month; private int day; + public Date(string date) { + date = date.Substring(0, date.Length - 14); + string[] sp = date.Split('-'); + year = int.Parse(sp[0]); + month = int.Parse(sp[1]); + day = int.Parse(sp[2]); + } + + public string printDate() { + return getYear() + "." + getMonth() + "." + getDay(); + } + public int getYear() { return year; } diff --git a/Assets/Scripts/Network/DatabaseData.cs b/Assets/Scripts/Network/DatabaseData.cs index 2576a3f..6c641a7 100644 --- a/Assets/Scripts/Network/DatabaseData.cs +++ b/Assets/Scripts/Network/DatabaseData.cs @@ -18,8 +18,7 @@ public class DatabaseData : MonoBehaviour } public void jsonParser(string jsondata) { - players = JsonUtility.FromJson("{\"player\":" + jsondata + "}"); - players.kiir(); + players = JsonUtility.FromJson("{\"player\":" + jsondata + "}"); } public void GetPlayerData() => StartCoroutine(IGetPlayerData()); @@ -39,9 +38,13 @@ public class DatabaseData : MonoBehaviour input.text = request.error; } else { jsondata = request.downloadHandler.text; - Debug.Log(jsondata); jsonParser(jsondata); - input.text = jsondata; + + input.text = ""; + foreach(var p in players.player) { + p.ConvertDate(); + input.text += "p_id: " + p.player_id + " username: " + p.player_name + " join date: " + p.joindate.printDate() + "\n"; + } } } } diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 5c8a0d9..0f34dcd 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -6,7 +6,12 @@ using UnityEngine; public class Player { public int player_id; public string player_name; - public string player_join_date; + public Date joindate; + public string player_join_date; + + public void ConvertDate() { //mindig meg kell hivni + joindate = new Date(player_join_date); + } } diff --git a/Assets/Scripts/PlayerList.cs b/Assets/Scripts/PlayerList.cs index d609e13..d3ef9da 100644 --- a/Assets/Scripts/PlayerList.cs +++ b/Assets/Scripts/PlayerList.cs @@ -6,10 +6,4 @@ using UnityEngine; public class PlayerList { public Player[] player; - - public void kiir() { - foreach(Player p in player) { - Debug.Log("p_id: " + p.player_id + " username" + p.player_join_date); - } - } }