View Single Post
Old 12-05-2012, 07:51 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,102
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
In vanilla Javascript,

Code:
<script type = "text/javascript">

var days = 2.03;  // 2 hours = .0833333 days
var d = parseInt(days)
var fraction = days - d;
if (fraction < .08333333) {
days --;
}
d = Math.ceil(days);
alert ("Charge is for " + d + " days");

</script>
"If you can't explain it simply, you don't understand it well enough”
“Everything should be as simple as it is, but not simpler.”
- both quotes Albert Einstein (German born American Physicist who developed the special and general theories of relativity. Nobel Prize for Physics in 1921. 1879-1955)
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is online now   Reply With Quote