mirror of https://github.com/jesopo/ircstates
switch datetimes to pendulum because stdlib doesnt handle timezones well
This commit is contained in:
parent
271cadf666
commit
56d047de8d
|
@ -1,5 +1,5 @@
|
|||
from datetime import datetime
|
||||
from typing import Dict, List, Optional, Set
|
||||
from typing import Dict, List, Optional, Set
|
||||
from pendulum import DateTime
|
||||
|
||||
from .named import Named
|
||||
from .channel_user import ChannelUser
|
||||
|
@ -11,9 +11,9 @@ class Channel(Named):
|
|||
|
||||
self.topic: Optional[str] = None
|
||||
self.topic_setter: Optional[str] = None
|
||||
self.topic_time: Optional[datetime] = None
|
||||
self.topic_time: Optional[DateTime] = None
|
||||
|
||||
self.created: Optional[datetime] = None
|
||||
self.created: Optional[DateTime] = None
|
||||
|
||||
self.list_modes: Dict[str, List[str]] = {}
|
||||
self.modes: Dict[str, Optional[str]] = {}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from typing import Callable, Dict, List, Optional, Set, Tuple
|
||||
from datetime import datetime
|
||||
from irctokens import build, Hostmask, Line, StatefulDecoder, StatefulEncoder
|
||||
from pendulum import from_timestamp, now
|
||||
|
||||
from .named import Named
|
||||
from .user import User
|
||||
|
@ -372,7 +372,7 @@ class Server(Named):
|
|||
if channel_lower in self.channels:
|
||||
channel = self.channels[channel_lower]
|
||||
emit.channel = channel
|
||||
channel.created = datetime.utcfromtimestamp(int(line.params[2]))
|
||||
channel.created = from_timestamp(int(line.params[2]))
|
||||
return emit
|
||||
|
||||
@line_handler("TOPIC")
|
||||
|
@ -384,7 +384,7 @@ class Server(Named):
|
|||
emit.channel = channel
|
||||
channel.topic = line.params[1]
|
||||
channel.topic_setter = str(line.hostmask)
|
||||
channel.topic_time = datetime.utcnow()
|
||||
channel.topic_time = now("utc")
|
||||
return emit
|
||||
|
||||
@line_handler(RPL_TOPIC)
|
||||
|
@ -406,7 +406,7 @@ class Server(Named):
|
|||
channel = self.channels[channel_lower]
|
||||
emit.channel = channel
|
||||
channel.topic_setter = line.params[2]
|
||||
channel.topic_time = datetime.utcfromtimestamp(int(line.params[3]))
|
||||
channel.topic_time = from_timestamp(int(line.params[3]))
|
||||
return emit
|
||||
|
||||
def _channel_modes(self,
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
irctokens ==1.0.0
|
||||
pendulum ==2.1.0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import unittest
|
||||
from datetime import datetime
|
||||
import pendulum
|
||||
import ircstates, irctokens
|
||||
|
||||
class ChannelTestJoin(unittest.TestCase):
|
||||
|
@ -91,7 +91,7 @@ class ChannelTestTopic(unittest.TestCase):
|
|||
self.assertEqual(server.channels["#chan"].topic, "test")
|
||||
|
||||
def test_set_by_at(self):
|
||||
dt = datetime.utcfromtimestamp(1584023277)
|
||||
dt = pendulum.datetime(2020, 3, 12, 14, 27, 57)
|
||||
server = ircstates.Server("test")
|
||||
server.parse_tokens(irctokens.tokenise("001 nickname"))
|
||||
server.parse_tokens(irctokens.tokenise(":nickname JOIN #chan"))
|
||||
|
@ -109,7 +109,7 @@ class ChannelTestTopic(unittest.TestCase):
|
|||
|
||||
class ChannelTestCreation(unittest.TestCase):
|
||||
def test(self):
|
||||
dt = datetime.utcfromtimestamp(1584041889)
|
||||
dt = pendulum.datetime(2020, 3, 12, 19, 38, 9)
|
||||
server = ircstates.Server("test")
|
||||
server.parse_tokens(irctokens.tokenise("001 nickname"))
|
||||
server.parse_tokens(irctokens.tokenise(":nickname JOIN #chan"))
|
||||
|
|
Loading…
Reference in New Issue