How to use Date in Javascript for prehistoric dates?

前端 未结 4 1476
盖世英雄少女心
盖世英雄少女心 2021-01-30 12:42

I’m working on a project where the JavaScript Date isn\'t big enough.

I want to place multiple events on the same time axis, some of them have month and day and some don

4条回答
  •  执笔经年
    2021-01-30 13:07

    Wrap the Date

    Create a class of your own that extends the Date class by adding a long integer field "year offset".

    Update all the methods that you want to use to apply this year offset - you can leave almost everything as-is, since you're not touching the complexities of handling time and days; maybe it will even be enough for you to change the constructors and string formatting routines to include "your" year in them.

提交回复
热议问题