Changed to unix timestamps
This commit is contained in:
parent
b8acdd8e48
commit
20916ad13d
68
DBClasses.cs
68
DBClasses.cs
|
@ -20,27 +20,29 @@ namespace CryptoCalc
|
||||||
public string DBSaveDataString => $"({Regex.Replace(DBVariables, "@", "")}) values ({DBVariables})";
|
public string DBSaveDataString => $"({Regex.Replace(DBVariables, "@", "")}) values ({DBVariables})";
|
||||||
|
|
||||||
public int Index { get; set; }
|
public int Index { get; set; }
|
||||||
public int Year { get; set; }
|
public long UnixTime { get; set; }
|
||||||
public int Month { get; set; }
|
|
||||||
public int Day { get; set; }
|
|
||||||
public int Hour { get; set; }
|
|
||||||
public int Minute { get; set; }
|
|
||||||
public int Second { get; set; }
|
|
||||||
public string DateTimeString { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Functions
|
#region Functions
|
||||||
|
|
||||||
public void SaveDateTime()
|
public void SaveUnixTimeNow()
|
||||||
{
|
{
|
||||||
Year = DateTime.Now.Year;
|
UnixTime = (long)DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds;
|
||||||
Month = DateTime.Now.Month;
|
}
|
||||||
Day = DateTime.Now.Day;
|
|
||||||
Hour = DateTime.Now.Hour;
|
public long GetUnixTime(DateTime dateTime)
|
||||||
Minute = DateTime.Now.Minute;
|
{
|
||||||
Second = DateTime.Now.Second;
|
return (long)dateTime.Subtract(DateTime.UnixEpoch).TotalSeconds;
|
||||||
DateTimeString = DateTime.Now.ToString();
|
}
|
||||||
|
|
||||||
|
public DateTime GetUTCTimeFromUnixTime(long _unix)
|
||||||
|
{
|
||||||
|
return DateTime.UnixEpoch.AddSeconds(_unix).ToUniversalTime();
|
||||||
|
}
|
||||||
|
public DateTime GetLocalTimeFromUnixTime(long _unix)
|
||||||
|
{
|
||||||
|
return DateTime.UnixEpoch.AddSeconds(_unix).ToLocalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -70,7 +72,7 @@ namespace CryptoCalc
|
||||||
|
|
||||||
public Transaction(string _currency, float _amount, string _type)
|
public Transaction(string _currency, float _amount, string _type)
|
||||||
{
|
{
|
||||||
SaveDateTime();
|
SaveUnixTimeNow();
|
||||||
Currency = _currency;
|
Currency = _currency;
|
||||||
Amount = _amount;
|
Amount = _amount;
|
||||||
TransactionType = _type;
|
TransactionType = _type;
|
||||||
|
@ -83,7 +85,7 @@ namespace CryptoCalc
|
||||||
|
|
||||||
public Transaction(string _currency, float _amount, string _type, string _feeCurrency, float _feeAmount)
|
public Transaction(string _currency, float _amount, string _type, string _feeCurrency, float _feeAmount)
|
||||||
{
|
{
|
||||||
SaveDateTime();
|
SaveUnixTimeNow();
|
||||||
Currency = _currency;
|
Currency = _currency;
|
||||||
Amount = _amount;
|
Amount = _amount;
|
||||||
TransactionType = _type;
|
TransactionType = _type;
|
||||||
|
@ -102,13 +104,7 @@ namespace CryptoCalc
|
||||||
private void SetDBStrings()
|
private void SetDBStrings()
|
||||||
{
|
{
|
||||||
DBVariables =
|
DBVariables =
|
||||||
$"@{nameof(Year)},"
|
$"@{nameof(UnixTime)},"
|
||||||
+ $"@{nameof(Month)},"
|
|
||||||
+ $"@{nameof(Day)},"
|
|
||||||
+ $"@{nameof(Hour)},"
|
|
||||||
+ $"@{nameof(Minute)},"
|
|
||||||
+ $"@{nameof(Second)},"
|
|
||||||
+ $"@{nameof(DateTimeString)},"
|
|
||||||
+ $"@{nameof(Currency)},"
|
+ $"@{nameof(Currency)},"
|
||||||
+ $"@{nameof(Amount)},"
|
+ $"@{nameof(Amount)},"
|
||||||
+ $"@{nameof(TransactionType)},"
|
+ $"@{nameof(TransactionType)},"
|
||||||
|
@ -118,7 +114,7 @@ namespace CryptoCalc
|
||||||
+ $"@{nameof(Note)}";
|
+ $"@{nameof(Note)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public string FullInfo => $"{ Index.ToString() } { DateTimeString } { Currency } { Amount } { TransactionType }";
|
public string FullInfo => $"{ Index.ToString() } { GetLocalTimeFromUnixTime(UnixTime) } { Currency } { Amount } { TransactionType }";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -130,9 +126,7 @@ namespace CryptoCalc
|
||||||
public override string DBVariables { get => base.DBVariables; set => base.DBVariables = value; }
|
public override string DBVariables { get => base.DBVariables; set => base.DBVariables = value; }
|
||||||
public override string DBTableName => "Wallets";
|
public override string DBTableName => "Wallets";
|
||||||
|
|
||||||
public int CreationYear { get; set; }
|
public long UnixTimeCreated { get; set; }
|
||||||
public int CreationMonth { get; set; }
|
|
||||||
public int CreationDay { get; set; }
|
|
||||||
public string Platform { get; set; }
|
public string Platform { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Currency { get; set; }
|
public string Currency { get; set; }
|
||||||
|
@ -148,10 +142,8 @@ namespace CryptoCalc
|
||||||
|
|
||||||
public Wallet(int _year, int _month, int _day, string _platform, string _name, string _currency, float _balance, int _default, string _note)
|
public Wallet(int _year, int _month, int _day, string _platform, string _name, string _currency, float _balance, int _default, string _note)
|
||||||
{
|
{
|
||||||
SaveDateTime();
|
SaveUnixTimeNow();
|
||||||
CreationYear = _year;
|
UnixTimeCreated = GetUnixTime(new DateTime(_year, _month, _day));
|
||||||
CreationMonth = _month;
|
|
||||||
CreationDay = _day;
|
|
||||||
Platform = _platform;
|
Platform = _platform;
|
||||||
Name = _name;
|
Name = _name;
|
||||||
Currency = _currency;
|
Currency = _currency;
|
||||||
|
@ -169,16 +161,8 @@ namespace CryptoCalc
|
||||||
private void SetDBStrings()
|
private void SetDBStrings()
|
||||||
{
|
{
|
||||||
DBVariables =
|
DBVariables =
|
||||||
$"@{nameof(Year)},"
|
$"@{nameof(UnixTime)},"
|
||||||
+ $"@{nameof(Month)},"
|
+ $"@{nameof(UnixTimeCreated)},"
|
||||||
+ $"@{nameof(Day)},"
|
|
||||||
+ $"@{nameof(Hour)},"
|
|
||||||
+ $"@{nameof(Minute)},"
|
|
||||||
+ $"@{nameof(Second)},"
|
|
||||||
+ $"@{nameof(DateTimeString)},"
|
|
||||||
+ $"@{nameof(CreationYear)},"
|
|
||||||
+ $"@{nameof(CreationMonth)},"
|
|
||||||
+ $"@{nameof(CreationDay)},"
|
|
||||||
+ $"@{nameof(Platform)},"
|
+ $"@{nameof(Platform)},"
|
||||||
+ $"@{nameof(Name)},"
|
+ $"@{nameof(Name)},"
|
||||||
+ $"@{nameof(Currency)},"
|
+ $"@{nameof(Currency)},"
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace CryptoCalc
|
||||||
transactions = DBInteraction.LoadTransactions();
|
transactions = DBInteraction.LoadTransactions();
|
||||||
foreach (Transaction x in transactions)
|
foreach (Transaction x in transactions)
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"{x.DateTimeString} *** {x.Currency} - {x.Amount}");
|
Debug.WriteLine($"{x.GetLocalTimeFromUnixTime(x.UnixTime)} *** {x.Currency} - {x.Amount}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void searchButton_Click(object sender, RoutedEventArgs e)
|
private void searchButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
@ -54,7 +54,7 @@ namespace CryptoCalc
|
||||||
private Transaction DummyTransaction()
|
private Transaction DummyTransaction()
|
||||||
{
|
{
|
||||||
Transaction t = new();
|
Transaction t = new();
|
||||||
t.SaveDateTime();
|
t.SaveUnixTimeNow();
|
||||||
t.Currency = "SOL";
|
t.Currency = "SOL";
|
||||||
t.Amount = Convert.ToSingle(30 * rand.NextDouble());
|
t.Amount = Convert.ToSingle(30 * rand.NextDouble());
|
||||||
t.TransactionType = "BUY";
|
t.TransactionType = "BUY";
|
||||||
|
@ -66,12 +66,10 @@ namespace CryptoCalc
|
||||||
private Wallet DummyWallet()
|
private Wallet DummyWallet()
|
||||||
{
|
{
|
||||||
Wallet w = new();
|
Wallet w = new();
|
||||||
w.SaveDateTime();
|
w.SaveUnixTimeNow();
|
||||||
w.CreationYear = 2017;
|
w.UnixTimeCreated = w.GetUnixTime(new DateTime(2018,10,1));
|
||||||
w.CreationMonth = 08;
|
|
||||||
w.CreationDay = 20;
|
|
||||||
w.Platform = "Ledger";
|
w.Platform = "Ledger";
|
||||||
w.Name = "TestWalled";
|
w.Name = "TestWallet";
|
||||||
w.Currency = "SOL";
|
w.Currency = "SOL";
|
||||||
w.Balance = Convert.ToSingle(30 * rand.NextDouble());
|
w.Balance = Convert.ToSingle(30 * rand.NextDouble());
|
||||||
w.DefaultWallet = 0;
|
w.DefaultWallet = 0;
|
||||||
|
|
BIN
transactions.db
BIN
transactions.db
Binary file not shown.
BIN
wallets.db
BIN
wallets.db
Binary file not shown.
Loading…
Reference in New Issue