0.5.0 • Published 2 years ago

@awes-io/dayjs v0.5.0

Weekly downloads
129
License
MIT
Repository
github
Last release
2 years ago

Date Convertation Module for Awes.io

Based on dayjs

Basic usage

  1. Install module yarn add @awes-io/dayjs
  2. Add module to nuxt.config.js
// nuxt.config.js

export default {
    modules: [
        // ... some other modules
        '@awes-io/dayjs'
    ]
}
  1. Now you are ready to use it

By default, the module will parse i18n.locales in nuxt.config.js to load additional localization

<template>
    <div>
        {{ $dayjs(new Date()).format('DD/MM/YYYY') }}
    </div>
</template>
export default {
    data() {
        return {
            date: new Date()
        }
    },

    computed: {
        formatted() {
            return this.$dayjs(this.date).format('HH:mm:ss')
        }
    }
}
  1. Additional configuration
// nuxt.config.js

export default {
    modules: [
        // ... some other modules
        '@awes-io/dayjs'
    ],

    awesIo: {
        // default configuration
        dayjs: {
            stringFormat: {
                pattern: null,
                format: true
            },
            plugins: [
                'dayjs/plugin/customParseFormat',
                'dayjs/plugin/localizedFormat'
            ]
        }
    }
}

You may provide default format for parsing and formatting string dates, like this:

export default {
    modules: [
        // ... some other modules
        '@awes-io/dayjs'
    ],

    awesIo: {
        dayjs: {
            // parse and format...
            stringFormat: 'YYYY-MM-DD[T]HH:mm:ssZZ'

            // ...or parsing only
            // stringFormat: {
            //     pattern: 'YYYY-MM-DD[T]HH:mm:ssZZ',
            //     format: false
            // }
        }
    }
}

To add more plugins, pass an array to plugins property, they will be merged with defaults

export default {
    modules: [
        // ... some other modules
        '@awes-io/dayjs'
    ],

    awesIo: {
        dayjs: {
            plugins: [
                'dayjs/plugin/relativeTime',
                { src: '~/assets/js/my-plugin', options: { something: true } }
            ]
        }
    }
}

Ensure to write proper commit message according to Git Commit convention

0.5.0

2 years ago

0.4.0

3 years ago

0.3.5

3 years ago

0.3.3

3 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago