![]() ![]() ![]() Please feel free to steal what you need from it. The DST calculator is in the printClock function. Mainly I just want to see if there is some flaw in my logic here. GENODIVE calculates different diversity indices such as the number of genotypes, the effective number of genotypes, Neis (1987) diversity index (identical Simpsons diversity index), the corresponding evenness, and the, corrected, Shannon-Wiener diversity index. But, at my current skill level, a bunch of nested if statements is all I could come up with to try to test the date to see if it's within the DST time of the year or not. I'm sure there is a much cleaner way to do this, and I'm probably this code will probably hurt most peoples' eyes. Then, it kind of does the inverse if the month is November to determine if the day is within the range that might be the first Sunday in November, and if the day is indeed Sunday, and if the hour is greater than 1, meaning DST should go back to 0. (Actually, I guess one of those must be Sunday, so I could probably get rid of the last else.) If both of those are the case, it sets DST to 1. If the day is between those two, then it runs through if statements for each day and checks if the day of the week is Sunday and if the hour is greater than 1. If it's less than 8, meaning the second Sunday couldn't have happened yet, DST is 0. If the day is greater than 14, meaning the second Sunday must have already passed, DST is 1. Then I check to see if the month is March. Does this look right? First, I'm saying if the month is anywhere between March and November, DST should be 1. I wrote this code that I think would properly return a 0 or a 1 to indicate if DST is in effect at the currently set time. (Starts second Sunday in March at 2AM and ends first Sunday in November at 2AM.) I'm trying to write a piece of code to look at the current time set using the Time.h library, and determine whether or not this point in time is a point of time where daylight savings time is in effect.įor this, I'm not getting fancy with multiple states or countries, I'm just looking at US daylight savings time, in the areas that observe it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |