p1-dateutils 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- p1_dateutils-0.1.0/PKG-INFO +11 -0
- p1_dateutils-0.1.0/README.md +9 -0
- p1_dateutils-0.1.0/dateutils/__init__.py +0 -0
- p1_dateutils-0.1.0/dateutils/datetime_utils.py +226 -0
- p1_dateutils-0.1.0/p1_dateutils.egg-info/PKG-INFO +11 -0
- p1_dateutils-0.1.0/p1_dateutils.egg-info/SOURCES.txt +11 -0
- p1_dateutils-0.1.0/p1_dateutils.egg-info/dependency_links.txt +1 -0
- p1_dateutils-0.1.0/p1_dateutils.egg-info/not-zip-safe +1 -0
- p1_dateutils-0.1.0/p1_dateutils.egg-info/requires.txt +1 -0
- p1_dateutils-0.1.0/p1_dateutils.egg-info/top_level.txt +1 -0
- p1_dateutils-0.1.0/pyproject.toml +3 -0
- p1_dateutils-0.1.0/setup.cfg +4 -0
- p1_dateutils-0.1.0/setup.py +15 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: p1-dateutils
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Timezone Wrapper for Dekoruma Internal Use
|
|
5
|
+
Home-page:
|
|
6
|
+
Author: Engineering
|
|
7
|
+
Author-email: engineering@dekoruma.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Requires-Dist: django
|
|
10
|
+
|
|
11
|
+
Timezone Wrapper for Dekoruma Internal Use
|
|
File without changes
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from datetime import date as _date
|
|
3
|
+
from datetime import datetime as _datetime
|
|
4
|
+
from datetime import time as _time
|
|
5
|
+
from datetime import timedelta
|
|
6
|
+
from datetime import tzinfo
|
|
7
|
+
from typing import Any
|
|
8
|
+
from typing import Callable
|
|
9
|
+
from zoneinfo import ZoneInfo
|
|
10
|
+
|
|
11
|
+
from django.utils.timezone import get_default_timezone
|
|
12
|
+
if sys.version_info[0] < 3:
|
|
13
|
+
DEFAULT_TIMEZONE: tzinfo = get_default_timezone()
|
|
14
|
+
else:
|
|
15
|
+
DEFAULT_TIMEZONE = ZoneInfo('Asia/Jakarta')
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class timeutils:
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def make_aware(cls, time: _time) -> _time:
|
|
22
|
+
if time.tzinfo is None:
|
|
23
|
+
time.replace(tzinfo=DEFAULT_TIMEZONE)
|
|
24
|
+
return time
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def hour(cls, time: _time) -> int:
|
|
28
|
+
return cls.make_aware(time).hour
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def minute(cls, time: _time) -> int:
|
|
32
|
+
return cls.make_aware(time).minute
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def second(cls, time: _time) -> int:
|
|
36
|
+
return cls.make_aware(time).second
|
|
37
|
+
|
|
38
|
+
@classmethod
|
|
39
|
+
def microsecond(cls, time: _time) -> int:
|
|
40
|
+
return cls.make_aware(time).microsecond
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def tzinfo(cls, time: _time) -> tzinfo | None:
|
|
44
|
+
return time.tzinfo
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def fold(cls, time: _time) -> int:
|
|
48
|
+
return time.fold
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def isoformat(cls, time: _time, timespec: str = 'auto') -> str:
|
|
52
|
+
return cls.make_aware(time).isoformat(timespec)
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def fromisoformat(cls, time_string: str) -> _time:
|
|
56
|
+
res = _time.fromisoformat(time_string)
|
|
57
|
+
return cls.make_aware(res)
|
|
58
|
+
|
|
59
|
+
@classmethod
|
|
60
|
+
def strftime(cls, time: _time, fmt: str) -> str:
|
|
61
|
+
return cls.make_aware(time).strftime(fmt)
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def utcoffset(cls, time: _time) -> timedelta | None:
|
|
65
|
+
return time.utcoffset()
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def tzname(cls, time: _time) -> str | None:
|
|
69
|
+
return time.tzname()
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def dst(cls, time: _time) -> timedelta | None:
|
|
73
|
+
return time.dst()
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def replace(cls, time: _time, hour: int | None = None, minute: int | None = None, second: int | None = None, microsecond: int | None = None,
|
|
77
|
+
tzinfo: bool = True, *, fold: int | None = None) -> _time:
|
|
78
|
+
return time.replace(hour, minute, second, microsecond, tzinfo, fold=fold)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class datetimeutils:
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def make_aware(cls, datetime: _datetime) -> _datetime:
|
|
85
|
+
if datetime.tzinfo is None:
|
|
86
|
+
datetime.replace(tzinfo=DEFAULT_TIMEZONE)
|
|
87
|
+
return datetime
|
|
88
|
+
|
|
89
|
+
@classmethod
|
|
90
|
+
def today(cls, datetime) -> _datetime:
|
|
91
|
+
return cls.make_aware(datetime).today()
|
|
92
|
+
|
|
93
|
+
@classmethod
|
|
94
|
+
def fromordinal(cls, n: int) -> _datetime:
|
|
95
|
+
return _datetime.fromordinal(n)
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def fromisoformat(cls, date_string: str) -> _datetime:
|
|
99
|
+
return _datetime.fromisoformat(date_string)
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def fromisocalendar(cls, year: int, week: int, day: int) -> _datetime:
|
|
103
|
+
return _datetime.fromisocalendar(year, week, day)
|
|
104
|
+
|
|
105
|
+
@classmethod
|
|
106
|
+
def strftime(cls, datetime: _datetime, fmt: str) -> str:
|
|
107
|
+
return datetime.strftime(fmt)
|
|
108
|
+
|
|
109
|
+
@classmethod
|
|
110
|
+
def year(cls, datetime: _datetime) -> int:
|
|
111
|
+
return cls.make_aware(datetime).year
|
|
112
|
+
|
|
113
|
+
@classmethod
|
|
114
|
+
def month(cls, datetime: _datetime) -> int:
|
|
115
|
+
return cls.make_aware(datetime).month
|
|
116
|
+
|
|
117
|
+
@classmethod
|
|
118
|
+
def day(cls, datetime: _datetime) -> int:
|
|
119
|
+
return cls.make_aware(datetime).day
|
|
120
|
+
|
|
121
|
+
@classmethod
|
|
122
|
+
def timetuple(cls, datetime: _datetime) -> Any:
|
|
123
|
+
return cls.make_aware(datetime).timetuple()
|
|
124
|
+
|
|
125
|
+
@classmethod
|
|
126
|
+
def toordinal(cls, datetime: _datetime) -> int:
|
|
127
|
+
return cls.make_aware(datetime).toordinal()
|
|
128
|
+
|
|
129
|
+
@classmethod
|
|
130
|
+
def weekday(cls, datetime: _datetime) -> int:
|
|
131
|
+
return cls.make_aware(datetime).weekday()
|
|
132
|
+
|
|
133
|
+
@classmethod
|
|
134
|
+
def isoweekday(cls, datetime: _datetime) -> int:
|
|
135
|
+
return cls.make_aware(datetime).isoweekday()
|
|
136
|
+
|
|
137
|
+
@classmethod
|
|
138
|
+
def isocalendar(cls, datetime: _datetime) -> Any:
|
|
139
|
+
return cls.make_aware(datetime).isocalendar()
|
|
140
|
+
|
|
141
|
+
@classmethod
|
|
142
|
+
def hour(cls, datetime: _datetime) -> int:
|
|
143
|
+
return cls.make_aware(datetime).hour
|
|
144
|
+
|
|
145
|
+
@classmethod
|
|
146
|
+
def minute(cls, datetime: _datetime) -> int:
|
|
147
|
+
return cls.make_aware(datetime).minute
|
|
148
|
+
|
|
149
|
+
@classmethod
|
|
150
|
+
def second(cls, datetime: _datetime) -> int:
|
|
151
|
+
return cls.make_aware(datetime).second
|
|
152
|
+
|
|
153
|
+
@classmethod
|
|
154
|
+
def microsecond(cls, datetime: _datetime) -> int:
|
|
155
|
+
return cls.make_aware(datetime).microsecond
|
|
156
|
+
|
|
157
|
+
@classmethod
|
|
158
|
+
def now(cls, tz=None) -> _datetime:
|
|
159
|
+
if tz is not None:
|
|
160
|
+
return _datetime.now(tz)
|
|
161
|
+
return cls.make_aware(_datetime.now())
|
|
162
|
+
|
|
163
|
+
@classmethod
|
|
164
|
+
def utcnow(cls) -> _datetime:
|
|
165
|
+
return _datetime.utcnow()
|
|
166
|
+
|
|
167
|
+
@classmethod
|
|
168
|
+
def combine(cls, date: _date, time: _time, tzinfo=True) -> _datetime:
|
|
169
|
+
if tzinfo:
|
|
170
|
+
return _datetime.combine(date, time, tzinfo)
|
|
171
|
+
return cls.make_aware(_datetime.combine(date, time, tzinfo))
|
|
172
|
+
|
|
173
|
+
@classmethod
|
|
174
|
+
def timestamp(cls, datetime: _datetime) -> float:
|
|
175
|
+
return cls.make_aware(datetime).timestamp()
|
|
176
|
+
|
|
177
|
+
@classmethod
|
|
178
|
+
def utctimetuple(cls, timestamp: float) -> _datetime:
|
|
179
|
+
return _datetime.utcfromtimestamp(timestamp)
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
def date(cls, datetime: _datetime) -> _date:
|
|
183
|
+
return cls.make_aware(datetime).date()
|
|
184
|
+
|
|
185
|
+
@classmethod
|
|
186
|
+
def time(cls, datetime: _datetime) -> _time:
|
|
187
|
+
return cls.make_aware(datetime).time()
|
|
188
|
+
|
|
189
|
+
@classmethod
|
|
190
|
+
def timetz(cls, datetime: _datetime) -> _time:
|
|
191
|
+
return cls.make_aware(datetime).timetz()
|
|
192
|
+
|
|
193
|
+
@classmethod
|
|
194
|
+
def replace(cls, datetime: _datetime, year=None, month=None, day=None, hour=None,
|
|
195
|
+
minute=None, second=None, microsecond=None, tzinfo=True,
|
|
196
|
+
*, fold=None):
|
|
197
|
+
return cls.make_aware(datetime).replace(year, month, day, hour,
|
|
198
|
+
minute, second, microsecond, tzinfo, fold=fold)
|
|
199
|
+
|
|
200
|
+
@classmethod
|
|
201
|
+
def astimezone(cls, datetime: _datetime, tz=None) -> _datetime:
|
|
202
|
+
return datetime.astimezone(tz)
|
|
203
|
+
|
|
204
|
+
@classmethod
|
|
205
|
+
def ctime(cls, datetime: _datetime) -> str:
|
|
206
|
+
return cls.make_aware(datetime).ctime()
|
|
207
|
+
|
|
208
|
+
@classmethod
|
|
209
|
+
def isoformat(cls, datetime: _datetime, sep='T', timespec='auto') -> str:
|
|
210
|
+
return cls.make_aware(datetime).isoformat(sep, timespec)
|
|
211
|
+
|
|
212
|
+
@classmethod
|
|
213
|
+
def strptime(cls, datetime: _datetime, date_string, format) -> _datetime:
|
|
214
|
+
return cls.make_aware(datetime).strptime(date_string, format)
|
|
215
|
+
|
|
216
|
+
@classmethod
|
|
217
|
+
def utcoffset(cls, datetime: _datetime) -> Callable | timedelta | None:
|
|
218
|
+
return cls.make_aware(datetime).utcoffset
|
|
219
|
+
|
|
220
|
+
@classmethod
|
|
221
|
+
def tzname(cls, datetime: _datetime) -> Callable | timedelta | None:
|
|
222
|
+
return cls.make_aware(datetime).tzname
|
|
223
|
+
|
|
224
|
+
@classmethod
|
|
225
|
+
def dst(cls, datetime: _datetime) -> Callable | timedelta | None:
|
|
226
|
+
return cls.make_aware(datetime).dst
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: p1-dateutils
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Timezone Wrapper for Dekoruma Internal Use
|
|
5
|
+
Home-page:
|
|
6
|
+
Author: Engineering
|
|
7
|
+
Author-email: engineering@dekoruma.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Requires-Dist: django
|
|
10
|
+
|
|
11
|
+
Timezone Wrapper for Dekoruma Internal Use
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
setup.py
|
|
4
|
+
dateutils/__init__.py
|
|
5
|
+
dateutils/datetime_utils.py
|
|
6
|
+
p1_dateutils.egg-info/PKG-INFO
|
|
7
|
+
p1_dateutils.egg-info/SOURCES.txt
|
|
8
|
+
p1_dateutils.egg-info/dependency_links.txt
|
|
9
|
+
p1_dateutils.egg-info/not-zip-safe
|
|
10
|
+
p1_dateutils.egg-info/requires.txt
|
|
11
|
+
p1_dateutils.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
django
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dateutils
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='p1-dateutils',
|
|
5
|
+
version='0.1.0',
|
|
6
|
+
description='Timezone Wrapper for Dekoruma Internal Use',
|
|
7
|
+
long_description='Timezone Wrapper for Dekoruma Internal Use',
|
|
8
|
+
url='',
|
|
9
|
+
author='Engineering',
|
|
10
|
+
author_email='engineering@dekoruma.com',
|
|
11
|
+
license='MIT',
|
|
12
|
+
packages=['dateutils'],
|
|
13
|
+
install_requires=['django'],
|
|
14
|
+
zip_safe=False
|
|
15
|
+
)
|