mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-26 18:47:25 +01:00
Compare commits
No commits in common. "aeac9caaa11a939aa830cce361215b242451e11c" and "0af237af3db8d6e3e3ad0261d878f827ee96acb0" have entirely different histories.
aeac9caaa1
...
0af237af3d
@ -52,15 +52,6 @@ app launch.
|
||||
| **Releasing refunds only the future** | Give back a day that has not arrived and it returns to the pool. Give back today, and it does not: those hours were already unguarded. |
|
||||
| **Silent** | No notification, no low-budget warning, no prompt when a gate fires. You find out by asking. |
|
||||
|
||||
## Weekly workdays
|
||||
|
||||
`freedays.WORKDAYS` (`{1, 2, 3}`, Tue/Wed/Thu in `date.weekday()` numbering),
|
||||
`NON_WORKDAYS` and `is_workday(day=None)` are the one definition of the weekly
|
||||
workdays every gate app reads — screen-locker's relaxed days, leetcode-guard's
|
||||
cheap days, wake-alarm's ramp hold and workday stick. Import it; never write
|
||||
the set out again. Dart/Kotlin code that cannot import it keeps a literal copy
|
||||
guarded by a drift test against this package.
|
||||
|
||||
## Free days are not sick days
|
||||
|
||||
screen-locker's sick days stay exactly where they are, with their rolling
|
||||
|
||||
@ -52,12 +52,9 @@ from freedays._errors import (
|
||||
from freedays._model import FreeDay
|
||||
from freedays._paths import Paths
|
||||
from freedays._sync import SyncUnavailableError, sync, sync_quietly
|
||||
from freedays._workdays import NON_WORKDAYS, WORKDAYS, is_workday
|
||||
|
||||
__all__ = [
|
||||
"DEFAULT_ANNUAL_BUDGET",
|
||||
"NON_WORKDAYS",
|
||||
"WORKDAYS",
|
||||
"AlreadyFreeError",
|
||||
"BudgetExhaustedError",
|
||||
"FreeDay",
|
||||
@ -71,7 +68,6 @@ __all__ = [
|
||||
"free_days_in_year",
|
||||
"is_exhausted",
|
||||
"is_free_day",
|
||||
"is_workday",
|
||||
"load",
|
||||
"lookup",
|
||||
"mark",
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
# Copyright (c) 2026 Krzysztof Rudnicki
|
||||
"""The weekly workdays: Tuesday, Wednesday and Thursday.
|
||||
|
||||
The one definition every gate app reads, so "which days are workdays" cannot
|
||||
drift between them. Consumers each give it their own meaning: screen-locker
|
||||
relaxes the lock, leetcode-guard charges the cheap price, wake-alarm's ramp
|
||||
holds the wake time instead of stepping it earlier, and a missed workday
|
||||
morning costs tomorrow its leniency.
|
||||
|
||||
Languages that cannot import this package (the Dart and Kotlin sides of the
|
||||
phone apps) keep a literal copy and a test that fails when it drifts from
|
||||
this one.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Final
|
||||
|
||||
from freedays._day import today
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from datetime import date
|
||||
|
||||
#: Python ``date.weekday()`` numbering: Mon=0 ... Sun=6.
|
||||
WORKDAYS: Final[frozenset[int]] = frozenset({1, 2, 3})
|
||||
|
||||
#: The complement: Monday, Friday, Saturday and Sunday.
|
||||
NON_WORKDAYS: Final[frozenset[int]] = frozenset(range(7)) - WORKDAYS
|
||||
|
||||
|
||||
def is_workday(day: date | None = None) -> bool:
|
||||
"""Return whether *day* (default: today, local) is a weekly workday.
|
||||
|
||||
Args:
|
||||
day: The date to classify; ``None`` means today.
|
||||
|
||||
Returns:
|
||||
True on Tuesday, Wednesday and Thursday.
|
||||
"""
|
||||
return today(day).weekday() in WORKDAYS
|
||||
@ -1,40 +0,0 @@
|
||||
# Copyright (c) 2026 Krzysztof Rudnicki
|
||||
"""The weekly workdays: the one Tue/Wed/Thu definition every app reads."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
|
||||
import freedays
|
||||
|
||||
|
||||
def test_workdays_are_tuesday_to_thursday() -> None:
|
||||
assert frozenset({1, 2, 3}) == freedays.WORKDAYS
|
||||
|
||||
|
||||
def test_non_workdays_are_the_complement() -> None:
|
||||
assert frozenset({0, 4, 5, 6}) == freedays.NON_WORKDAYS
|
||||
assert not freedays.WORKDAYS & freedays.NON_WORKDAYS
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"day",
|
||||
[date(2026, 9, 29), date(2026, 9, 30), date(2026, 10, 1)], # Tue, Wed, Thu
|
||||
)
|
||||
def test_tuesday_to_thursday_are_workdays(day: date) -> None:
|
||||
assert freedays.is_workday(day)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"day",
|
||||
# Mon, Fri, Sat, Sun
|
||||
[date(2026, 9, 28), date(2026, 10, 2), date(2026, 10, 3), date(2026, 10, 4)],
|
||||
)
|
||||
def test_the_rest_are_not(day: date) -> None:
|
||||
assert not freedays.is_workday(day)
|
||||
|
||||
|
||||
def test_is_workday_defaults_to_today() -> None:
|
||||
assert freedays.is_workday() is (freedays.today().weekday() in {1, 2, 3})
|
||||
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "freedays"
|
||||
version = "0.3.0"
|
||||
version = "0.1.0"
|
||||
description = "Shared pre-declared free-day pool: one global list of days on which every gate app stands down"
|
||||
requires-python = ">=3.14"
|
||||
# Deliberately NOT gatelock. Its __init__ imports tkinter for the lock-window
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
"devDependencies": {
|
||||
"@eslint/js": "10.0.1",
|
||||
"@kuhyx/ts-config": "link:../ts_config",
|
||||
"@types/node": "26.6.3",
|
||||
"@types/node": "26.6.2",
|
||||
"@vitest/coverage-v8": "5.0.2",
|
||||
"eslint": "10.11.0",
|
||||
"typescript": "6.0.3",
|
||||
|
||||
@ -173,8 +173,8 @@ importers:
|
||||
specifier: link:../ts_config
|
||||
version: link:../ts_config
|
||||
'@types/node':
|
||||
specifier: 26.6.3
|
||||
version: 26.6.3
|
||||
specifier: 26.6.2
|
||||
version: 26.6.2
|
||||
'@vitest/coverage-v8':
|
||||
specifier: 5.0.2
|
||||
version: 5.0.2(vitest@5.0.2)
|
||||
@ -189,7 +189,7 @@ importers:
|
||||
version: 8.70.0(eslint@10.11.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
vitest:
|
||||
specifier: 5.0.2
|
||||
version: 5.0.2(@types/node@26.6.3)(@vitest/coverage-v8@5.0.2)(vite@8.2.1(@types/node@26.6.3))
|
||||
version: 5.0.2(@types/node@26.6.2)(@vitest/coverage-v8@5.0.2)(vite@8.2.1(@types/node@26.6.2))
|
||||
|
||||
packages:
|
||||
|
||||
@ -409,8 +409,8 @@ packages:
|
||||
'@types/json-schema@7.0.15':
|
||||
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
||||
|
||||
'@types/node@26.6.3':
|
||||
resolution: {integrity: sha512-dsqMQQoeTLqu9wynDD00q573mNzso3IdQOAfHRJqLCcmCFPoGo9A1bDpUcv/9tnKpErQWv9uKeGfl37EIS02Yg==}
|
||||
'@types/node@26.6.2':
|
||||
resolution: {integrity: sha512-X1P21scMv4zGKLYqjdGjaKa7COa0RKVYYZZN/NfvLQ1JegxFhdhpZG/Lyn8AXx6CDUavKAd11v6BvfpkDByK8g==}
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.70.0':
|
||||
resolution: {integrity: sha512-/v8HZt6RlyIZxB3ntehELOcUcfxKPVGWXnQdJuHRmzrqgF8nQypcC/oxGW+Ot4VGKDq81XugPKxx0n5PBtf9PA==}
|
||||
@ -1186,7 +1186,7 @@ snapshots:
|
||||
|
||||
'@types/json-schema@7.0.15': {}
|
||||
|
||||
'@types/node@26.6.3':
|
||||
'@types/node@26.6.2':
|
||||
dependencies:
|
||||
undici-types: 8.9.0
|
||||
|
||||
@ -1291,7 +1291,7 @@ snapshots:
|
||||
obug: 2.1.4
|
||||
std-env: 4.2.0
|
||||
tinyrainbow: 3.1.1
|
||||
vitest: 5.0.2(@types/node@26.6.3)(@vitest/coverage-v8@5.0.2)(vite@8.2.1(@types/node@26.6.3))
|
||||
vitest: 5.0.2(@types/node@26.6.2)(@vitest/coverage-v8@5.0.2)(vite@8.2.1(@types/node@26.6.2))
|
||||
|
||||
'@vitest/istanbul-lib-coverage@1.0.1': {}
|
||||
|
||||
@ -1299,14 +1299,14 @@ snapshots:
|
||||
dependencies:
|
||||
'@vitest/istanbul-lib-coverage': 1.0.1
|
||||
|
||||
'@vitest/mocker@5.0.2(vite@8.2.1(@types/node@26.6.3))':
|
||||
'@vitest/mocker@5.0.2(vite@8.2.1(@types/node@26.6.2))':
|
||||
dependencies:
|
||||
'@jridgewell/trace-mapping': 0.3.31
|
||||
'@vitest/spy': 5.0.2
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 1.3.1
|
||||
optionalDependencies:
|
||||
vite: 8.2.1(@types/node@26.6.3)
|
||||
vite: 8.2.1(@types/node@26.6.2)
|
||||
|
||||
'@vitest/spy@5.0.2': {}
|
||||
|
||||
@ -1702,7 +1702,7 @@ snapshots:
|
||||
dependencies:
|
||||
punycode: 2.3.1
|
||||
|
||||
vite@8.2.1(@types/node@26.6.3):
|
||||
vite@8.2.1(@types/node@26.6.2):
|
||||
dependencies:
|
||||
lightningcss: 1.33.0
|
||||
picomatch: 4.0.7
|
||||
@ -1710,13 +1710,13 @@ snapshots:
|
||||
rolldown: 1.2.4
|
||||
tinyglobby: 0.2.17
|
||||
optionalDependencies:
|
||||
'@types/node': 26.6.3
|
||||
'@types/node': 26.6.2
|
||||
fsevents: 2.3.3
|
||||
|
||||
vitest@5.0.2(@types/node@26.6.3)(@vitest/coverage-v8@5.0.2)(vite@8.2.1(@types/node@26.6.3)):
|
||||
vitest@5.0.2(@types/node@26.6.2)(@vitest/coverage-v8@5.0.2)(vite@8.2.1(@types/node@26.6.2)):
|
||||
dependencies:
|
||||
'@types/chai': 5.2.3
|
||||
'@vitest/mocker': 5.0.2(vite@8.2.1(@types/node@26.6.3))
|
||||
'@vitest/mocker': 5.0.2(vite@8.2.1(@types/node@26.6.2))
|
||||
chai: 6.2.2
|
||||
es-module-lexer: 2.3.2
|
||||
expect-type: 1.4.0
|
||||
@ -1727,10 +1727,10 @@ snapshots:
|
||||
tinybench: 6.1.4
|
||||
tinyexec: 1.3.0
|
||||
tinyglobby: 0.2.17
|
||||
vite: 8.2.1(@types/node@26.6.3)
|
||||
vite: 8.2.1(@types/node@26.6.2)
|
||||
why-is-node-running: 3.2.2
|
||||
optionalDependencies:
|
||||
'@types/node': 26.6.3
|
||||
'@types/node': 26.6.2
|
||||
'@vitest/coverage-v8': 5.0.2(vitest@5.0.2)
|
||||
transitivePeerDependencies:
|
||||
- msw
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
"@testing-library/jest-dom": "7.0.1",
|
||||
"@testing-library/react": "16.3.3",
|
||||
"@testing-library/user-event": "14.6.7",
|
||||
"@types/node": "26.6.3",
|
||||
"@types/node": "26.6.2",
|
||||
"@types/react": "19.3.0",
|
||||
"@types/react-dom": "19.3.0",
|
||||
"@vitest/coverage-v8": "5.0.2",
|
||||
|
||||
@ -182,8 +182,8 @@ importers:
|
||||
specifier: 14.6.7
|
||||
version: 14.6.7(@testing-library/dom@10.4.1)
|
||||
'@types/node':
|
||||
specifier: 26.6.3
|
||||
version: 26.6.3
|
||||
specifier: 26.6.2
|
||||
version: 26.6.2
|
||||
'@types/react':
|
||||
specifier: 19.3.0
|
||||
version: 19.3.0
|
||||
@ -213,7 +213,7 @@ importers:
|
||||
version: 8.70.0(eslint@10.11.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
|
||||
vitest:
|
||||
specifier: 5.0.2
|
||||
version: 5.0.2(@types/node@26.6.3)(@vitest/coverage-v8@5.0.2)(jsdom@30.1.1)(vite@8.2.2(@types/node@26.6.3))
|
||||
version: 5.0.2(@types/node@26.6.2)(@vitest/coverage-v8@5.0.2)(jsdom@30.1.1)(vite@8.2.2(@types/node@26.6.2))
|
||||
|
||||
packages:
|
||||
|
||||
@ -545,8 +545,8 @@ packages:
|
||||
'@types/json-schema@7.0.15':
|
||||
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
||||
|
||||
'@types/node@26.6.3':
|
||||
resolution: {integrity: sha512-dsqMQQoeTLqu9wynDD00q573mNzso3IdQOAfHRJqLCcmCFPoGo9A1bDpUcv/9tnKpErQWv9uKeGfl37EIS02Yg==}
|
||||
'@types/node@26.6.2':
|
||||
resolution: {integrity: sha512-X1P21scMv4zGKLYqjdGjaKa7COa0RKVYYZZN/NfvLQ1JegxFhdhpZG/Lyn8AXx6CDUavKAd11v6BvfpkDByK8g==}
|
||||
|
||||
'@types/react-dom@19.3.0':
|
||||
resolution: {integrity: sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==}
|
||||
@ -1567,7 +1567,7 @@ snapshots:
|
||||
picocolors: 1.1.1
|
||||
redent: 3.0.0
|
||||
optionalDependencies:
|
||||
vitest: 5.0.2(@types/node@26.6.3)(@vitest/coverage-v8@5.0.2)(jsdom@30.1.1)(vite@8.2.2(@types/node@26.6.3))
|
||||
vitest: 5.0.2(@types/node@26.6.2)(@vitest/coverage-v8@5.0.2)(jsdom@30.1.1)(vite@8.2.2(@types/node@26.6.2))
|
||||
|
||||
'@testing-library/react@16.3.3(@testing-library/dom@10.4.1)(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)':
|
||||
dependencies:
|
||||
@ -1598,7 +1598,7 @@ snapshots:
|
||||
|
||||
'@types/json-schema@7.0.15': {}
|
||||
|
||||
'@types/node@26.6.3':
|
||||
'@types/node@26.6.2':
|
||||
dependencies:
|
||||
undici-types: 8.9.0
|
||||
|
||||
@ -1711,7 +1711,7 @@ snapshots:
|
||||
obug: 2.1.4
|
||||
std-env: 4.2.0
|
||||
tinyrainbow: 3.1.1
|
||||
vitest: 5.0.2(@types/node@26.6.3)(@vitest/coverage-v8@5.0.2)(jsdom@30.1.1)(vite@8.2.2(@types/node@26.6.3))
|
||||
vitest: 5.0.2(@types/node@26.6.2)(@vitest/coverage-v8@5.0.2)(jsdom@30.1.1)(vite@8.2.2(@types/node@26.6.2))
|
||||
|
||||
'@vitest/istanbul-lib-coverage@1.0.1': {}
|
||||
|
||||
@ -1719,14 +1719,14 @@ snapshots:
|
||||
dependencies:
|
||||
'@vitest/istanbul-lib-coverage': 1.0.1
|
||||
|
||||
'@vitest/mocker@5.0.2(vite@8.2.2(@types/node@26.6.3))':
|
||||
'@vitest/mocker@5.0.2(vite@8.2.2(@types/node@26.6.2))':
|
||||
dependencies:
|
||||
'@jridgewell/trace-mapping': 0.3.31
|
||||
'@vitest/spy': 5.0.2
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 1.3.1
|
||||
optionalDependencies:
|
||||
vite: 8.2.2(@types/node@26.6.3)
|
||||
vite: 8.2.2(@types/node@26.6.2)
|
||||
|
||||
'@vitest/spy@5.0.2': {}
|
||||
|
||||
@ -2260,7 +2260,7 @@ snapshots:
|
||||
dependencies:
|
||||
punycode: 2.3.1
|
||||
|
||||
vite@8.2.2(@types/node@26.6.3):
|
||||
vite@8.2.2(@types/node@26.6.2):
|
||||
dependencies:
|
||||
lightningcss: 1.33.0
|
||||
picomatch: 4.0.7
|
||||
@ -2268,13 +2268,13 @@ snapshots:
|
||||
rolldown: 1.2.6
|
||||
tinyglobby: 0.2.17
|
||||
optionalDependencies:
|
||||
'@types/node': 26.6.3
|
||||
'@types/node': 26.6.2
|
||||
fsevents: 2.3.3
|
||||
|
||||
vitest@5.0.2(@types/node@26.6.3)(@vitest/coverage-v8@5.0.2)(jsdom@30.1.1)(vite@8.2.2(@types/node@26.6.3)):
|
||||
vitest@5.0.2(@types/node@26.6.2)(@vitest/coverage-v8@5.0.2)(jsdom@30.1.1)(vite@8.2.2(@types/node@26.6.2)):
|
||||
dependencies:
|
||||
'@types/chai': 5.2.3
|
||||
'@vitest/mocker': 5.0.2(vite@8.2.2(@types/node@26.6.3))
|
||||
'@vitest/mocker': 5.0.2(vite@8.2.2(@types/node@26.6.2))
|
||||
chai: 6.2.2
|
||||
es-module-lexer: 2.3.2
|
||||
expect-type: 1.4.0
|
||||
@ -2285,10 +2285,10 @@ snapshots:
|
||||
tinybench: 6.1.4
|
||||
tinyexec: 1.3.0
|
||||
tinyglobby: 0.2.17
|
||||
vite: 8.2.2(@types/node@26.6.3)
|
||||
vite: 8.2.2(@types/node@26.6.2)
|
||||
why-is-node-running: 3.2.2
|
||||
optionalDependencies:
|
||||
'@types/node': 26.6.3
|
||||
'@types/node': 26.6.2
|
||||
'@vitest/coverage-v8': 5.0.2(vitest@5.0.2)
|
||||
jsdom: 30.1.1
|
||||
transitivePeerDependencies:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user