Comments (14)
It would be nice if the toFormat( ) series of functions took symbols for timezones such as Z etc. So we can generate string dates that have an offset of -05:00 for example
from date-utils.
I would be nice if there was a version that does not alter the default Date object prototype.
from date-utils.
Check out cromag.js
from date-utils.
I want crop feature. sometimes I need to set milisecond, second, minute field to zero. I'd like to see that feature in date-utils.
from date-utils.
What about i18n? :)
from date-utils.
Just to continue on #36 and compacting the API, I would propose the following:
- Instead of
Date.validateDay
etc. go forDate.validate
. In this case the date atom is passed within an Object (ie{day: 4}
). The function should check out the parameters and raise error/warning depending on Object contents. - Instead of
d.addMilliseconds
etc. go forDate.add
. Same idea as above. - Instead of
d.removeMilliseconds
etc. go forDate.remove
. Same idea as above. - Consider merging
d.add
andd.remove
into a single method,d.offset
. In this case the direction would be determined based on whether passed number is positive or negative. Ie. to remove a day you would dod.offset({day: -1})
.
Doing this would remove 20-21 functions/methods from the API depending whether you go with offset
.
Maybe there are other ways to compact but these seem the most obvious.
from date-utils.
i like the idea of compacting the api - want to finish documenting everything so there is fresh knowledge, and a good tag for 1.x.
from date-utils.
@jadrake75 if you can expand that into a set of rules, it would help a lot - at that point we can talk about a complete ruleset and set up boundaries.
from date-utils.
I would love chainable ruby/rails like dates (I know this is js, but bare with me). I would love to be able to code:
7.days().from_now()
14.minutes().ago()
I realize that we're not going to extend the Number object, but something like.
Date.integer(7).days().from_now().at_beginning_of_day() // hh:mm:ss.ms / 00:00:00.000
Date.integer(7).days().from_now().at_end_of_day() // hh:mm:ss.ms / 23:59:99.999
Date.i(14).minutes.ago()
Date.i(15).days().since(Date.i(1).week().ago())
Date.between(new Date("1/1/2014"), new Date("12/11/2014")).days()
would be amazing!
from date-utils.
I would like to see a static method added as a proxy to calling the constructor. This would ease testing by providing a method that can be easily mocked. Perhaps... Date.now()
? We already have Date.today()
so this would be very similar.
I may be missing something with testing as I'm just getting started, however I can't figure out how to mock a constructor using Jest.
In fact I think I will fork and add this. Would you consider a pull request to add it?
from date-utils.
i'm curious what this would add, since it would be a synonym to new Date()
.
as an aside, Date.now()
is already taken :)
from date-utils.
It is indeed. I've given it some more thought and I don't think it would help me with testing anyway since date-utils extends the global Date object. As far as I know Jest doesn't have a way to mock objects/methods unless they can be loaded with require(). Sorry for the spurious suggestion.
The library is very nice, thank you for providing it.
from date-utils.
to(UTC)Format
's formatting patterns could be more like what other languages use for specifying date formats; the current patterns are a tad surprising at times (like having HH24
for 24h padded time, but HH
for 12h padded, and no way of having unpadded 24h hours). Java's patterns are, surprisingly enough, easy to use and follow. With patterns akin to Java's, the more letters you have in the pattern the longer the output you get (either more padding or abbreviated/long forms of words), and patterns use both lower and upper case.
Some examples:
- the full name of a month could be
MMMM
, the abbreviated month name could beMMM
, zero-padded month could beMM
, and single or double digit month could beM
- 24h hours could use
H
(withHH
for zero-padded) - 12h hours could use
h
/hh
- minutes could be
m
/mm
instead of just the paddedMI
etc.
from date-utils.
An ordinal suffix for the day of month, like 2nd, 6th, etc would be incredibly useful. Like the S
flag in PHP's date format function.
from date-utils.
Related Issues (20)
- How do you feel about... ? HOT 1
- subtract instance methods HOT 10
- d.getMonthsBetween(date); HOT 28
- Add `remove` to README
- error in the parsing of the weekday HOT 1
- getDaysBetween returns wrong number HOT 3
- No bower versions HOT 3
- How to set one special Date() object? HOT 1
- Browser support? HOT 2
- Number of Days between HOT 3
- site.flatly.css contains a broken import according to cssmin
- Property 'jui' redefine problem HOT 1
- Official typescript typings HOT 3
- getMonthsBetween inconsitency HOT 7
- Method getMonthAbbrNameFromNumber doesn't exists
- SCRIPT1046: Multiple definitions of a property not allowed in strict mode
- Cannot find module 'date-utils' HOT 2
- Function add/addMonths compute error HOT 3
- on node v10,Do I still need this polyfill ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from date-utils.