Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have an error with this fix because my timezone isn't the expected one: #21895

Closed
lunny opened this issue Nov 21, 2022 · 0 comments
Closed
Labels

Comments

@lunny
Copy link
Member

lunny commented Nov 21, 2022

    I  have an error with this fix because my timezone isn't the expected one:
 FAIL  web_src/js/utils.test.js > translateDay
AssertionError: expected 'dim.' to deeply equal 'lun.'
  web_src/js/utils.test.js:127:27
    125|   const originalLang = document.documentElement.lang;
    126|   document.documentElement.lang = 'fr-FR';
    127|   expect(translateDay(1)).toEqual('lun.');
       |                           ^
    128|   expect(translateDay(5)).toEqual('ven.');
    129|   document.documentElement.lang = 'pl-PL';

  - Expected   "lun."
  + Received   "dim."

I suggest the fix must considered the same timezone (UTC) for the localised test:

 
 // given a month (0-11), returns it in the documents language
 export function translateMonth(month) {
-  return new Date(Date.UTC(2022, month, 12)).toLocaleString(getCurrentLocale(), {month: 'short'});
+  return new Date(Date.UTC(2022, month, 12)).toLocaleString(getCurrentLocale(), {month: 'short', timeZone: 'UTC'});
 }
 
 // given a weekday (0-6, Sunday to Saturday), returns it in the documents language
 export function translateDay(day) {
-  return new Date(Date.UTC(2022, 7, day)).toLocaleString(getCurrentLocale(), {weekday: 'short'});
+  return new Date(Date.UTC(2022, 7, day)).toLocaleString(getCurrentLocale(), {weekday: 'short', timeZone: 'UTC'});
 }

ping @yardenshoham

Originally posted by @fsologureng in #15541 (comment)

@lunny lunny added the type/bug label Nov 21, 2022
fsologureng added a commit to fsologureng/gitea that referenced this issue Nov 22, 2022
@lunny lunny closed this as completed in 1d52228 Nov 22, 2022
fsologureng added a commit to fsologureng/gitea that referenced this issue Nov 22, 2022
Standardize UTC timezone for `translateMonth` and `translateDay` tests.
zjjhot added a commit to zjjhot/gitea that referenced this issue Nov 23, 2022
* giteaofficial/main:
  Handle empty author names (go-gitea#21902)
  Move all remaining colors into CSS variables (go-gitea#21903)
  Add option to enable CAPTCHA validation for login (go-gitea#21638)
  Prepend refs/heads/ to issue template refs (go-gitea#20461)
  Fixes go-gitea#21895: standardize UTC tz for util tests (go-gitea#21897)
  Clarify logging documentation (go-gitea#21665)
  Update JS dependencies (go-gitea#21881)
  Webhook list enhancements (go-gitea#21893)
  Embed Matrix icon as SVG (go-gitea#21890)
  fix(web): add `alt` for logo in home page (go-gitea#21887)
  Improvements for Content Copy (go-gitea#21842)
  Replace yaml.v2 with yaml.v3 (go-gitea#21832)
  Allow disable RSS/Atom feed (go-gitea#21622)
  Consolidate security-check into checks-backend (go-gitea#21882)
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant