mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
fix playlist last update
+ create a recently added playlist on get api
This commit is contained in:
+8
-9
@@ -4,25 +4,24 @@ from datetime import datetime
|
||||
_format = "%Y-%m-%d %H:%M:%S"
|
||||
|
||||
|
||||
def create_new_date():
|
||||
def create_new_date(date: datetime = None) -> str:
|
||||
"""
|
||||
Creates a new date and time string in the format of "YYYY-MM-DD HH:MM:SS"
|
||||
:return: A string of the current date and time.
|
||||
"""
|
||||
now = datetime.now()
|
||||
return now.strftime(_format)
|
||||
if not date:
|
||||
date = datetime.now()
|
||||
|
||||
return date.strftime(_format)
|
||||
|
||||
|
||||
def date_string_to_time_passed(prev_date: str) -> str:
|
||||
"""
|
||||
Converts a date string to time passed. e.g. 2 minutes ago, 1 hour ago, yesterday, 2 days ago, 2 weeks ago, etc.
|
||||
"""
|
||||
now = datetime.now()
|
||||
then = datetime.strptime(prev_date, _format)
|
||||
now = datetime.now().timestamp()
|
||||
then = datetime.strptime(prev_date, _format).timestamp()
|
||||
|
||||
diff = now - then
|
||||
seconds = diff.seconds
|
||||
|
||||
now = pendulum.now()
|
||||
return now.subtract(seconds=seconds).diff_for_humans()
|
||||
|
||||
return now.subtract(seconds=diff).diff_for_humans()
|
||||
|
||||
Reference in New Issue
Block a user