mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
♻️ Refactor week number calculation to include ISO year (#15680)
This commit is contained in:
parent
2570a971a2
commit
b5d47b9600
1 changed files with 6 additions and 4 deletions
|
@ -18,7 +18,6 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -26,6 +25,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/siyuan-note/siyuan/kernel/model"
|
"github.com/siyuan-note/siyuan/kernel/model"
|
||||||
)
|
)
|
||||||
|
@ -238,8 +239,8 @@ func getDateInfo(dateStr string, lang string, weekdayType string) map[string]int
|
||||||
weekdayStr = date.Format("Mon")
|
weekdayStr = date.Format("Mon")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Calculate week number
|
// Calculate week number and ISO year
|
||||||
_, weekNum := date.ISOWeek()
|
isoYear, weekNum := date.ISOWeek()
|
||||||
weekNumStr := fmt.Sprintf("%dW", weekNum)
|
weekNumStr := fmt.Sprintf("%dW", weekNum)
|
||||||
|
|
||||||
switch lang {
|
switch lang {
|
||||||
|
@ -259,6 +260,7 @@ func getDateInfo(dateStr string, lang string, weekdayType string) map[string]int
|
||||||
|
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"year": year,
|
"year": year,
|
||||||
|
"isoYear": isoYear,
|
||||||
"month": month,
|
"month": month,
|
||||||
"day": day,
|
"day": day,
|
||||||
"date": fmt.Sprintf("%02d-%02d", date.Month(), date.Day()),
|
"date": fmt.Sprintf("%02d-%02d", date.Month(), date.Day()),
|
||||||
|
@ -399,7 +401,7 @@ func generateTypeFiveSVG(color string, lang string, dateInfo map[string]interfac
|
||||||
<text transform="translate(22 146.5)" style="fill: #fff;font-size: 120px; font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans', 'Noto Sans CJK SC', 'Microsoft YaHei'; ">%d</text>
|
<text transform="translate(22 146.5)" style="fill: #fff;font-size: 120px; font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans', 'Noto Sans CJK SC', 'Microsoft YaHei'; ">%d</text>
|
||||||
<text x="50%%" y="410.5" style="fill: #66757f;font-size: 200px;text-anchor: middle;font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans', 'Noto Sans CJK SC', 'Microsoft YaHei'; ">%s</text>
|
<text x="50%%" y="410.5" style="fill: #66757f;font-size: 200px;text-anchor: middle;font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans', 'Noto Sans CJK SC', 'Microsoft YaHei'; ">%s</text>
|
||||||
</svg>
|
</svg>
|
||||||
`, colorScheme.Primary, colorScheme.Secondary, dateInfo["year"], dateInfo["week"])
|
`, colorScheme.Primary, colorScheme.Secondary, dateInfo["isoYear"], dateInfo["week"])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type 6: 仅显示星期
|
// Type 6: 仅显示星期
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue