mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-24 06:56:42 +00:00
Fix cannot import UTC
This commit is contained in:
parent
33499be425
commit
259d3a0155
@ -24,7 +24,7 @@ import aiofiles
|
|||||||
import zipfile
|
import zipfile
|
||||||
import time
|
import time
|
||||||
import aiohttp.web
|
import aiohttp.web
|
||||||
from datetime import datetime, timezone, UTC
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
from ..utils.asyncio import wait_run_in_executor
|
from ..utils.asyncio import wait_run_in_executor
|
||||||
from ..utils.asyncio import aiozipstream
|
from ..utils.asyncio import aiozipstream
|
||||||
@ -52,15 +52,15 @@ class Snapshot:
|
|||||||
self._project = project
|
self._project = project
|
||||||
if name:
|
if name:
|
||||||
self._name = name
|
self._name = name
|
||||||
self._created_at = datetime.now().timestamp()
|
self._created_at = datetime.now(timezone.utc).timestamp()
|
||||||
filename = self._name + "_" + datetime.fromtimestamp(self._created_at, UTC).replace(tzinfo=None).strftime(FILENAME_TIME_FORMAT) + ".gns3project"
|
filename = self._name + "_" + datetime.fromtimestamp(self._created_at, tz=timezone.utc).replace(tzinfo=None).strftime(FILENAME_TIME_FORMAT) + ".gns3project"
|
||||||
else:
|
else:
|
||||||
self._name = filename.split("_")[0]
|
self._name = filename.split("_")[0]
|
||||||
datestring = filename.replace(self._name + "_", "").split(".")[0]
|
datestring = filename.replace(self._name + "_", "").split(".")[0]
|
||||||
try:
|
try:
|
||||||
self._created_at = datetime.strptime(datestring, FILENAME_TIME_FORMAT).replace(tzinfo=timezone.utc).timestamp()
|
self._created_at = datetime.strptime(datestring, FILENAME_TIME_FORMAT).replace(tzinfo=timezone.utc).timestamp()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self._created_at = datetime.now(UTC)
|
self._created_at = datetime.now(timezone.utc)
|
||||||
self._path = os.path.join(project.path, "snapshots", filename)
|
self._path = os.path.join(project.path, "snapshots", filename)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
Reference in New Issue
Block a user