Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Some calculations with Time.now.to_i, i.e. calculating the difference between 2 timestamps
KurtiAustria
post Aug 5 2008, 12:53 AM
Post #1


Level 1
Group Icon

Group: Member
Posts: 11
Type: Event Designer
RM Skill: Beginner




hy, again!

I've got 2 Time stamps made with Time.now.to_i and saved into $game_variables[5] and $game_variables[6].
So how can i calculate the difference in days between 5 and 6?
how can i round from 0.1 to 1?

I tried to solve it that way but it returns me a syntax error
CODE
class ZeitFunktionen
  def calculate_days(timestamp_start, timestamp_end)
    difference = timestamp_end - timestamp_start
    minutes = difference/60
    hours = minutes/60
    days = hours/24
    return days
  end
end


That's how I call the Script
CODE
var = ZeitFunktionen.new
$game_variables[45] = var.calculate_days
($game_variables[44], Time.now.to_i)


thx, Kurti

since i didn't receive any answer for days, i had to search for answers elsewhere. and i found answers. i had to use 60.0 to make it a float.
if anyone's interested in this script, simply ask.

This post has been edited by KurtiAustria: Aug 8 2008, 12:29 AM
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 11:20 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker