proposal-temporal | Provides standard objects and functions for working with dates and times | Math library
kandi X-RAY | proposal-temporal Summary
kandi X-RAY | proposal-temporal Summary
Date has been a long-standing pain point in ECMAScript. This proposes Temporal, a global Object that acts as a top-level namespace (like Math), that brings a modern date/time API to the ECMAScript language. For a detailed breakdown of motivations, see: Fixing JavaScript Date.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Render docs .
- Render a markdown file
- Build the main lix tree .
- Escape the given html .
- Returns an english language string .
proposal-temporal Key Features
proposal-temporal Examples and Code Snippets
Community Discussions
Trending Discussions on proposal-temporal
QUESTION
Using the Temporal.Calendar of the upcoming proposal of the Temporal global Object, the following short function converts between calendar dates (the 18 Calendars recognized in Javascript).
Currently, the output date returned by Temporal.Calendar for other Calendars is in the format (example): '2022-02-25[u-ca=persian]'
How to avoid usingtoString().split("[")[0])
to get the calendar date without the suffix [u-ca=CalendarName]
as the Intl.DateTimeFormat()
does not recognize the suffix?
ANSWER
Answered 2022-Feb-25 at 18:33You can pass the Temporal.PlainDateTime object directly to Intl.DateTimeFormat, or indirectly by using Temporal.Calendar.prototype.toLocaleString(). This should save you from having to split the string to remove the brackets.
(A good rule of thumb is that if you find yourself doing string manipulation with the output of toString() from any Temporal object, or using new Date()
for that matter, it's probably a sign that there's a Temporal method you should be using instead.)
One caveat is that you have to make sure that the calendar of the locale matches the calendar of the date you are formatting. You can't use toLocaleString() or Intl.DateTimeFormat to do calendar conversion (unless it is from the ISO 8601 calendar). So you should use the withCalendar() method to convert the date to the calendar you want to output it in, as well as making sure the calendar in the Intl options matches it.
Here's my attempt at such a function:
QUESTION
I am trying to use Temporal yearMonth.subtract but is not working. add
is working as expected.
Demo: https://codesandbox.io/s/objective-knuth-20ov2?file=/src/index.js
...ANSWER
Answered 2021-Dec-10 at 19:07Applying the Temporal toPlainYearMonth
method to currentMonth
before the addition/subtraction operation is causing the problem.
This works as expected:
QUESTION
I must convert a date time, given its time zone, year, month, day, hours and minutes to an ISO string.
For example, given the following parameters:
...ANSWER
Answered 2020-Nov-18 at 14:16here is my answer:
QUESTION
When I put a element inside an SVG file, and then the SVG image is resized, Safari resizes graphical elements smoothly but resizes fonts in a "jumpy" way. This Safari behavior makes it hard to line up text and non-text elements because the text size changes relative to the other elements as the page is resized.
Is there a workaround to force either smooth font resizing in Safari or, if that's not possible, at least to resize both fonts and non-font elements in the same jumpy way so they won't get misaligned?
The image below is an example of this. If I resize the page in Firefox or Chrome, the green, orange, and pink boxes stay in the same place relative to the text underneath. If I horizontally shrink the page in Safari so that the image is resized, the text keeps jumping around horizontally, which causes the text and the boxes to be misaligned for some browser sizes.
The image is from here: https://raw.githubusercontent.com/tc39/proposal-temporal/579788fd110e56d70a00bab5da5926cd419f995f/docs/persistence-model.svg
FWIW, the only reference I could find to this behavior is a sad, 9-year-old post complaining about the same problem. Safari / Webkit Animating Font Size is Jumpy. It's so old that Chrome had the same problem before it was forked from WebKit. ;-(
...ANSWER
Answered 2020-Nov-11 at 00:42Aha! After experimenting with various CSS tweaks, I found an easy solution: text-rendering: geometricPrecision
solves the jumpy-text-resize problem on Safari without noticeably degrading anything in Chrome or Firefox.
To explain why it works, here's what MDN says:
In SVG, when text is scaled up or down, browsers calculate the final size of the text (which is determined by the specified font size and the applied scale) and request a font of that computed size from the platform's font system. But if you request a font size of, say, 9 with a scale of 140%, the resulting font size of 12.6 doesn't explicitly exist in the font system, so the browser rounds the font size to 12 instead. This results in stair-step scaling of text.
But the
geometricPrecision
property — when fully supported by the rendering engine — lets you scale your text fluidly. For large scale factors, you might see less-than-beautiful text rendering, but the size is what you would expect—neither rounded up nor down to the nearest font size supported by Windows or Linux.
Here's the updated version of the SVG image that doesn't exhibit the Safari problem. Safari still seems to have a small font-size measurement error relative to Chrome/FF (fonts are not quite the same width) but it's much better than the jumpy behavior I was seeing before.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install proposal-temporal
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page