allow time edits

This commit is contained in:
2023-04-26 00:19:35 +02:00
parent 0b39a3fa5c
commit 24ae05c425
3 changed files with 86 additions and 6 deletions

View File

@ -47,6 +47,18 @@ static func time_to_period(time_in_secs: int) -> String:
return "%02d:%02d:%02d" % [hours, minutes, seconds]
static func period_to_time(period_string: String) -> int:
var period := period_string.split(":")
if period.size() < 3:
return -1
var hours := int(period[0])
var minutes := int(period[1])
var seconds := int(period[2])
var time := seconds + (minutes * 60) + (hours * 60 * 60)
return time
func to_csv_line() -> PoolStringArray:
return PoolStringArray([
name,

View File

@ -50,5 +50,24 @@ func from_string(time_string: String) -> TimeStamp:
return from_dict(time)
func from_unix_time(unix_time: int) -> TimeStamp:
var time := Time.get_datetime_dict_from_unix_time(unix_time)
return from_dict(time)
func equals(other) -> bool:
return (
other.year == year and \
other.month == month and \
other.day == day and \
other.weekday == weekday and \
other.hour == hour and \
other.minute == minute and \
other.second == second and \
other.unix == unix
)
func _to_string() -> String:
return Time.get_datetime_string_from_datetime_dict(to_dict(), false)