player convert date working
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ public class DatabaseData : MonoBehaviour
|
||||
}
|
||||
|
||||
public void jsonParser(string jsondata) {
|
||||
players = JsonUtility.FromJson<PlayerList>("{\"player\":" + jsondata + "}");
|
||||
players.kiir();
|
||||
players = JsonUtility.FromJson<PlayerList>("{\"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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user