Welcome Guest.   Make a donation to an author on the site July 28, 2014, 05:35:53 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2010! Download 24 custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: DONE - IDEA: commandline/console program to calculate sunrise/sunset times  (Read 16678 times)
LuckMan212
Charter Member
***
Posts: 137


View Profile Give some DonationCredits to this forum member
« on: November 03, 2005, 10:41:37 PM »

There are some handy utils for un*x systems that can do the task of calculating sunrise/sunset/civil twilight/etc times given a latitude and longitude input.  Unfortunately I was not able to locate any win32 console apps that can do this reliably.   I found one written by an author who is no longer reachable and his contains a daylight-savings bug (DST calculation doesn't seem to work).  Daylight savings is a very important and tricky factor.

The reason I would like to have such a program is to use it in batch files to schedule home automation tasks such as turning out outside lights, controlling thermostat settings etc, based on sunrise/sunset/twilight times which change each day.

As a starting point you might consider the following URLs for assistance with the algorithms:

http://www.codeproject.com/datetime/srss.asp

http://www.freevbcode.com/ShowCode.asp?ID=341

http://xoomer.virgilio.it...riset/formulas/index.html

there are others but that is a start...

will anyone be so kind as to create this program?? Wink  all it needs to do is output the time in 24hour hh:mm format, no fancy GUI is needed (at least for me!).  It would be good if it can accept some commandline arguments such as specifying a date manually (default would be todays date) and also the ability to output only the time you need for example just the SUNRISE time.

example:

>suntime.exe 40.734N 73.986W -time sunrise
05:39

>suntime.exe 40.734N 73.986W -time sunset
17:33

>suntime.exe 40.734N 73.986W -time twilight
16:55


etc etc...
 Thmbsup
« Last Edit: November 21, 2005, 01:04:21 AM by mouser » Logged
jazper
Coding Snacks Author
Charter Honorary Member
***
Posts: 92



View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: November 04, 2005, 12:26:27 AM »

Give this a try:


SYNTAX: suntime.exe <latitude> <longitude> -time <sunrise|sunset|moonset|moonrise|twilight>


http://www.zaboo.net/kdunlap/suntime.zip


jazper
Logged
mouser
First Author
Administrator
*****
Posts: 33,183



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: November 04, 2005, 12:30:17 AM »

jazper - care to give us some info on the programmer of the util - is it you?
Logged
jazper
Coding Snacks Author
Charter Honorary Member
***
Posts: 92



View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: November 04, 2005, 02:03:13 AM »

Sorry, I wrote the app.

And I updated it as well,.

Changed:
  - Latitude needs suffix N or S for North and South
  - Longitude needs suffix E or W for East and West
  - Output time is based on local time


SYNTAX: suntime.exe <latitude[N|S]> <longitude[E|W]> -time <sunrise|sunset|moonset|moonrise|twilight>

http://www.zaboo.net/kdunlap/suntime.zip



jazper
« Last Edit: November 04, 2005, 02:07:08 AM by jazper » Logged
mouser
First Author
Administrator
*****
Posts: 33,183



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: November 04, 2005, 02:10:27 AM »

wow - wonderful!  Thmbsup

ps.
if you're interested in setting up a little icon under your name where people can make a donation to support your coding (don't expect much if anything but still it's the principle and we want to encourage people to donate to coders), there's a link to some instructions here: http://www.donationcoder....um/index.php?topic=1283.0
Logged
LuckMan212
Charter Member
***
Posts: 137


View Profile Give some DonationCredits to this forum member
« Reply #5 on: November 05, 2005, 09:15:56 AM »

jazper- this is fantastic! I really appreciate you creating this program!! may I ask is it possible to make a few small changes?

1) the extra :00 (seconds) at the end seems to always be "00" at least in my testing.  Can this simply be dropped?  I do not need seconds calculated, minute resolution is enough. 

2) can the time be output in 24-hour (military) notation? so instead of 5:29PM can it just output 17:29 ?  If you prefer the 12hour notation then maybe add a switch like -24h or something to allow the user to choose which format to output.

3) is it possible to allow the program to calculate the sunrise/sunset times of any arbitrary date, not just Today's date?  example:
-suntime 40.73N 73.98W -time sunrise -date 10/30/05

also, is the program compensating for daylight savings? if yes, how does it know this? (does it read time zone from current user?)
sorry for all the questions thanks again!!! cheesy
Logged
jazper
Coding Snacks Author
Charter Honorary Member
***
Posts: 92



View Profile WWW Give some DonationCredits to this forum member
« Reply #6 on: November 16, 2005, 09:35:32 AM »

LuckMan212,
  As requested here is a new version...

[copy or print]
SYNTAX: suntime.exe <latitude[N|S]> <longitude[E|W]> -time <sunrise|sunset|moonset|moonrise|twilight> [-24hr] [-date MM/DD/YYYY]


ADDED: Removed trailings seconds
ADDED: -date switch
ADDED: -24hr switch, if it exists, then output in 24hr time.

Download it here


jazper
Logged
LuckMan212
Charter Member
***
Posts: 137


View Profile Give some DonationCredits to this forum member
« Reply #7 on: November 18, 2005, 11:48:34 PM »

jazper-

thank you so much, this program is now almost 100% perfect!! Thmbsup
only problem is now Daylight Savings Time.
I unfortunately live in New York which is one place that observe the daylight savings time.
Which sets clock back 1hr on Last Sunday in October and then sets clock forward 1hr on First Sunday in April.
Would it be possible to add a "-dst" switch to compensate for this factor if dates are falling between this range?

you can see the effect of this by looking at the following link, for example:
(just look what happens between October 29 and Oct 30...)
http://tinyurl.com/dwyvc


thank you so much!!
Logged
jazper
Coding Snacks Author
Charter Honorary Member
***
Posts: 92



View Profile WWW Give some DonationCredits to this forum member
« Reply #8 on: November 20, 2005, 11:47:48 AM »

[copy or print]
ADDED: -dst switch, will compensate the output time for DST
   if -date is DST and currentdate is not, then +1 output
   else if -date is not DST and currentdate is DST then -1 output

FIXED: All cmd line switches are detected regardless of case(e.g. -date or -DATE)


Latest version HERE
Logged
LuckMan212
Charter Member
***
Posts: 137


View Profile Give some DonationCredits to this forum member
« Reply #9 on: November 20, 2005, 03:35:08 PM »

wonderful!!  cheesy  Thmbsup
this is exactly what I needed, thank you so much!
now tell me how I can donate some $ for your efforts
Logged
jazper
Coding Snacks Author
Charter Honorary Member
***
Posts: 92



View Profile WWW Give some DonationCredits to this forum member
« Reply #10 on: November 20, 2005, 07:09:58 PM »

LuckMan212,
  Although donations personally are greatly appreciated, please put any donation that you were willing to give towards the November Fundraiser


Thanks!

jazper
Logged
jazper
Coding Snacks Author
Charter Honorary Member
***
Posts: 92



View Profile WWW Give some DonationCredits to this forum member
« Reply #11 on: November 21, 2005, 12:48:09 AM »

If you feel I've fulfilled your request, you may want to change the post icon to a smiley smiley and the topic to DONE - <original topic>
Logged
mouser
First Author
Administrator
*****
Posts: 33,183



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #12 on: November 21, 2005, 01:03:28 AM »

i'll change the topic and icon smiley
Logged
LuckMan212
Charter Member
***
Posts: 137


View Profile Give some DonationCredits to this forum member
« Reply #13 on: November 21, 2005, 07:24:04 PM »

ok well thanks a lot, I have just made a donation to the November fundraiser cheesy, but I would still like to make a small personal donation to you jazper, just email me your paypal ID to luke.hamburg (at) gmail.com
cheers buddy Thmbsup

edit: and thanks mouser for updating the topic title and smiley! Wink
« Last Edit: November 21, 2005, 09:46:05 PM by LuckMan212 » Logged
jazper
Coding Snacks Author
Charter Honorary Member
***
Posts: 92



View Profile WWW Give some DonationCredits to this forum member
« Reply #14 on: November 22, 2005, 01:50:58 AM »

LuckMan212,
   Here is a link to my donation info, again only donate if you want to.



jazper
Logged
LuckMan212
Charter Member
***
Posts: 137


View Profile Give some DonationCredits to this forum member
« Reply #15 on: November 22, 2005, 11:18:26 AM »

thanks, I just sent it  cheesy
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.039s | Server load: 0.07 ]