Socket
Socket
Sign inDemoInstall

@awes-io/dayjs

Package Overview
Dependencies
2
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @awes-io/dayjs

Date convertation module for Awes.io


Version published
Weekly downloads
25
increased by127.27%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 15 Nov 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc