Echo JS 0.11.0

<~>

tracker1 comments

tracker1 1574 days ago. link 1 point
This site is for english content... see about page.
tracker1 1574 days ago. link 1 point
I think that Cloudflare workers are a great idea, and could be awesome for some projects.  I'm not sure there's a self-hosted option as a migration strategy though...  Short of an open platform to self-host at least for development, it just feels like the ultimate lock-in strategy.
tracker1 1583 days ago. link 2 points
I find part of the argument deeply flawed...  In particular:

> Dart is not a widespread language compared to ... Kotlin, Swift

The main reason Kotlin and Swift are widespread is because they are platform languages themselves.  Part of considering a cross-platform language is expressly to avoid/reduce the tether of platform languages.

While it seems that I have to remove several Flutter articles a week, I can see the appeal.  I also see the appeal for React Native as well as the work on Xamarin Forms, and the MAUI support coming in .Net 6 (though lack of Linux targets in the near term is disappointing there).
tracker1 1583 days ago. link 1 point
Curious if WebGPU API works without a real GPU, like in container environments... will probably play around with this a little.

Import maps in the box is nice to see as well, I think once the majority of browsers has support, that we'll probably start to see more projects move away from build tooling, which I'm not sure is better or worse.  I know that it may be better than the bundle bloat that many projects see currently.

Deno usually adds some interesting features in each minor release.  Not sure why there was a downvote on this.
tracker1 1583 days ago. link 2 points
GP is refering to "with" being used for template engines.
tracker1 1583 days ago. link 1 point
About the only time I use labels, is to pull a ripcord on existing code logic (usually larger than it should be) that would be much more cumbersome to refactor into separate function calls.

I don't use it a lot and usually have to lookup the syntax to double-check, as often I'll remember it as `:label` instead of `label:`.  Same happens with shift/unshift, I almost always have to look it up as I remember backwards.
tracker1 1583 days ago. link 1 point
Added the "(Commercial Services)" tag... this article is a bit more than roughly a howto for a single commercial service, so didn't want to just delete it.
tracker1 1589 days ago. link 2 points
Would suggest environment variables instead of a config file.
tracker1 1589 days ago. link 1 point
Looks like I can do what I need with tz-offset, which is only ~18k unpacked compared to close to moment/moment-timezone which are MASSIVE.

    var tzOffset = require("tz-offset")

    function todayAtTime(input /*17:00*/) {
      const now = new Date();
      const y = now.getFullYear();
      const m = `0${now.getMonth() + 1}`.substr(-2);
      const d = `0${now.getDate()}`.substr(-2);
      
      const ret = `${y}-${m}-${d}T${input}`;
      return ret;
    }

    function inDst(dtm) {
        const dstStart = new Date(dtm.getFullYear(), 2/*Mar*/, 14, 2);
        const dstEnd = new Date(dtm.getFullYear(), 10/*Nov*/, 7, 3);
        return (dtm < dstStart || dtm > dstEnd);
    }

    function parseAsTimezone(input, timezone, noDst) {
        const dtm = new Date(input);
        dtm.setMinutes(
            dtm.getMinutes() 
            + (-1 * dtm.getTimezoneOffset())
            + tzOffset.offsetOf(timezone)
        );
        
        const dstStart = new Date(dtm.getFullYear(), 2/*Mar*/, 14, 2);
        const dstEnd = new Date(dtm.getFullYear(), 10/*Nov*/, 7, 3)
        
        if (noDst) return dtm;
        
        switch (timezone) {
            case "America/Phoenix":
                // todo: other timezones without dst    
                break;
            default:
                if (inDst(dtm)) {
                    dtm.setHours(dtm.getHours() - 1);
                }
        }
        return dtm;
    }

    function todayAtTimezone(time, timezone) {
      return parseAsTimezone(todateAtTime(time), timezone);
    }

    // Phoenix same as Denver
    console.log(parseAsTimezone('2021-01-01T15:00:00','America/Los_Angeles').toJSON());
    console.log(parseAsTimezone('2021-01-01T15:00:00','America/Denver').toJSON());
    console.log(parseAsTimezone('2021-01-01T15:00:00','America/Phoenix').toJSON());


    // Phoenix same as LA
    console.log(parseAsTimezone('2021-05-01T15:00:00','America/Los_Angeles').toJSON());
    console.log(parseAsTimezone('2021-05-01T15:00:00','America/Denver').toJSON());
    console.log(parseAsTimezone('2021-05-01T15:00:00','America/Phoenix').toJSON());

    // Getting the Time set for a give IATA timezone TODAY
    console.log(todayAtTimezone('15:00', 'America/Los_Angeles').toJSON())
    console.log(todayAtTimezone('15:00', 'America/Denver').toJSON())
    console.log(todayAtTimezone(‘15:00', 'America/Phoenix').toJSON())
[more]