New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding previousDay and its variations #2522
adding previousDay and its variations #2522
Conversation
7fde6ae
to
b85fae6
Compare
7ef7d9b
to
506e78f
Compare
Hi @LucasHFS
if you prefer to run tests locally you can do Many thanks! |
Minor stuff, but you have a little typo in your tests (previours instead of previous). Could I also propose a simpler and faster (by about 50%) implementation for export default function previousDay(dirtyDate: Date | number, day: Day): Date {
requiredArgs(2, arguments)
const date = toDate(dirtyDate)
let delta = getDay(date) - day
if (delta <= 0) delta += 7
return subDays(date, delta)
} |
Sure, tomorrow I'll work on this. |
e10c1a8
to
8de1be7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your contribution! 🚀
Just had a look again at this PR and I think there's no need to convert the date argument using ex: export default function previousThursday(date: Date | number): Date {
requiredArgs(1, arguments)
return previousDay(toDate(date), 4)
} could simply be: export default function previousThursday(date: Date | number): Date {
requiredArgs(1, arguments)
return previousDay(date, 4)
} |
@fturmel this totally makes sense! Thank you! |
Added new functions: `previousDay`, `previousMonday`, `previousTuesday`, `previousWednesday`, `previousThursday`, `previousFriday`, `previousSaturday` and `previousSunday`. Co-authored-by: Lucas Silva <lucas.silva@codeminer42.com> Co-authored-by: Tetiana <ttobin@protonmail.ch> Co-authored-by: Sasha Koss <koss@nocorp.me>
[WIP] Implements #2507 request, and similar functions.