[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 64 KB, 640x480, 1332645992425.jpg [View same] [iqdb] [saucenao] [google]
4534056 No.4534056 [Reply] [Original]

Hello /sci/
Does anyone know a java algorithm to calculate the day of the year? The user specifies a date, eg. 29/02/2000, which would be the 60th day of the year. Or does anybody know of a formula which does the same?

>> No.4534067

/sci/ is safe for work, reported enjoy your ban

>> No.4534074

>>4534067
this nigga gay

>> No.4534075

It's 4chan. Be grateful she's not 12.
Just subtract 31 days for January, 28/29 days for February depending on if it's a leap year, and so on. Then when you get to the last month, add what day you're on.

>> No.4534079

>>4534067
LOL

>>4534075
thank you sir

>> No.4534087

>>4534067

I'm with this guy, fuck pussies

>> No.4534099

>>4534074
No he likes to stop cancer.

>> No.4534117

What I was trying to do earlier was make an algorithm that takes epoch time (seconds since Jan. 1, 1970) and prints out the date. How would someone do that?

>> No.4534120

just had to do this project. if you're allowed, java has a built in calendar class you can use that would make very easy.

here's how i did leap year

public void isLeapYear()
{
if (year % 100 == 0)
{
if (year % 400 == 0)
++daysInMonths[1];
}
else if (year % 4 == 0)
++daysInMonths[1];
}

>> No.4534125

>>4534075
you obviously haven't seen that pedo thread around here.

Reported op for not posting a 12 year old.

>> No.4534128
File: 137 KB, 401x487, sportsguy.jpg [View same] [iqdb] [saucenao] [google]
4534128

>>4534056

>The user specifies a date, eg. 29/02/2000
>There are at least 29 months in a year

>> No.4534130

here's the other important method i used:

public void setTotalDays()
{
int total = 0;
for (int i = month - 1 ; i > 0 ; i-- )
total += daysInMonths[i - 1];
total += day;
totalElapsed = total;
}

>> No.4534132
File: 349 KB, 1024x1536, 1314565095389.jpg [View same] [iqdb] [saucenao] [google]
4534132

>>4534067

Just for you

>> No.4534143
File: 231 KB, 1536x1020, pussy.jpg [View same] [iqdb] [saucenao] [google]
4534143

>>4534128
Most countries go day/month/year.
You know, the way that makes sense.

>> No.4534193

>>4534130
cheers bro

>> No.4534225

>>4534143
>>4534143
FUCK THAT"S DISGUSTING

>> No.4534233

>>4534225
Haha. I don't see anything wrong with it.
Explain yourself using scientific evidence.