Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Ronny Hanssen
    @Spiralis
    Hi guys. I am new to day.js, but it seems like it could be a good fit for me.
    I am creating a library that other web-apps will be using. The most common use-case is for the library to be consumed via a script-tag in the browser, where they would then initialize the library.
    I have two questions:
    1. I want the end-users to be able to get the dates I use via day.js in their native language (when day.js supports it). But, I am worried about importing all locales before I build the script, as the resulting library would be way larger than ideal/necessary.
    2. Since day.js doesn't support timezones, would I have to detect the users timezone and convert that to/from UTC (as the backend will always use UTC)
    Ronny Hanssen
    @Spiralis
    I think I can perhaps load the locales dynamically from the CDN, perhaps? But, if my main library is loaded via npm, how can I then add dynamically loaded locales from CDN to the days instance? Is there an API for that?
    iamkun
    @iamkun
    @Spiralis Day.js will use user's current timezone. But you can also use UTC plugin to force get UTC time.
    Dynamic loading should be implemented in your js logic code not a Day.js feature.
    Jurgis Bridžius
    @bridzius
    Hello! I saw that there is a PR - iamkun/dayjs#375 - which is aimed towards enabling a "strict mode" when validating dayjs('812024', 'YYMMDD').isValid() === false. It's conflicting now, but are there plans to merge this in the future? Or is a different solution in the works?
    iamkun
    @iamkun
    @bridzius I think a "strict mode " is important in some cases. We might could introduce this as a plugin to support both core dayjs as well as customParseFormat plugin.
    Nuno Coelho
    @nvcoelho_twitter
    Hi there I'm looking for the locals for Xhosa and Afrikaans, seems they are not supported?
    iamkun
    @iamkun
    @nvcoelho_twitter PR welcomed
    wcldyx
    @wcldyx
    hello
    wesslim
    @wesslim
    Hi, it's possible to convert merely from minutes to hours and minutes?
    eg. 90minutes convert to 1 hour 30 minutes
    iamkun
    @iamkun
    @wesslim no at this time.
    we could add a plugin to support this, and similar libs?
    wesslim
    @wesslim
    i believe it will be helpful to has plugin offer this function,
    and thanks,
    ggraffion-accor
    @ggraffion-accor
    Hello,
    When is the next release planned?
    I need this fix iamkun/dayjs@e5a257c on my project =)
    iamkun
    @iamkun
    @ggraffion-accor released 1.8.15 today
    ggraffion-accor
    @ggraffion-accor
    @iamkun Perfect, thanks!
    gotounix
    @gotounix
    Is there Chinese friends use dayjs on wechat mini program?
    const dayjs = require('../../utils/dayjs.min.js')
    const dayjsPluginUTC = require('../../utils/dayjs-plugin-utc.min.js')
    dayjs.extend()
    I got an error message:Uncaught TypeError: t is not a function
    Anybody knows how to fix it? Thanks
    iamkun
    @iamkun
    @gotounix dayjs.extend(dayjsPluginUTC.default)
    年糕小豆汤
    @iamcco
    Hi guys, dayjs how to format date to rfc3339 format ? like 2019-12-24T15:59:59Z
    Paul
    @dagda1
    Hi all, is there anyway to have a strict mode.
    import dayjs from 'dayjs';
    import customParseFormat from 'dayjs/plugin/customParseFormat';
    
    dayjs('2020-13-32', 'YYYY-MM-DD').isValid()  // wrong on both month and year
    in fact
    import dayjs from 'dayjs';
    import customParseFormat from 'dayjs/plugin/customParseFormat';
    
    dayjs('2020-99-78', 'YYYY-MM-DD').isValid()
    I'm pretty sure I'm doing something very daft as the bottom one is about as invalid as can be
    I am on dayjs@1.8.25
    iamkun
    @iamkun
    @dagda1 Yes in next release iamkun/dayjs#882
    iamkun
    @iamkun
    stirct mode released dayjs@1.8.26. @dagda1
    Eric Martinez
    @ericmartinezr
    Hey guys, I'm using dayjs and the plugin dayjs-business-days
    I've added like this in my class. I'm using Angular.
    import dayjs from 'dayjs';
    import dayjsBusinessDays from 'dayjs-business-days';
    
    export class Class {
      constructor() {
        dayjs.extend(dayjsBusinessDays);
      }
    
      add(fechaInicio: Date, dias: number): Date {
        return dayjs(fechaInicio)
          .businessDaysAdd(dias)
          .toDate();
      }
    }
    and I created a .d.ts file for it
    import { Dayjs } from 'dayjs';
    
    declare module 'dayjs' {
      interface Dayjs {
        businessDaysAdd(days: number);
      }
    }
    There's no linting issue, but when I run it I get
    error TS2339: Property 'businessDaysAdd' does not exist on type 'Dayjs'
    Is there something I'm missing?
    iamkun
    @iamkun
    @ericmartinezr make sure the d.ts file you added is included in ts config
    Artem Gusev
    @corocoto
    Hi everybody :) @iamkun I'm finished docs translation on russian. Please, check it. Thanks
    iamkun
    @iamkun
    @CreativeRusBear Cool thanks. I just released a new doc.
    Apoorv Mishra
    @apoorv-mishra
    Hi everyone :wave: , just published a CLI tool for guessing a date's format at https://github.com/apoorv-mishra/moment-guess. Hope that it might turn out to be useful for dayjs users :smiley:
    Eugene Serkin
    @jeserkin
    Good evening chat. I was wondering if there is way to globally set, what timezone I wish to use with dayjs?
    iamkun
    @iamkun
    @jeserkin No, at present. Feel free to open an issue for this feature request.
    Sabin Bogati
    @sabinbogati1
    hello
    iamkun
    @iamkun
    sasial
    @sasial-dev

    Hiya!
    I'm making a node.js library, and I want it to return a DayJS class, how do I set it up so it returns the DayJS Class (that people can use its methods on), and have it shown in my JSDOCS?
    Do I use

    const dayjs = require('dayjs')

    or

    const { Dayjs } = require('dayjs')

    Thanks,
    Sasial.

    sasial
    @sasial-dev
    Basically, I just want to return a dayjs object, and allow people to use it normally.
    sasial
    @sasial-dev
    @iamkun
    iamkun
    @iamkun
    @sasial-dev dayjs() will returns you a dayjs obejct
    sasial
    @sasial-dev

    @iamkun I've gone and updated my code now,
    Library:

         /**
         * TEST
         *
         * @returns {dayjs} 
         * @memberof APIClient
         */
        async test() {
          return dayjs()
        }

    Test Script

    mylib.test().then(day => {
        console.log(day.to(day.add(6, "m")))
    })

    Now while this works (returning a dayjs object), there's no VSC autocomplete or anything?
    How can I set it up so it knows it's returning a dayjs object?