-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Zeitmenge and Zeitspanne (as future replacements for Zeitraum) #611
Closed
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5684953
Add Zeitmenge and Zeitspanne (as future replacements for Zeitraum)
hf-kklein efbbb5e
Add JSON Schemas for Zeitmenge and Zeitspanne
hf-kklein bfd86d9
🗑️ removed COM Zeitmenge and corresp. json_schema
DeltaDaniel 19055b4
🔀Merged Enum Zeiteinheit to Enum Mengeneinheit
DeltaDaniel c8b312f
added default-value None to Zeitspanne
DeltaDaniel ffa68b8
removed test_zeitmenge
DeltaDaniel ef33866
fixed black issue
DeltaDaniel 9fd5e14
updated json schemas
DeltaDaniel 8301aad
🗑️removed Enum zeiteinheit
DeltaDaniel d97af19
updated json schemas
DeltaDaniel 6f674b1
Update src/bo4e/com/zeitspanne.py
hf-fvesely 8616d83
Update src/bo4e/com/zeitspanne.py
hf-fvesely 8a1a081
updated Zeitspanne.json
DeltaDaniel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"$defs": { | ||
"Zeiteinheit": { | ||
"description": "Auflistung möglicher Einheiten zur Verwendung in zeitbezogenen Angaben.", | ||
"enum": [ | ||
"SEKUNDE", | ||
"MINUTE", | ||
"STUNDE", | ||
"VIERTEL_STUNDE", | ||
"TAG", | ||
"WOCHE", | ||
"MONAT", | ||
"QUARTAL", | ||
"HALBJAHR", | ||
"JAHR" | ||
], | ||
"title": "Zeiteinheit", | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": true, | ||
"description": "Eine Zeitmenge ist eine Anzahl mit Zeiteinheit; z.B. \"5 Tage\" oder \"1 Monat\".\nDer Unterschied zur Zeitspanne ist, dass Start- und Endzeitpunkt nicht angegeben werden.\nDie Zeitmenge ist aus dem COM Zeitraum hervorgegangen, das in Zeitspanne und Zeitmenge aufgeteilt wurde.", | ||
"properties": { | ||
"dauer": { | ||
"anyOf": [ | ||
{ | ||
"type": "number" | ||
}, | ||
{ | ||
"type": "string" | ||
} | ||
], | ||
"title": "Dauer" | ||
}, | ||
"einheit": { | ||
"$ref": "#/$defs/Zeiteinheit" | ||
} | ||
}, | ||
"required": [ | ||
"einheit", | ||
"dauer" | ||
], | ||
"title": "Zeitmenge", | ||
"type": "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"additionalProperties": true, | ||
"description": "Eine Zeitspanne ist definiert aus Start und/oder Ende.\nDer Unterschied zur Zeitmenge ist, dass konkrete Start- und Endzeitpunkt angegeben werden.\nDie Zeitspanne ist aus dem COM Zeitraum hervorgegangen, das in Zeitspanne und Zeitmenge aufgeteilt wurde.", | ||
"properties": { | ||
"ende": { | ||
"anyOf": [ | ||
{ | ||
"format": "date-time", | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"title": "Ende" | ||
}, | ||
"start": { | ||
"anyOf": [ | ||
{ | ||
"format": "date-time", | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"title": "Start" | ||
} | ||
}, | ||
"required": [ | ||
"start", | ||
"ende" | ||
], | ||
"title": "Zeitspanne", | ||
"type": "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
contains the COM Zeitmenge | ||
""" | ||
from decimal import Decimal | ||
|
||
from bo4e.com.com import COM | ||
from bo4e.enum.zeiteinheit import Zeiteinheit | ||
|
||
|
||
class Zeitmenge(COM): | ||
""" | ||
Eine Zeitmenge ist eine Anzahl mit Zeiteinheit; z.B. "5 Tage" oder "1 Monat". | ||
Der Unterschied zur Zeitspanne ist, dass Start- und Endzeitpunkt nicht angegeben werden. | ||
Die Zeitmenge ist aus dem COM Zeitraum hervorgegangen, das in Zeitspanne und Zeitmenge aufgeteilt wurde. | ||
""" | ||
|
||
# I made those _not_ optional because the entire instance of Zeitmenge is pointless if one of the two is missing | ||
einheit: Zeiteinheit #: z.B. Tage | ||
dauer: Decimal #: z.B: 5 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
contains the COM Zeitspanne | ||
""" | ||
from datetime import datetime | ||
from typing import Optional | ||
|
||
from bo4e.com.com import COM | ||
|
||
|
||
class Zeitspanne(COM): | ||
""" | ||
Eine Zeitspanne ist definiert aus Start und/oder Ende. | ||
Der Unterschied zur Zeitmenge ist, dass konkrete Start- und Endzeitpunkt angegeben werden. | ||
hf-fvesely marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Die Zeitspanne ist aus dem COM Zeitraum hervorgegangen, das in Zeitspanne und Zeitmenge aufgeteilt wurde. | ||
""" | ||
|
||
# I made those _not_ optional because the entire instance of Zeitmenge is pointless if one of the two is missing | ||
hf-fvesely marked this conversation as resolved.
Show resolved
Hide resolved
|
||
start: Optional[datetime] #: inklusiver Beginn | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Pydantic v2 musst du explizit den default-Wert |
||
ende: Optional[datetime] #: exklusives Ende |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from datetime import datetime, timezone | ||
|
||
from bo4e.com.zeitspanne import Zeitspanne | ||
|
||
|
||
class TestZeitspanne: | ||
def test_zeitspanne(self) -> None: | ||
""" | ||
Test de-/serialisation of Zeitspanne | ||
""" | ||
zeitspanne = Zeitspanne( | ||
start=datetime(2013, 5, 1, tzinfo=timezone.utc), ende=datetime(2022, 1, 28, tzinfo=timezone.utc) | ||
) | ||
|
||
json_string = zeitspanne.model_dump_json(by_alias=True) | ||
|
||
assert "2013-05-01T00:00:00Z" in json_string | ||
assert "2022-01-28T00:00:00Z" in json_string | ||
|
||
zeitspanne_deserialized = Zeitspanne.model_validate_json(json_string) | ||
assert zeitspanne_deserialized == zeitspanne |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from datetime import datetime, timezone | ||
|
||
from bo4e.com.zeitspanne import Zeitspanne | ||
|
||
|
||
class TestZeitspanne: | ||
def test_zeitspanne(self) -> None: | ||
""" | ||
Test de-/serialisation of Zeitspanne | ||
""" | ||
zeitspanne = Zeitspanne( | ||
start=datetime(2013, 5, 1, tzinfo=timezone.utc), ende=datetime(2022, 1, 28, tzinfo=timezone.utc) | ||
) | ||
|
||
json_string = zeitspanne.model_dump_json(by_alias=True) | ||
|
||
assert "2013-05-01T00:00:00Z" in json_string | ||
assert "2022-01-28T00:00:00Z" in json_string | ||
|
||
zeitspanne_deserialized = Zeitspanne.model_validate_json(json_string) | ||
assert zeitspanne_deserialized == zeitspanne |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Das soll doch mit dem COM Menge verheiratet werden. Planst du, das hier einzuführen, um es später wieder rauszukicken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dfer PR ist von gestern.