We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Looks great. Everything is almost here only easter is missing.
Easter can be a little tricky. Here is a simple example in C.
/* Source: https://www.rmg.co.uk/stories/topics/when-easter */ #include <stdio.h> void easter(int y, int *m, int *d) { *d = 225 - 11 * (y % 19); while (*d > 50) *d -= 30; if (*d > 48) --*d; *d = *d + 7 - (y + y/4 + *d + 1) % 7; if (*d > 31) { *m = 4; *d -= 31; } else { *m = 3; } return 0; } int main( void ) { int year, day, month; for (year=1998; year<2100; year++) { // algorithm does not work after 2099 easter(year,&month,&day); printf("%d-%02d-%02d\n", year, month, day); } return 0; }
The text was updated successfully, but these errors were encountered:
Interesting fact. Didnt know calculating a date would be this hectic of a task.
Sorry, something went wrong.
It seems to be difficult to calculate the easter day, but it is really easy to specify the day with special.days and highlight it
special.days
If you need to know if a year is a leap year or not you can use a simple script:
leap <- function(year){ start <- as.Date(paste0(year,"-01-01")) end <- as.Date(paste0(year,"-12-31")) ndays <- length(seq(start, end, by="1 day")) return(ndays) } leap(2011)
@R-CoderDotCom:
Is there any case I am missing where this is better than the simple arithmetic solution?
leap <- function(year) { year <- as.integer(year) leap_every <- 4L leap_skip <- 100L leap_skip_skip <- leave_every * leap_skip_skip !(year %% leap_every) && (year %% leap_skip || !(year %% leap_skip_skip)) }
No branches or pull requests
Looks great. Everything is almost here only easter is missing.
Easter can be a little tricky. Here is a simple example in C.
The text was updated successfully, but these errors were encountered: