mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
STAR-322: Improving configuration models interface
This commit is contained in:
parent
a1c252d3a2
commit
4f82a2759a
7 changed files with 278 additions and 183 deletions
|
@ -1,5 +1,8 @@
|
|||
from datetime import datetime, timedelta
|
||||
from typing import TypeVar, Dict, Tuple, List
|
||||
|
||||
from UM import i18nCatalog
|
||||
|
||||
T = TypeVar("T")
|
||||
U = TypeVar("U")
|
||||
|
||||
|
@ -24,3 +27,27 @@ def findChanges(previous: Dict[str, T], received: Dict[str, U]) -> Tuple[List[T]
|
|||
updated = [(previous[updated_id], received[updated_id]) for updated_id in updated_ids]
|
||||
|
||||
return removed, added, updated
|
||||
|
||||
|
||||
def formatTimeCompleted(time_remaining: int) -> str:
|
||||
completed = datetime.now() + timedelta(seconds=time_remaining)
|
||||
return "{hour:02d}:{minute:02d}".format(hour = completed.hour, minute = completed.minute)
|
||||
|
||||
|
||||
def formatDateCompleted(time_remaining: int) -> str:
|
||||
remaining = timedelta(seconds=time_remaining)
|
||||
completed = datetime.now() + remaining
|
||||
i18n = i18nCatalog("cura")
|
||||
|
||||
# If finishing date is more than 7 days out, using "Mon Dec 3 at HH:MM" format
|
||||
if remaining.days >= 7:
|
||||
return completed.strftime("%a %b ") + "{day}".format(day = completed.day)
|
||||
# If finishing date is within the next week, use "Monday at HH:MM" format
|
||||
elif remaining.days >= 2:
|
||||
return completed.strftime("%a")
|
||||
# If finishing tomorrow, use "tomorrow at HH:MM" format
|
||||
elif remaining.days >= 1:
|
||||
return i18n.i18nc("@info:status", "tomorrow")
|
||||
# If finishing today, use "today at HH:MM" format
|
||||
else:
|
||||
return i18n.i18nc("@info:status", "today")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue