Copy link to clipboard
Copied
What I'd like to do is create something like a thermometer. I'm not sure as to how many fields I would need. I'd like to have a field to enter a number like a temperature and what time. Then another field that would calculate how many points the temperature has gone up in 60 minutes. Something like a point per minute. But, then goes down depending on the conditions, so there should be another field for that to be calculated in. I'm kinda confused as to how to do this. Any thoughts or ideas or suggestions will be welcomed. I don't know even if it's possible. I have little knowledge as to how to or what I need to do to create something like this. If it can be done with javascript, please, let me know. Thanks, guys.
Field1 //enter the time, perhaps from the computer
Field2//enter the temp (or number) at that time
Field3//calculates the points temp has risen
Field4//calculates the points temp has fallen
Copy link to clipboard
Copied
This is very similar to a time sheet calculation for the time worked in a day. You have a start time and end time and you need to calculate the difference between the two events. Most time sheets calculate only the times that occur within a single day but you may encounter an event that occurs on a different day. You also, just like on a time sheet may have an interval that spans the period in which there is a change from Day Light Savings Time or Summer Time where there is a jump forward or backward of an hour. So your calculation will not be a simple subtraction of the start time from the end time. The number of minutes go from 00 to 59 and then the hour changes and the hours go from 00 to 23 and the day changes. Days are a whole set of other issues because of the varying number of days in a given month. Fortunately JavaScript assigns a unique value to each millisecond beginning at January 1, 1970 00:00:00.000, midnight. So there is a unique ascending number for each millisecond in JavaScript's date object. So your task is to convert a date and time string value into a JavaScript date object for the staring date and time and the ending date and time. When you take the difference in milliseconds between these two values you will have the number of milliseconds in the measured interval. It is a trivial computation to convert the number of milliseconds into minutes or hours.
Copy link to clipboard
Copied
Thanks for the reply. So, you think I can do what I'm talking about? I've read through your response and I must admit I don't know how to configure what I'm trying to do to what you're saying. I'm still too much a novice (but learning) in javascript and this will be the first time dealing with dates and times. I really don't understand how to calculate them. Would you have an example of what you're referring to? Something that I could play around with? I learn a lot by examples. Getting into them hands on.
Copy link to clipboard
Copied
Hi PDF User,
There are plenty of examples for you to learn the concepts of working with dates and times in the tutorials linked below. There are a lot of sample scripts there that you can see and learn a lot from.
https://acrobatusers.com/tutorials/date_time_part1
https://acrobatusers.com/tutorials/date_time_part2
https://acrobatusers.com/tutorials/working-date-and-time-acrobat-javascript-part-3-3
Hope this helps,
Dimitri
www.pdfscripting.com
Copy link to clipboard
Copied
The practicalPDF Date Library for Adobe Acrobat : http://practicalpdf.com/the-practicalpdf-date-library-for-adobe-acrobat/
Copy link to clipboard
Copied
I would start by figuring out how you will record the temperature differences. Once I resolved that, I would start to work on the time calculations.
I would create a start temperature and end temperature field with the numeric format and either 1 or no decimals. Then I would create a field to hold the temperature difference. This field's value can be calculated by either using the "Simplified Field Notation" or the "Custom JavaScript calculation" options.
The time calculations will require the "Custom JavaScript calculation" option since the "Simplified Field Notation" method can not perform the necessary conversions.