From e2e3e02a1b1266043c878c87b8d2654abc0afa34 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sun, 24 May 2026 18:42:58 +0300 Subject: [PATCH] =?UTF-8?q?fix(skd):=20=D1=81=D0=BE=D1=85=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D1=8F=D1=82=D1=8C=20=D1=8F=D0=B2=D0=BD=D1=8B=D0=B5=20sta?= =?UTF-8?q?rtDate/endDate=20=D0=B2=20top-level=20StandardPeriod=20paramete?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Параметр типа StandardPeriod с variant=Custom может иметь явные даты, отличающиеся от default 0001-01-01T00:00:00 (например endDate=23:59:59). См. АнализПричинБлокировкиВычетаНДС @941. Раньше decompile сохранял variant только если ≠Custom (для Custom — ничего), и compile эмитил захардкоженные 0001-01-01T00:00:00 для обеих дат. Теряли явное время. decompile: для StandardPeriod с явными датами (любая ≠00:00:00) → object form {variant: Custom, startDate, endDate}. compile (PS+Py): Emit-ParamValue принимает dict val с variant/startDate/ endDate; для Custom без явных дат сохраняется текущий fallback на 0001-01-01T00:00:00. Sample30 total: 620 → 618 строк diff. --- .../skd-compile/scripts/skd-compile.ps1 | 26 ++++++++++++++++--- .../skills/skd-compile/scripts/skd-compile.py | 18 ++++++++++--- .../skd-decompile/scripts/skd-decompile.ps1 | 16 +++++++++--- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/.claude/skills/skd-compile/scripts/skd-compile.ps1 b/.claude/skills/skd-compile/scripts/skd-compile.ps1 index d484f0bd..fb258c67 100644 --- a/.claude/skills/skd-compile/scripts/skd-compile.ps1 +++ b/.claude/skills/skd-compile/scripts/skd-compile.ps1 @@ -1,4 +1,4 @@ -# skd-compile v1.96 — Compile 1C DCS from JSON +# skd-compile v1.97 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$DefinitionFile, @@ -1502,7 +1502,23 @@ function Emit-ParamValue { return } - $valStr = "$val" + # val может быть строкой (variant only) или объектом {variant, startDate?, endDate?}. + $valIsDict = ($val -is [hashtable]) -or ($val -is [System.Collections.IDictionary]) -or ($val -is [PSCustomObject]) + $variantStr = $null + $sdStr = $null + $edStr = $null + if ($valIsDict) { + if ($val -is [PSCustomObject]) { + if ($val.PSObject.Properties['variant']) { $variantStr = "$($val.variant)" } + if ($val.PSObject.Properties['startDate']) { $sdStr = "$($val.startDate)" } + if ($val.PSObject.Properties['endDate']) { $edStr = "$($val.endDate)" } + } else { + if ($val.Contains('variant')) { $variantStr = "$($val['variant'])" } + if ($val.Contains('startDate')) { $sdStr = "$($val['startDate'])" } + if ($val.Contains('endDate')) { $edStr = "$($val['endDate'])" } + } + } + $valStr = if ($variantStr) { $variantStr } else { "$val" } if ($type -eq "StandardPeriod") { # Platform-pattern: startDate/endDate эмитятся ТОЛЬКО для variant=Custom. @@ -1510,8 +1526,10 @@ function Emit-ParamValue { X "$indent" X "$indent`t$(Esc-Xml $valStr)" if ($valStr -eq 'Custom') { - X "$indent`t0001-01-01T00:00:00" - X "$indent`t0001-01-01T00:00:00" + $sdOut = if ($sdStr) { $sdStr } else { '0001-01-01T00:00:00' } + $edOut = if ($edStr) { $edStr } else { '0001-01-01T00:00:00' } + X "$indent`t$(Esc-Xml $sdOut)" + X "$indent`t$(Esc-Xml $edOut)" } X "$indent" } elseif ($type -match '^date') { diff --git a/.claude/skills/skd-compile/scripts/skd-compile.py b/.claude/skills/skd-compile/scripts/skd-compile.py index 7213089f..ad2cef33 100644 --- a/.claude/skills/skd-compile/scripts/skd-compile.py +++ b/.claude/skills/skd-compile/scripts/skd-compile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# skd-compile v1.96 — Compile 1C DCS from JSON +# skd-compile v1.97 — Compile 1C DCS from JSON # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import json @@ -1040,15 +1040,25 @@ def emit_param_value(lines, type_str, val, indent, value_list_allowed=False): emit_empty_value(lines, type_str, indent, '', value_list_allowed) return - val_str = str(val) + # val может быть строкой (variant only) или dict {variant, startDate?, endDate?}. + variant_str = None + sd_str = None + ed_str = None + if isinstance(val, dict): + variant_str = str(val.get('variant')) if val.get('variant') is not None else None + sd_str = str(val['startDate']) if 'startDate' in val else None + ed_str = str(val['endDate']) if 'endDate' in val else None + val_str = variant_str if variant_str else str(val) if type_str == 'StandardPeriod': # Platform-pattern: startDate/endDate ТОЛЬКО для variant=Custom. lines.append(f'{indent}') lines.append(f'{indent}\t{esc_xml(val_str)}') if val_str == 'Custom': - lines.append(f'{indent}\t0001-01-01T00:00:00') - lines.append(f'{indent}\t0001-01-01T00:00:00') + sd_out = sd_str if sd_str else '0001-01-01T00:00:00' + ed_out = ed_str if ed_str else '0001-01-01T00:00:00' + lines.append(f'{indent}\t{esc_xml(sd_out)}') + lines.append(f'{indent}\t{esc_xml(ed_out)}') lines.append(f'{indent}') elif type_str and re.match(r'^date', type_str): lines.append(f'{indent}{esc_xml(val_str)}') diff --git a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 index 3393376f..6a5ab9bc 100644 --- a/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 +++ b/.claude/skills/skd-decompile/scripts/skd-decompile.ps1 @@ -1,4 +1,4 @@ -# skd-decompile v0.79 — Decompile 1C DCS Template.xml to JSON DSL (draft) +# skd-decompile v0.80 — Decompile 1C DCS Template.xml to JSON DSL (draft) # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [Parameter(Mandatory)] @@ -755,8 +755,18 @@ function Build-Parameter { $vType = Get-LocalXsiType $valueNode if ($vType -eq 'StandardPeriod') { $variant = Get-Text $valueNode "v8:variant" - if ($variant -and $variant -ne 'Custom') { $valueDisplay = $variant } - # Custom with explicit dates → object form (handled below via needsObject) + $sd = Get-Text $valueNode "v8:startDate" + $ed = Get-Text $valueNode "v8:endDate" + $hasExplicitDates = ($sd -and $sd -ne '0001-01-01T00:00:00') -or ($ed -and $ed -ne '0001-01-01T00:00:00') + if ($hasExplicitDates) { + # Custom с явными датами → object form {variant, startDate, endDate} + $valueDisplay = [ordered]@{ variant = $variant } + if ($sd) { $valueDisplay['startDate'] = $sd } + if ($ed) { $valueDisplay['endDate'] = $ed } + } elseif ($variant -and $variant -ne 'Custom') { + $valueDisplay = $variant + } + # Custom без явных дат — valueDisplay = null, compile подставит 0001-01-01. } elseif ($vType -eq 'DesignTimeValue') { $valueDisplay = $valueNode.InnerText } elseif ($vType -eq 'LocalStringType') {