Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 8:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Date Calculations
PostPosted: February 1st, 2008, 11:15 am 
Offline

Joined: January 31st, 2008, 3:21 pm
Posts: 9
Good morning to all Opus lovers.

I have Opus Pro 05 and don't know the first thing about how to use script. Does anyone know how to do date calculations? I will be storing information in .txt file and will also be using the clickable calendar in my project. The <SYSTEM_DATE_FULL> variable format will be used. When I receive data from a .txt file, I would like to be able to calculate the current date on the system from a future date that has been recorded or (vice versa). I need the calculation to tell me how many days are left until the future date. I hope this all makes sense.

Many thanks


Top
 Profile  
 
 Post subject:
PostPosted: February 1st, 2008, 1:30 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Rykie,

You might need to learn fast :-)

I'm attatching an IMP with the DW calendar modified to display the difference in days between the system date and the date clicked. I've added a date difference script and edited DW's to display this value.

The script is:

Quote:
function dateDiff(now,next)
{
var date1 = new Date(now)
var date2 = new Date(next)
var diff = new Date()

diff.setTime(Math.abs(date1.getTime() - date2.getTime()))

var timediff = diff.getTime()

var days = Math.floor(timediff / (1000 * 60 * 60 * 24))
timediff -= days * (1000 * 60 * 60 * 24)

return days + " days"
}


This is a function (read the help) that allows you to pass two dates and returns the number of days.

Nothing like diving in head first...

Mack


You do not have the required permissions to view the files attached to this post.

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: February 1st, 2008, 3:45 pm 
Offline

Joined: January 31st, 2008, 3:21 pm
Posts: 9
Hi Mack

You are dam right about learning fast. Thanks for the script, I will have a look at it now in more detail as I have a fair understanding of what I need to do. I have a similar query with regards to time. Thank you
Rykie


Top
 Profile  
 
 Post subject:
PostPosted: February 1st, 2008, 4:50 pm 
Offline

Joined: January 31st, 2008, 3:21 pm
Posts: 9
Hi Mack

Thanks again. I had a look in more detail and understand what you have done, this could be handy for the future. But I'm not sure if this example will work in my case.

I would like you to take the calendar out of the equation for now.

I have a variable <SYSTEM_DATE_FULL> Read from the systems current time. I have another variable lets say <DUE_DATE> which is a date that has been stored in a .txt file. When I open the page or click a button I need the calculation to take place and store the answer in a separate variable <DAYS> on that page.

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: February 6th, 2008, 1:13 am 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
Hi Rykie,

Mackavi's script will do what you want---all you need to do is put that script into a script object in the page, then to actually use it, you call the function in a script action which could be attached to a button or an text input box. The script action would simply be

Code:
dateDiff(firstDate,nextDate)


where firstDate and nextDate are the two dates to 'compare'. You can compare dates either way. To check dates due, the first date would be today and the next date would be a date in the future.
To check dates past, the first date would be a date in the past and the next date would be today---or you can do it between any two random dates.

the dates have to be in this format to work ....06 February 2008.
You can do this without the calendar

Rgds

Sandy

_________________
Whoever designed this, never actually used it!


Top
 Profile  
 
 Post subject:
PostPosted: February 6th, 2008, 11:38 am 
Offline

Joined: January 31st, 2008, 3:21 pm
Posts: 9
Good morning Sandy,

Thank you for your reply, I will try and give it a go. If I don't come right, I hope you don't mind me sending you a private message.

Best wishes
Ryk Melck


Top
 Profile  
 
 Post subject:
PostPosted: February 6th, 2008, 2:15 pm 
Offline

Joined: January 31st, 2008, 3:21 pm
Posts: 9
Hi Sandy

My problem is understanding the script. I have tried to store the information into variables but could not seem to get it to work. I feel a little frustrated with my self.
I have attached an example on my other posting with regards to date calculations. Please download it from there and have a look. The more I get from others the more I will learn.

Thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group