OverviewExamples
current_date_sortable = System.GetDate(2); -- ISO date format sorts nicely
Get's the current date in ISO format (YYYY-MM-DD) and stores it in the variable "current_date_sortable."
days_since_Jan_15_2003 = System.GetDate(3)-2452655; -- 2452655 is the Julian date for Jan 15, 2003
Subtracts the Julian date for Jan 15, 2003 from the current Julian date and stores the result in the variable "days_since_Jan_15_2003". The Julian date format is perfect for date comparisons.
nWeekday = System.GetDate(7);
Returns the current day of the week (1-7) in the variable "nWeekday."
-- Specify the length of the trial period, in days
time_limit = 30;
-- Initialize days_left
days_left = 0;
-- Retrieve previous value stored
date_installed = Application.LoadValue("My Application", "Date Installed");-- Convert loaded value into a number
date_installed = String.ToNumber(date_installed);
-- If there is no previous value (date_installed == 0), create a value
if date_installed == 0 then
Application.SaveValue("My Application", "Date Installed", System.GetDate(DATE_FMT_JULIAN));
days_left = time_limit;
else
days_left = (date_installed + time_limit) - System.GetDate(DATE_FMT_JULIAN);
end
-- Check if there is time left
if String.ToNumber(days_left) < 1 then
Dialog.Message("Trial Period Over", "This software has expired");
Application.Exit();
else
Dialog.Message("Trial Period", "You have "..days_left.." days left in your trial period.");
end
Notifies the user after thirty days that the installation has expired and exits.
See also: Related Actions