What does HackerNews think of proposal-temporal?
Provides standard objects and functions for working with dates and times.
> 2022-11-23T08:52:02!Europe/London
There is a IETF standard proposal, which is very closed to getting finalised, that defines a similar format:
2022-11-23T08:52:02+01:00[Europe/London]
ref: https://datatracker.ietf.org/doc/draft-ietf-sedate-datetime-...It's already in use by the Temporal TC39 proposal, which defines new types for working with temporal data in JavaScript.
- https://github.com/tc39/proposal-temporal
- https://github.com/tc39/proposal-temporal#polyfills
- https://tc39.es/proposal-temporal/
- https://tc39.es/proposal-temporal/docs/index.html
- https://github.com/tc39/proposal-temporal/issues/1450
- https://tc39.es/proposal-temporal/docs/parse-draft.html
As far as I know, issue #1450 is the last remaining blocker for the standardization. I'd assume that this will be resolved in the next months. So Temporal will likely be officially released with ECMAScript 2023, but browser vendors and other implementors will start shipping it before the offical release.
> NOTE: Although this proposal's API is not expected to change, implementers of this proposal MUST NOT ship unflagged Temporal implementations until IETF standardizes timezone/calendar string serialization formats. See #1450 for updates.
it's basically already accepted. Stage 3 means it's basically ready for a preview implementation and stage 4 means passed for "official" ecmascript inclusion
I think the major thing that will take time behind getting Temporal to Stage 4 is aligning with IETF on [a draft update RFC 3339](https://github.com/ryzokuken/draft-ryzokuken-datetime-extend...)
https://github.com/tc39/proposal-temporal
JS standard libraries are forever. It pays to take a bit more time and get it right.
I think we can all agree the Date API sucks, but life can still be good if you just give in and include a date library. Also, there's some light at the end of the tunnel with Temporal proposal coming along [1].
Object.keys returning string[] is purely a TypeScript design decision, coming from how TypeScript chooses to model object subtyping [2].
type Foo = {
a: string
}
const keysOfFoo = (obj: Foo) => Object.keys(obj)
const foo = {a: '', b: 5}
keysOfFoo(foo)
The fact that this passes type checks is a conscious TS design decision that comes with both advantages and disadvantages. It wouldn't have to be this way; Exact types [3] could potentially be used to describe that if the type is exactly Foo, it's safe to assume Object.keys(foo) is (keyof Foo)[].For first class tuples (and records), there's a stage 2 EcmaScript proposal coming along [4]. There's of course also the readonly [] type in TypeScript if you only need the safety of not accidentally pushing to an "immutable" array. First class language support could have nice additional features though, like strict equality.
Anyways, if these are the things you don't like about JS/TS, I don't think AssemblyScript will be the answer for you, as the goals of that language seem to be entirely different from "fixing" old JS cruft. Apart from the i32, i64 stuff I guess.
[1] https://github.com/tc39/proposal-temporal
[2] https://github.com/Microsoft/TypeScript/pull/12253#issuecomm...
[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
https://github.com/tc39/proposal-temporal
At a glance, it does follow the same ideas as the great Joda Time library (now a part of the Java standard library), and there's currently a port of this library for JS which is quite nice: