@@ -58,6 +58,9 @@ proc ::twic::downloadWeek {week} {
5858 -message " Error downloading TWIC week $weeknum :\n $err "
5959 return
6060 }
61+
62+ # Store week number for final message
63+ set ::twic::weekNumber $weeknum
6164}
6265
6366# twic::getCurrentWeekNumber
@@ -66,10 +69,10 @@ proc ::twic::downloadWeek {week} {
6669# Each week increments by 1, released on Monday at ~8pm EST
6770#
6871proc ::twic::getCurrentWeekNumber {} {
69- # Use a known reference: Week 1621 on approximately Dec 4 , 2025
70- # Reference epoch: Dec 4 , 2025 00:00:00 UTC
72+ # Use a known reference: Week 1621 on approximately Dec 2 , 2025
73+ # Reference epoch: Dec 2 , 2025 00:00:00 UTC
7174 set reference_week 1621
72- set reference_epoch 1764758400 ;# 2025-12-04 00:00:00 UTC
75+ set reference_epoch 1764633600 ;# 2025-12-02 00:00:00 UTC
7376
7477 set current_epoch [clock seconds]
7578
@@ -125,7 +128,7 @@ proc ::twic::downloadTWICWeek {weeknum} {
125128 error " Downloaded file is empty or missing"
126129 }
127130
128- ::twic::extractZIP $zipfile
131+ ::twic::extractZIP $zipfile $weeknum
129132}
130133
131134# twic::downloadWithHTTP
@@ -171,7 +174,7 @@ proc ::twic::downloadZIP {zipurl} {
171174# Extract PGN files from ZIP archive
172175# Tries multiple methods: unzip command, then Tcllib vfs::zip, then fallback zip handling
173176#
174- proc ::twic::extractZIP {zipfile} {
177+ proc ::twic::extractZIP {zipfile weeknum } {
175178 set extractdir [file join $::twic::tempDir " extracted" ]
176179 file mkdir $extractdir
177180
@@ -349,16 +352,16 @@ proc ::twic::extractZIP {zipfile} {
349352
350353 # If multiple PGN files, merge them first
351354 if {[llength $pgnfiles ] > 1} {
352- ::twic::mergePGNFiles $pgnfiles
355+ ::twic::mergePGNFiles $pgnfiles $weeknum
353356 } else {
354- ::twic::openPGNInImport [lindex $pgnfiles 0]
357+ ::twic::openPGNInImport [lindex $pgnfiles 0] $weeknum
355358 }
356359}
357360
358361# twic::mergePGNFiles
359362# Merge multiple PGN files into a single file
360363#
361- proc ::twic::mergePGNFiles {pgnfiles} {
364+ proc ::twic::mergePGNFiles {pgnfiles weeknum } {
362365 set outputfile [file join $::twic::tempDir " twic_merged.pgn" ]
363366
364367 if {[catch {
@@ -380,13 +383,13 @@ proc ::twic::mergePGNFiles {pgnfiles} {
380383 error " Error merging PGN files: $err "
381384 }
382385
383- ::twic::openPGNInImport $outputfile
386+ ::twic::openPGNInImport $outputfile $weeknum
384387}
385388
386389# twic::openPGNInImport
387390# Open the PGN file in the import dialog
388391#
389- proc ::twic::openPGNInImport {pgnfile} {
392+ proc ::twic::openPGNInImport {pgnfile weeknum } {
390393 # Re-enable the menu item
391394 catch {.menu.tools entryconfig " Download TWIC*" -state normal}
392395 set ::twic::downloading 0
@@ -404,12 +407,12 @@ proc ::twic::openPGNInImport {pgnfile} {
404407 set destdir [pwd ]
405408 }
406409
407- set destfile [file join $destdir " twic_[ clock format [ clock seconds ] -format %Y%m%d] .pgn" ]
410+ set destfile [file join $destdir " twic_${weeknum} .pgn" ]
408411
409412 # Make sure destination is writable and unique
410413 set counter 1
411414 while {[file exists $destfile ]} {
412- set destfile [file join $destdir " twic_[ clock format [ clock seconds ] -format %Y%m%d]_ $ counter .pgn" ]
415+ set destfile [file join $destdir " twic_${weeknum} _ ${ counter} .pgn" ]
413416 incr counter
414417 }
415418
@@ -429,7 +432,7 @@ proc ::twic::openPGNInImport {pgnfile} {
429432 ::file::Open $destfile
430433
431434 tk_messageBox -icon info -type ok -title " TWIC Download Complete" \
432- -message " TWIC games downloaded successfully.\n\n File: [ file tail $destfile ] \n\n You can now filter, merge, or import these games."
435+ -message " TWIC games downloaded successfully.\n\n Week: $weeknum \ n File: [ file tail $destfile ] \n\n You can now filter, merge, or import these games."
433436}
434437
435438# twic::getTempDir
0 commit comments