DEV Community

Peter + AI
Peter + AI

Posted on

A Quick Guide to Uniface's `lineartime` Data Type ⏱️

Hey dev community! 👋

Today, let's dive into a specific feature of the low-code development platform Uniface: the lineartime data type. It might seem like a small detail, but understanding the right tool for the job is key to efficient coding. So, what is it and when should you use it?

What Exactly is lineartime\?

In simple terms, lineartime is a Uniface data type designed to hold a duration of time as a whole number of hours. Think of it as a simple hour counter. 🔢

It's an integer that can hold a value from 0 to 24. You can use it to define variables or parameters when you only need to track the number of hours that have passed, without needing the extra detail of minutes or seconds.

How to Use It: An Example 💻

You'll typically declare a lineartime variable in the params or variables block of your ProcScript code. The real power comes when you're calculating elapsed time.

Let's look at an example straight from the documentation:

 params time pTimeStamp : IN lineartime pElapsedTime : OUT endparams pElapsedTime = $clock - pTimeStamp 
Enter fullscreen mode Exit fullscreen mode

Breaking Down the Code:

  • params...endparams: This block defines the input and output parameters for an operation or component.
  • time pTimeStamp : IN: This is our input. It's a standard time data type, which holds a specific time of day (e.g., 14:30:15).
  • lineartime pElapsedTime : OUT: This is our output. This is where the calculated result—the elapsed hours—will be stored.
  • pElapsedTime = $clock - pTimeStamp: This is where the magic happens! $clock gives you the current system time. Uniface calculates the difference between the current time and the input pTimeStamp and cleverly stores the result as a whole number of hours in our pElapsedTime variable.

When Should You NOT Use lineartime\? 🤔

This one is simple: if you need more precision, lineartime is not the right choice! 😅

If your application needs to track minutes, seconds, or even milliseconds, you should use a more detailed data type like lineardatetime instead. The lineartime data type will simply truncate any value smaller than a full hour.

Conclusion

The lineartime data type in Uniface is a niche but useful tool for calculating and storing time durations in whole hours. It's perfect for simple time-tracking where precision isn't a concern.

Happy coding! ✨


P.S. This post was crafted with the help of an AI assistant to ensure clarity and accuracy, based on the official Uniface 10.4 documentation.

Top comments (0)