Giter Site home page Giter Site logo

dayjs-plugin-utc's People

Contributors

danazkari avatar dependabot[bot] avatar guisturdy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

dayjs-plugin-utc's Issues

setTimezoneOffset is not a function error when using `add`ing a year

Tried adding a year to a dayjs instance extended with this plugin, and it breaks, I went ahead, forked, cloned and added a test for this project and was able to reproduce:

it('add years to current date', () => {
  const addingYears = dayjs().add(1, 'y');
  expect(addingYears.year()).toBe(dayjs().year() + 1);
})

image

Typescript Definitions

Hi,

I'm trying to use this in my typescript project, but there are no type definitions.

Thanks.

`startOf` breaks offset

Hi,

Thank you for creating this plugin, but I found some issue with .startOf.

const b = dayjs.utc('2010-2-2 12:0:0').utcOffset(-450)
b.format('YYYY-MM-DD HH:mm')
// "2010-02-02 04:30"

b.hour()
// 4
b.startOf('hour').hour()
// 20 -> should be 4

b.startOf('hour').format('YYYY-MM-DD HH:mm')
// "2010-02-02 20:00" -> should be  // "2010-02-02 04:00"
b.startOf('minute').format('YYYY-MM-DD HH:mm')
// "2010-02-02 20:00" -> should be  // "2010-02-02 04:00"


b.startOf('minute').utcOffset(-450).format('YYYY-MM-DD HH:mm')
// "2010-02-02 04:30" -> works well if added `.utcOffset` again

DST issue

Daylight Savings Time seems to be an issue in the plugin.

    let utcDate = dayjs("2016-11-18:00:00:00+00:00");
    console.log(utcDate.utc().format());  // 2016-11-17T23:00:00+00:00

I'd expect 2016-11-18T00:00:00+00:00 to be the value returned.
I found that dates including and between 11/7 - 3/13 have this problem.

Or am I just missing something? (My local offset is -7, observing DST currently.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.