Skip to content

Commit 185c260

Browse files
committed
Enhance temporal processing in Git: apply utfardad_datum in init commit function
1 parent 0130107 commit 185c260

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

exporters/git/generate_commits.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ def create_init_git_commit(
5656
if not utfardad_datum:
5757
raise ValueError(f"utfardadDateTime saknas för {beteckning}")
5858

59+
# Apply temporal processing with utfardad_datum as target date
60+
temporal_content = apply_temporal(markdown_content, utfardad_datum, verbose=verbose)
61+
5962
# Prepare final content for local save (always clean selex tags in git mode)
60-
final_content = clean_selex_tags(markdown_content)
63+
final_content = clean_selex_tags(temporal_content)
6164

6265
# Save file locally for reference
6366
save_to_disk(output_file, final_content)

sfs_processor.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,11 @@ def _create_markdown_document(data: Dict[str, Any], output_path: Path, git_mode:
225225
# Convert table-like structures to proper Markdown tables
226226
# TODO: markdown_content = convert_tables_in_markdown(markdown_content, verbose)
227227

228-
# Apply temporal processing to handle selex attributes
229-
if git_mode:
230-
# In git mode, use utfardad_datum as the target date for temporal processing
231-
target_date = format_datetime(data.get('fulltext', {}).get('utfardadDateTime'))
232-
if not target_date:
233-
raise ValueError(f"utfardadDateTime saknas för {data.get('beteckning')}")
234-
else:
228+
# Apply temporal processing to handle selex attributes (only if not in git mode)
229+
if not git_mode:
235230
from datetime import datetime
236231
target_date = datetime.now().strftime('%Y-%m-%d')
237-
238-
markdown_content = apply_temporal(markdown_content, target_date, verbose=verbose)
232+
markdown_content = apply_temporal(markdown_content, target_date, verbose=verbose)
239233

240234
# Extract amendments for git logic (if needed)
241235
# TODO: amendments = extract_amendments(data.get('andringsforfattningar', []))

0 commit comments

Comments
 (0)