D
Deno

help

Date library

Llinker_error12/11/2023
Can anyone recommend a decent working date library for deno? All the ones I'm trying (datefns, dayjs) are giving me errors or are not giving me types (no ctrl-click on symbols) in VS Code. Like, am I doing something wrong? This is crazy... every single package I try is either errors or no symbols...
"date_fns": "npm:date-fns@2.30.0",

"date_fns": "npm:date-fns@2.30.0",

I have this in my import map. My app compiles, but I don't get symbols. also tried importing both of these through esm.sh no dice
DAHDeno AI Helper12/11/2023
I wasn't able to find a specific recommendation for a date library in the official Deno documentation. However, I can provide some general advice based on your message. If you're experiencing issues with libraries like date-fns or dayjs, it could be due to compatibility issues or incorrect imports. Since Deno uses ES modules, make sure you are importing the libraries correctly with the full path that includes the .ts or .js extension, and from a CDN that supports Deno if the library is not natively a Deno module. For instance, when using date-fns, you should import it from a Deno-compatible source like this:
import { format } from 'https://deno.land/x/date_fns/index.js';
import { format } from 'https://deno.land/x/date_fns/index.js';
For dayjs, you would need to find a version that is compatible with Deno or a CDN that provides it in a Deno-friendly format. Regarding the lack of types and the inability to use ctrl-click on symbols in VS Code, this could be due to missing type definitions for the libraries you are using. If the libraries are not natively built for Deno, they might not include type definitions that Deno or VS Code can automatically detect. You can sometimes find or create type definition files (.d.ts) for these libraries, which can help with type checking and editor features like symbol navigation. Please note that this advice is not based on the Deno documentation, and I would recommend double-checking the accuracy of this advice and looking for any updates or community solutions that might address these issues. Additionally, you might want to check the Deno third-party module registry (https://deno.land/x) for any date libraries that are specifically designed for Deno, as they are more likely to be compatible and come with proper type definitions.
Jjeff.hykin12/12/2023
Yeah I didn't like the existing ones so I wrote my own
import DateTime from "https://deno.land/x/good@1.6.0.0/date.js"
import DateTime from "https://deno.land/x/good@1.6.0.0/date.js"
Note this is not a recommendation sadly, as it does not have any type annotations, it's very mutable, and it doesn't handle timezone all that well. Yet somehow it's still better than the built-in Date (it's backwards compatible with all methods)
Jjcayzac12/12/2023
import moment from 'https://esm.sh/moment@2.29.4' seems to work fine for me There's also a https://deno.land/x/momentjs which claims to be a "Deno compatible" version, although I'm not sure what exactly is the problem with the vanilla/upstream version of Moment. Vanilla import from esm.sh works fine for me. That x/ library also seems abandonned (single commit 3 years ago).

Looking for more? Join the community!

Recommended Posts
await writer.write(buffer) never resolves on Deno.CommandHiho. I'm creating a `Deno.Command` that writes a buffer to `vipsthumbnail` via stdin (and reads theNot sure if I understand kv watch right?Not sure if I understand kv watch right, is like named queues? o more like a reliable Broadcast chanDisplaying a ModalI am trying to get a minimal example of using Bootstrap Modals, and managing that modal using state.How do I run an npm script with multiple dependencies, e.g. `drizzle-kit generate:pg`?I thought about wrapping it into a task `"generate": "deno run -A npm:drizzle-kit generate:pg"` in tHow to use a class name as a qualifier for an enum ?Hi there, it's more of a generic typescript question but I'm using it in the Deno context and the lihow can I make him see the process?```ts error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'on') proImporting NPM Packages in Deno Throws 'Uncaught SyntaxError' for Specific ModulesHi there, I'm relatively new to Deno. I'm running into an error with an NPM package import. ```JS imHow to override type definitions provided by a third party module@Deno AI Helper How do I override type definitions provided by a third party moduleSync Child Stdin ReadI'd like to make a JS wrapper around the repl of another language. For example: ```js let a = otherUsing custom font using fresh and tailwindcssHello ! I recently followed [this guide](https://fresh.deno.dev/docs/examples/migrating-to-tailwindwasm-vips file does not existOk this is not directly a deno thing, but anyway. Has anyone successfully used wasm-vips with `vips.update imports to latest version in `deno.json`i defined imports as URLs with the version of the packages in my `deno.json` file. i would like to kAttempt on adding ref/unref on UDPHello, issue [#20138](https://github.com/denoland/deno/issues/20138) is about `unref` not being implFresh migrating from serveTlsIn my `main.ts` file for Fresh I have some code I borrowed from source a few minor versions ago to sServing static websiteI have a static website with an index.html that imports a main.js and css file. When serving index.hpositional arguments deno taskCan I use positional arguments in deno task? I have a number of scripts that I frequently want to rLinter does not warn about lack of constructor arguments.The vscode shows that there are no arguments, but linter does not show it as an error: ``` root@instCan you make a fresh route detect, if it is being requested by `deno run`Can you make a fresh route detect, if it is being requested by `deno run` like `deno run https://locDeno dependency top level await work aroundI have the following error while building with dnt ``` [dnt] Top level await cannot be used when disBundling a CLI written in JS with DenoHi team, Thanks for writing this [excellent blog-post (and video)](https://deno.com/blog/roll-your-