clox 1.0__py3-none-any.whl → 1.1__py3-none-any.whl

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.

Potentially problematic release.


This version of clox might be problematic. Click here for more details.

clox/functions.py CHANGED
@@ -15,12 +15,13 @@ from .jcalendar import TextCalendar as JalaliCalendar
15
15
  from .params import HORIZONTAL_TIME_24H_FORMATS, VERTICAL_TIME_24H_FORMATS
16
16
  from .params import HORIZONTAL_TIME_12H_FORMATS, VERTICAL_TIME_12H_FORMATS
17
17
  from .params import TIMEZONE_DIFFERENCE_FORMAT
18
- from .params import CLOX_VERSION, DATE_FORMAT
19
- from .params import TIMEZONES_LIST, COUNTRIES_LIST
18
+ from .params import CLOX_VERSION
19
+ from .params import TIMEZONES_LIST, COUNTRIES_LIST, WEEKDAYS_LIST
20
20
  from .params import ADDITIONAL_INFO, EXIT_MESSAGE
21
21
  from .params import FACES_MAP, FACES_LIST, CALENDARS_LIST, DATE_SYSTEMS_LIST
22
22
  from .params import HORIZONTAL_FACES_LIST_EXAMPLE, VERTICAL_FACES_LIST_EXAMPLE
23
23
  from .params import CLOX_OVERVIEW, CLOX_REPO
24
+ from .params import DATE_FORMATS_MAP, DATE_FORMATS_LIST
24
25
 
25
26
 
26
27
  def clox_info() -> None:
@@ -125,13 +126,49 @@ def show_countries_list() -> None:
125
126
  country_code=country_code, country_name=country_code))
126
127
 
127
128
 
129
+ def show_date_formats_list(date_system: str = "GREGORIAN") -> None:
130
+ """
131
+ Show date formats list.
132
+
133
+ :param date_system: date system
134
+ """
135
+ datetime_lib = datetime
136
+ example_year = 1990
137
+ if date_system == "JALALI":
138
+ datetime_lib = jdatetime
139
+ example_year = 1368
140
+ print("Date formats list:\n")
141
+ example_date = datetime_lib.datetime(year=example_year, month=7, day=23)
142
+ for index, date_format in enumerate(DATE_FORMATS_LIST, 1):
143
+ print("{index}. {date_format_code} - {date_format_example}".format(index=index,
144
+ date_format_code=date_format, date_format_example=example_date.strftime(DATE_FORMATS_MAP[date_format])))
145
+
146
+
147
+ def _get_weekday_id(first_weekday: str, date_system: str = "GREGORIAN") -> int:
148
+ """
149
+ Get weekday id.
150
+
151
+ :param first_weekday: first weekday
152
+ :param date_system: date system
153
+ """
154
+ first_weekday_normalized = first_weekday.upper()
155
+ if len(first_weekday) > 2:
156
+ first_weekday_normalized = first_weekday_normalized[:2]
157
+ weekdays = [x[:2] for x in WEEKDAYS_LIST]
158
+ if date_system == "JALALI":
159
+ weekdays = weekdays[-2:] + weekdays[:-2]
160
+ return weekdays.index(first_weekday_normalized)
161
+
162
+
128
163
  def print_calendar(
129
- mode: str = "month",
164
+ mode: str = "MONTH",
130
165
  timezone: Optional[str] = None,
131
166
  country: Optional[str] = None,
132
167
  v_shift: int = 0,
133
168
  h_shift: int = 0,
134
- date_system: str = "gregorian") -> None:
169
+ date_system: str = "GREGORIAN",
170
+ date_format: str = "FULL",
171
+ first_weekday: str = "MONDAY") -> None:
135
172
  """
136
173
  Print calendar.
137
174
 
@@ -141,12 +178,15 @@ def print_calendar(
141
178
  :param v_shift: vertical shift
142
179
  :param h_shift: horizontal shift
143
180
  :param date_system: date system
181
+ :param date_format: date format
182
+ :param first_weekday: first weekday
144
183
  """
184
+ first_weekday_id = _get_weekday_id(first_weekday, date_system)
145
185
  datetime_lib = datetime
146
- calendar_obj = GregorianCalendar()
147
- if date_system == "jalali":
186
+ calendar_obj = GregorianCalendar(first_weekday_id)
187
+ if date_system == "JALALI":
148
188
  datetime_lib = jdatetime
149
- calendar_obj = JalaliCalendar()
189
+ calendar_obj = JalaliCalendar(first_weekday_id)
150
190
  tz = None
151
191
  timezone_str = "Local"
152
192
  if country is not None:
@@ -159,14 +199,14 @@ def print_calendar(
159
199
  v_shift = max(0, v_shift)
160
200
  h_shift = max(0, h_shift)
161
201
  datetime_timezone = datetime_lib.datetime.now(tz=tz)
162
- date_timezone_str = datetime_timezone.strftime(DATE_FORMAT)
202
+ date_timezone_str = datetime_timezone.strftime(DATE_FORMATS_MAP[date_format])
163
203
  print('\n' * v_shift, end='')
164
204
  print(" " * h_shift, end='')
165
205
  print("Today: {date}".format(date=date_timezone_str))
166
206
  print(" " * h_shift, end='')
167
207
  print("Timezone: {timezone}\n".format(timezone=timezone_str))
168
208
  calendar_str = calendar_obj.formatmonth(datetime_timezone.year, datetime_timezone.month)
169
- if mode == "year":
209
+ if mode == "YEAR":
170
210
  calendar_str = calendar_obj.formatyear(datetime_timezone.year)
171
211
  print("\n".join([" " * h_shift + x for x in calendar_str.split("\n")]))
172
212
 
@@ -182,7 +222,8 @@ def run_clock(
182
222
  hide_date: bool = False,
183
223
  hide_timezone: bool = False,
184
224
  am_pm: bool = False,
185
- date_system: str = "gregorian") -> None:
225
+ date_system: str = "GREGORIAN",
226
+ date_format: str = "FULL") -> None:
186
227
  """
187
228
  Run clock.
188
229
 
@@ -197,9 +238,10 @@ def run_clock(
197
238
  :param hide_timezone: hide timezone flag
198
239
  :param am_pm: AM/PM mode flag
199
240
  :param date_system: date system
241
+ :param date_format: date format
200
242
  """
201
243
  datetime_lib = datetime
202
- if date_system == "jalali":
244
+ if date_system == "JALALI":
203
245
  datetime_lib = jdatetime
204
246
  format_index = 0
205
247
  time_formats = HORIZONTAL_TIME_12H_FORMATS if am_pm else HORIZONTAL_TIME_24H_FORMATS
@@ -224,7 +266,7 @@ def run_clock(
224
266
  print(" " * h_shift, end='')
225
267
  datetime_timezone = datetime_lib.datetime.now(tz=tz)
226
268
  time_timezone_str = datetime_timezone.strftime(time_formats[format_index])
227
- date_timezone_str = datetime_timezone.strftime(DATE_FORMAT)
269
+ date_timezone_str = datetime_timezone.strftime(DATE_FORMATS_MAP[date_format])
228
270
  tprint(time_timezone_str, font=face, sep="\n" + " " * h_shift)
229
271
  if not hide_date:
230
272
  print(" " * h_shift, end='')
@@ -256,18 +298,22 @@ def main() -> None:
256
298
  parser.add_argument('--faces-list', help='faces list', nargs="?", const=1)
257
299
  parser.add_argument('--timezones-list', help='timezones list', nargs="?", const=1)
258
300
  parser.add_argument('--countries-list', help='countries list', nargs="?", const=1)
301
+ parser.add_argument('--date-formats-list', help='date formats list', nargs="?", const=1)
259
302
  parser.add_argument('--no-blink', help='disable blinking mode', nargs="?", const=1)
260
303
  parser.add_argument('--vertical', help='vertical mode', nargs="?", const=1)
261
304
  parser.add_argument('--hide-date', help='hide date', nargs="?", const=1)
262
305
  parser.add_argument('--hide-timezone', help='hide timezone', nargs="?", const=1)
263
306
  parser.add_argument('--am-pm', help='AM/PM mode', nargs="?", const=1)
264
- parser.add_argument('--calendar', help='calendar mode', type=str.lower, choices=CALENDARS_LIST)
307
+ parser.add_argument('--calendar', help='calendar mode', type=str.upper, choices=CALENDARS_LIST)
308
+ parser.add_argument('--first-weekday', help='first weekday', type=str.upper, default="MONDAY",
309
+ choices=WEEKDAYS_LIST + [x[:2] for x in WEEKDAYS_LIST])
310
+ parser.add_argument('--date-format', help='date format', type=str.upper, choices=DATE_FORMATS_LIST, default="FULL")
265
311
  parser.add_argument(
266
312
  '--date-system',
267
313
  help='date system',
268
- type=str.lower,
314
+ type=str.upper,
269
315
  choices=DATE_SYSTEMS_LIST,
270
- default="gregorian")
316
+ default="GREGORIAN")
271
317
  args = parser.parse_args()
272
318
  if args.version:
273
319
  print(CLOX_VERSION)
@@ -279,6 +325,8 @@ def main() -> None:
279
325
  show_timezones_list(args.country)
280
326
  elif args.countries_list:
281
327
  show_countries_list()
328
+ elif args.date_formats_list:
329
+ show_date_formats_list(date_system=args.date_system)
282
330
  elif args.calendar:
283
331
  print_calendar(
284
332
  mode=args.calendar,
@@ -286,7 +334,9 @@ def main() -> None:
286
334
  country=args.country,
287
335
  h_shift=args.h_shift,
288
336
  v_shift=args.v_shift,
289
- date_system=args.date_system)
337
+ date_system=args.date_system,
338
+ date_format=args.date_format,
339
+ first_weekday=args.first_weekday)
290
340
  else:
291
341
  try:
292
342
  run_clock(
@@ -300,6 +350,7 @@ def main() -> None:
300
350
  hide_date=args.hide_date,
301
351
  hide_timezone=args.hide_timezone,
302
352
  am_pm=args.am_pm,
303
- date_system=args.date_system)
353
+ date_system=args.date_system,
354
+ date_format=args.date_format)
304
355
  except (KeyboardInterrupt, EOFError):
305
356
  print(EXIT_MESSAGE)
clox/params.py CHANGED
@@ -2,7 +2,7 @@
2
2
  """clox params."""
3
3
  import pytz
4
4
 
5
- CLOX_VERSION = "1.0"
5
+ CLOX_VERSION = "1.1"
6
6
 
7
7
  CLOX_OVERVIEW = '''
8
8
  Clox is a terminal-based clock application designed for terminal enthusiasts who appreciate simplicity,
@@ -22,9 +22,9 @@ HORIZONTAL_TIME_24H_FORMATS = ['%H:%M', '%H:%M.']
22
22
  VERTICAL_TIME_24H_FORMATS = ['%H\n%M', '%H\n%M.']
23
23
  HORIZONTAL_TIME_12H_FORMATS = ['%I:%M %p', '%I:%M %p.']
24
24
  VERTICAL_TIME_12H_FORMATS = ['%I\n%M\n%p', '%I\n%M\n%p.']
25
- DATE_FORMAT = "%A, %B %d, %Y"
26
25
  TIMEZONE_DIFFERENCE_FORMAT = "{hours:02}h{minutes:02}m {direction}"
27
26
 
27
+ WEEKDAYS_LIST = ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"]
28
28
  TIMEZONES_LIST = list(map(lambda x: x.upper(), pytz.all_timezones))
29
29
  COUNTRIES_LIST = list(map(lambda x: x.upper(), pytz.country_timezones.keys()))
30
30
 
@@ -57,8 +57,24 @@ FACES_MAP = {
57
57
  25: 'epic',
58
58
  }
59
59
 
60
+ DATE_FORMATS_MAP = {
61
+ 'ISO': '%Y-%m-%d',
62
+ 'US': '%m/%d/%Y',
63
+ 'US-SHORT': '%m/%d/%y',
64
+ 'EU': '%d/%m/%Y',
65
+ 'EU-SHORT': '%d/%m/%y',
66
+ 'DOT': '%d.%m.%Y',
67
+ 'DASH': '%d-%m-%Y',
68
+ 'YMD': '%Y/%m/%d',
69
+ 'DMY': '%d/%m/%Y',
70
+ 'MDY': '%m/%d/%Y',
71
+ 'FULL': '%A, %B %d, %Y',
72
+ }
73
+
60
74
  FACES_LIST = [-1] + sorted(FACES_MAP)
61
75
 
62
- CALENDARS_LIST = ["month", "year"]
76
+ CALENDARS_LIST = ["MONTH", "YEAR"]
77
+
78
+ DATE_SYSTEMS_LIST = ["GREGORIAN", "JALALI"]
63
79
 
64
- DATE_SYSTEMS_LIST = ["gregorian", "jalali"]
80
+ DATE_FORMATS_LIST = sorted(DATE_FORMATS_MAP)
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clox
3
- Version: 1.0
3
+ Version: 1.1
4
4
  Summary: A Geeky Clock for Terminal Enthusiasts
5
5
  Home-page: https://github.com/sepandhaghighi/clox
6
- Download-URL: https://github.com/sepandhaghighi/clox/tarball/v1.0
6
+ Download-URL: https://github.com/sepandhaghighi/clox/tarball/v1.1
7
7
  Author: Sepand Haghighi
8
8
  Author-email: me@sepand.tech
9
9
  License: MIT
@@ -104,13 +104,13 @@ Clox is a terminal-based clock application designed for terminal enthusiasts who
104
104
  ## Installation
105
105
 
106
106
  ### Source Code
107
- - Download [Version 1.0](https://github.com/sepandhaghighi/clox/archive/v1.0.zip) or [Latest Source](https://github.com/sepandhaghighi/clox/archive/dev.zip)
107
+ - Download [Version 1.1](https://github.com/sepandhaghighi/clox/archive/v1.1.zip) or [Latest Source](https://github.com/sepandhaghighi/clox/archive/dev.zip)
108
108
  - `pip install .`
109
109
 
110
110
  ### PyPI
111
111
 
112
112
  - Check [Python Packaging User Guide](https://packaging.python.org/installing/)
113
- - `pip install clox==1.0`
113
+ - `pip install clox==1.1`
114
114
 
115
115
 
116
116
  ## Usage
@@ -218,22 +218,33 @@ clox --vertical
218
218
 
219
219
  In this mode, the calendar will be displayed
220
220
 
221
- ℹ️ Valid choices: [`month`, `year`]
221
+ ℹ️ Valid choices: [`MONTH`, `YEAR`]
222
222
 
223
223
  ```console
224
- clox --calendar=month
224
+ clox --calendar=month --first-weekday="SUNDAY"
225
225
  ```
226
226
 
227
227
  ### Date System
228
228
 
229
- ℹ️ Valid choices: [`gregorian`, `jalali`]
229
+ ℹ️ Valid choices: [`GREGORIAN`, `JALALI`]
230
230
 
231
- ℹ️ The default date system is `gregorian`
231
+ ℹ️ The default date system is `GREGORIAN`
232
232
 
233
233
  ```console
234
234
  clox --date-system=jalali
235
235
  ```
236
236
 
237
+ ### Date Format
238
+
239
+ ℹ️ Valid choices: [`ISO`, `US`, `US-SHORT`, `EU`, `EU-SHORT`, `DOT`, `DASH`, `YMD`, `DMY`, `MDY`, `FULL`]
240
+
241
+ ℹ️ The default date format is `FULL`
242
+
243
+ ```console
244
+ clox --date-system=jalali --date-format=EU
245
+ ```
246
+ * Date Formats List: `clox --date-formats-list`
247
+
237
248
  ## Screen Record
238
249
 
239
250
  <div align="center">
@@ -292,6 +303,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
292
303
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
293
304
 
294
305
  ## [Unreleased]
306
+ ## [1.1] - 2025-05-23
307
+ ### Added
308
+ - `--first-weekday` argument
309
+ - `--date-format` argument
310
+ - `--date-formats-list` argument
311
+ ### Changed
312
+ - `README.md` updated
313
+ - Test system modified
295
314
  ## [1.0] - 2025-05-06
296
315
  ### Added
297
316
  - Local time
@@ -358,7 +377,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
358
377
  - `TIMEZONES.md`
359
378
  - `FACES.md`
360
379
 
361
- [Unreleased]: https://github.com/sepandhaghighi/clox/compare/v1.0...dev
380
+ [Unreleased]: https://github.com/sepandhaghighi/clox/compare/v1.1...dev
381
+ [1.1]: https://github.com/sepandhaghighi/clox/compare/v1.0...v1.1
362
382
  [1.0]: https://github.com/sepandhaghighi/clox/compare/v0.9...v1.0
363
383
  [0.9]: https://github.com/sepandhaghighi/clox/compare/v0.8...v0.9
364
384
  [0.8]: https://github.com/sepandhaghighi/clox/compare/v0.7...v0.8
@@ -0,0 +1,12 @@
1
+ clox/__init__.py,sha256=gErclFSjUDschQpngWqOBGkBKt1jwd-Ww8B9iJmlU5s,108
2
+ clox/__main__.py,sha256=9oJYc1WXu4ZMrjKny_2-4Cgu46-VWHuE9xOqD1iJY0E,109
3
+ clox/functions.py,sha256=-tJtvWZBtYmh2qlNe_Y7KYZJXwo3nUzgVYwHe_mnbmc,13607
4
+ clox/jcalendar.py,sha256=RvtTikECGI4LjDSi5qbJF9grz7to2__fgR98xnnvme8,13462
5
+ clox/params.py,sha256=JH8NEjXDUoHKCLCVtfjog5DR-iqVPxUsGJPZYcNeWL4,2118
6
+ clox-1.1.dist-info/licenses/AUTHORS.md,sha256=lmtnd18MnfgB57jdvfJbC0JHN3iARf2Ov4pY5kPGJC8,242
7
+ clox-1.1.dist-info/licenses/LICENSE,sha256=WoAsqqZ_lNVBGdyxjwh7YnVNXKfOB-qYVrRhrn-e-_4,1072
8
+ clox-1.1.dist-info/METADATA,sha256=qmV3t6v2pJmTIUppwLi-XhVJud_bHvkgmjJL2H5pdsQ,10459
9
+ clox-1.1.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
10
+ clox-1.1.dist-info/entry_points.txt,sha256=sP4Rmoe-DxYGjlF_Tld6nghbt_u-fK8h9ZUQFmO8TJs,45
11
+ clox-1.1.dist-info/top_level.txt,sha256=5DxGH-4VNfYkM8vbfngObh6-jpFEoSW4M90EvDGfhSw,5
12
+ clox-1.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.3.1)
2
+ Generator: setuptools (80.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
clox-1.0.dist-info/RECORD DELETED
@@ -1,12 +0,0 @@
1
- clox/__init__.py,sha256=gErclFSjUDschQpngWqOBGkBKt1jwd-Ww8B9iJmlU5s,108
2
- clox/__main__.py,sha256=9oJYc1WXu4ZMrjKny_2-4Cgu46-VWHuE9xOqD1iJY0E,109
3
- clox/functions.py,sha256=NocjRMBfVLOBXk7rTkNfiDqvlJ5roQFkEB947Gx1hbY,11313
4
- clox/jcalendar.py,sha256=RvtTikECGI4LjDSi5qbJF9grz7to2__fgR98xnnvme8,13462
5
- clox/params.py,sha256=4eEm2syVxmx2_HsOG6HweVToGuNOx3tJAB8bQKNNgGQ,1715
6
- clox-1.0.dist-info/licenses/AUTHORS.md,sha256=lmtnd18MnfgB57jdvfJbC0JHN3iARf2Ov4pY5kPGJC8,242
7
- clox-1.0.dist-info/licenses/LICENSE,sha256=WoAsqqZ_lNVBGdyxjwh7YnVNXKfOB-qYVrRhrn-e-_4,1072
8
- clox-1.0.dist-info/METADATA,sha256=A4Jl_O1NYBkvXE4vrlsNUZpYv8SDeXhOOTudRuwBeWE,9913
9
- clox-1.0.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
10
- clox-1.0.dist-info/entry_points.txt,sha256=sP4Rmoe-DxYGjlF_Tld6nghbt_u-fK8h9ZUQFmO8TJs,45
11
- clox-1.0.dist-info/top_level.txt,sha256=5DxGH-4VNfYkM8vbfngObh6-jpFEoSW4M90EvDGfhSw,5
12
- clox-1.0.dist-info/RECORD,,
File without changes