Skip to content

Commit

Permalink
feat: Date.now and Array iter
Browse files Browse the repository at this point in the history
  • Loading branch information
JamzumSum committed Dec 1, 2023
1 parent 6fe872c commit bd13dce
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
36 changes: 18 additions & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pychaosvm"
version = "0.3.0"
version = "0.3.1"
description = "A Python envirionment for Tencent ChaosVM."
authors = ["aioqzone <[email protected]>"]
license = "AGPL-3.0-or-later"
Expand Down
17 changes: 14 additions & 3 deletions src/chaosvm/proxy/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def __init__(self, v: Union[int, str, None] = None) -> None:
else:
self.d = datetime.now(self.TZ)

@classmethod
def now(cls):
return cls()

def getTime(self):
return int(self.d.timestamp() * 1000)

Expand All @@ -138,6 +142,9 @@ def getTimezoneOffset(self):
return -int(offset.total_seconds() / 60)
return 0

def __sub__(self, o: Self) -> int:
return (self.d - o.d).seconds * 1000


class Number(Proxy):
def __init__(self, i) -> None:
Expand Down Expand Up @@ -271,16 +278,20 @@ def __init__(self, *args):
self[i] = k

def __len__(self):
return self.length
keys = [int(i) for i in self.__dict__ if i.isdigit()]
return max(keys) + 1 if keys else 0

def __iter__(self):
for i in range(self.length):
yield self[i]

def forEach(self, pred: Function):
for i in range(self.length):
pred(None, self[i])

@property
def length(self):
keys = [int(i) for i in self.__dict__ if i.isdigit()]
return max(keys) + 1 if keys else 0
return len(self)

@length.setter
def length(self, v: int):
Expand Down

0 comments on commit bd13dce

Please sign in to comment.