fix(xueqiu/kline,earnings-date): format dates in Asia/Shanghai instead of UTC#1498
Merged
jackwener merged 2 commits intoMay 13, 2026
Merged
Conversation
0b5ad7b to
a0d953f
Compare
There was a problem hiding this comment.
Pull request overview
Fixes an off-by-one trading-day labeling bug in the xueqiu adapter by formatting kline and earnings-date timestamps as Asia/Shanghai calendar dates rather than UTC, aligning CLI output with what users see in the xueqiu UI.
Changes:
- Added
formatChinaDate(ts)helper to format timestamps inAsia/ShanghaiasYYYY-MM-DD. - Updated
xueqiu/klineandxueqiu/earnings-dateto use the new helper instead oftoISOString(). - Added Vitest coverage for the new date-formatting helper.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| clis/xueqiu/utils.js | Adds formatChinaDate to format dates in Asia/Shanghai rather than UTC. |
| clis/xueqiu/kline.js | Uses formatChinaDate for the date field to avoid UTC day-shift. |
| clis/xueqiu/earnings-date.js | Uses formatChinaDate for event date formatting. |
| clis/xueqiu/utils.test.js | Adds unit tests pinning Asia/Shanghai date semantics and nullish handling. |
Comments suppressed due to low confidence (1)
clis/xueqiu/utils.js:13
toLocaleDateString('en-CA', { timeZone: 'Asia/Shanghai' })doesn’t guarantee a stableYYYY-MM-DDoutput across runtimes/locales (and may lose zero-padding), which could break downstream consumers expecting ISO dates. Consider usingIntl.DateTimeFormatwith explicityear/month/dayoptions and assemblingYYYY-MM-DDviaformatToParts(similar toclis/tieba/utils.js’sformatTiebaUnixTime) to make the output format deterministic.
* Fetch a xueqiu JSON API from inside the browser context (credentials included).
* Page must already be navigated to xueqiu.com before calling this function.
* Throws CliError on HTTP errors; otherwise returns the parsed JSON.
*/
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a0d953f to
a25c002
Compare
2d8dd6e to
daf68af
Compare
…d of UTC (jackwener#1465) `xueqiu/kline` and `xueqiu/earnings-date` formatted bar timestamps with `new Date(ts).toISOString().split('T')[0]`. That string is the UTC calendar date, always one day earlier than the date xueqiu shows in its UI (which is Beijing-aligned for every market). Issue jackwener#1465 reports "5月10日跑的,5月8号的k线没有" because the May 8 China trading-day bar was labeled 2026-05-07. Same off-by-one was present in `earnings-date.js`. Routes both call sites through a new `formatChinaDate(ts)` helper in `clis/xueqiu/utils.js` built on `toLocaleDateString('en-CA', { timeZone: 'Asia/Shanghai' })`. Verified live against SZ300136 and AAPL: both now match the dates shown on xueqiu.com. Tests: `clis/xueqiu/utils.test.js` (new) pins the Asia/Shanghai semantic with 4 cases (China midnight, late-evening, 16:00 UTC day boundary, and nullish input). `npx vitest run --project adapter clis/xueqiu/` 49/49, `npx tsc --noEmit` clean, `npm run build` 815 entries unchanged shape. Closes jackwener#1465
daf68af to
41d2910
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
xueqiu/klineandxueqiu/earnings-dateformatted bar timestamps withnew Date(ts).toISOString().split('T')[0], which returns the UTC calendar date. xueqiu serves every market (China A-share, US, HK, etc.) on a Beijing-aligned timeline in its UI, so the UTC string is always one day earlier than the date the user actually sees on xueqiu.com.Issue #1465 reports
5月10日跑的,5月8号的k线没有because the May 8 China trading-day bar was labeled2026-05-07. The same off-by-one was present inearnings-date.js.Fix introduces
formatChinaDate(ts)inclis/xueqiu/utils.jsand routes both call sites through it. The helper usestoLocaleDateString('en-CA', { timeZone: 'Asia/Shanghai' }), which produces the ISOYYYY-MM-DDform in xueqiu's canonical timezone for all markets (verified live against bothSZ300136andAAPL).Related issue: #1465
Type of Change
Checklist
Documentation (if adding/modifying an adapter)
docs/adapters/(if new adapter)docs/adapters/index.mdtable (if new adapter)docs/.vitepress/config.mts(if new adapter)README.md/README.zh-CN.mdwhen command discoverability changedCliErrorsubclasses instead of rawError(Only the
datecolumn value formatting moves from UTC to Asia/Shanghai. Argument shape and error contract unchanged.)Screenshots / Output
SZ300136, default--days 14, run 2026-05-12:AAPL,--days 5, run 2026-05-12:npx vitest run --project adapter clis/xueqiu/49/49 green (4 new cases inclis/xueqiu/utils.test.jspin the Asia/Shanghai semantics, including the 16:00 UTC day-boundary).npx tsc --noEmitclean.npm run build815 manifest entries, unchanged shape.silent-column-drop/typed-error-lintbaselines unchanged.Closes #1465