Comments (2)
My purpose is to can test a function that use now.BeginingOf...
, not to use now inside a test.
For example we cannot add a test in this package for the function now.BeginningOfWeek()
. I mean it's an usual issue to test a function that use the current datetime...
from now.
It's difficult to test function in main like now.BeginingOf... because it use time.Now()
For testing purposes, one can just use the With
free function which returns an instance of Now
that has the same family of BeginningOf
functions.
now.With(time.Date(2021, 1, 1, 0, 0, 0, 0, time.Local)).BeginningOfWeek()
Having said that, the ability the override such stuff exists in many Golang libraries via conventional OverrideFooFunc
facilities, which seems like a good addition to this library but I do not see it bringing much of a value testing wise.
Cheers.
from now.
Related Issues (20)
- License
- Make FirstDayMonday a variable on now.Now struct or a parameter to BeginningOfWeek HOT 1
- Unable to parse time without day HOT 1
- Milliseconds are not parsed correctly
- Alternative API?
- Broken when clocks go back HOT 2
- WeekStartDay as an attribute of Now type HOT 2
- 可以考虑内置支持下这些格式吗?
- Cant find variable now HOT 1
- Parse day of the week
- please add mysql datetime layout HOT 1
- Beginning of Month error HOT 1
- Current quarter HOT 1
- don't allocate config inside With() HOT 1
- Serious error with format "2006-01-02T15:04:05Z" (also see #22) HOT 1
- How about add a maxTime and a minTime const
- How do get the previous month's time? HOT 1
- Recommend a better golang package for datetime
- Rename License to LICENSE HOT 1
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 now.