Skip to content

Improve documenation for quickly using this as a wrapper for other date libraries #613

@YPCrumble

Description

@YPCrumble

I've read the README and I think that this library may do what I want it to, but I'm not sure. If it does do what I think it does, I would love to help improve the README to make the potential clearer!

Here's what I'm looking for:

I want a wrapper around MomentJS, date-fns, dayjs, luxon, that allows me as a library author to use date-io in my library and then allow users of the library to install one of those four alternatives as a peer dependency, and the date functionality should just work.

So essentially, let's say I'm using MomentJS. I should be able to replace this code:

// my-logic-file.js
import moment from 'moment'

const now = moment().format('MMMM Do YYYY, h:mm:ss a')
console.log(now)

with something like this:

// custom-date-io.js
import dateio from 'dateio'
import moment from 'moment'

dateio.setup(moment)
export default dateio
// my-logic-file.js
import dateio from 'custom-date-io'

// I'm pretty sure this is the dateio format but not 100% sure
const now = dateio.date().format('fullDateTime12h')
console.log(now)

In the README, however, it appears that as a library author I have to choose one specific library for my users. For instance, the example in the readme chooses date-fns for its users here:

// you-awesome-lib/adapters/date-fns
export { default } from "@date-io/date-fns";

So perhaps what I'm looking for is not currently possible?

Thanks for building this and for taking a look at this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions