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

Use Date.now() and Date.parse() when a millisecond value is needed #6518

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

absidue
Copy link
Member

@absidue absidue commented Jan 5, 2025

Use Date.now() and Date.parse() when a millisecond value is needed

Pull Request Type

  • Performance improvement

Description

At the moment when we need to parse a date but get the millisecond value from it we call the Date() constructor and then call .getTime() on it, in this pull request we instead use Date.parse() which uses the same string date parsing algorithm as the Date() constructor but directly produces a number of milliseconds. I also fixed another instance of using the Date() constructor without any arguments and then calling .getTime() on it, which wasn't caught by the linter (presumably because it was split up and .getTime() was called multiple times).

Testing

  1. Refresh your subscriptions with RSS enabled and check that the published dates show up.
  2. Visit any page that has lists of videos with the local API and check that the published dates show up (e.g. search, trending, channel pages).
  3. Open a video and check that the published date shows up in the video info section.

Desktop

  • OS: Windows
  • OS Version: 10
  • FreeTube version: d4ad95b

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) January 5, 2025 17:37
@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Jan 5, 2025
@FreeTubeBot FreeTubeBot merged commit 85cec5c into FreeTubeApp:development Jan 8, 2025
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Jan 8, 2025
@absidue absidue deleted the date-optimisations branch January 8, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants