4.13.37 Calculating dates and times
Function
This plug-in adds or subtracts the specified time from the specified date/time. The calculated date/time is stored as the calculation result (common.calculateResult property) in the specified format.
This plug-in requires the following server:
- Execution-target server
The server on which this plug-in is to be executed.
The script of this plug-in performs the following processes:
(1) If the execution-target server uses Windows, execute the following commandlets:
- Obtain the object that has the specified date/time.
$Key = Get-Date "input-date/time-(common.inputDateAndTime property)-value"
- Add or subtract the specified time from the object you obtained in the previous step.
Get-Date -Date ($Key).method-name.Invoke("calculated-date/time-(common.calculateDateAndTime property)-value")
-UFormat "format-(common.dateAndTimeFormat property)-value"
The method name used in the commandlet shown earlier differs depending on the calculated unit (common.calculateUnit property) value.
For details about the Get-Date commandlet, see the relevant parts of the Microsoft library.
(2) If the execution-target server is UNIX, the following command is executed:
date -d "input-date/time-(common.inputDateAndTime property)-value
calculated-date/time-(common.calculateDateAndTime property)-numerical-value
calculated-unit-(common.calculateUnit property)-value
[ago]#1
"
"+format-(common.dateAndTimeFormat property)-value"
#1: Specify this when setting a negative number for the calculated date/time (common.calculateDateAndTime property).
For details about the date command, see the command information obtainable by using the OS "man" command.
Specify the input date/time (common.inputDateAndTime property) in "YYYY-MM-DD hh:mm:ss" format.
The format (common.dateAndTimeFormat property) is as follows:
- Specify a string within 64 characters.
- Any characters specified for conversion found in the string are converted to their corresponding values. Characters other than those specified for conversion are stored in the calculation result (common.calculateResult property) without being converted.
Examples of characters specified for conversion are shown below. For information on other characters specified for conversion, see the commandlets and command manuals shown earlier.
[Characters specified for conversion]
%Y A four-digit Western-calendar year, including the millennium and century.
%y Last two digits of the year. The year excluding the millennium and century. If this is in the single digits, prepend it with a 0.
%m Months. If the month is in the single digits, prepend it with a 0.
%d Days. If the day is in the single digits, prepend it with a 0.
%H Hours in 24-hour notation. If the hours are in the single digits, prepend them with a 0.
%I Hours in 12-hour notation. If the hours are in the single digits, prepend them with a 0.
%M Minutes. If the minutes are in the single digits, prepend them with a 0.
%S Seconds. If the seconds are in the single digits, prepend them with a 0.
%s Number of seconds elapsed since 1970-01-01 00:00:00 UTC.
Use situation
When creating a file or directory, you can use this when you want to use a calculated date/time as an identifier for the file name or directory name.
Prerequisites
For the most recent information about the prerequisite products for the system, prerequisite products for the execution-target server, and the supported OSs for the execution-target server, see the release notes.
[Prerequisite products for the system]
JP1/Automatic Operation 11-00 or later
[Prerequisite products for the execution-target server]
None.
[Supported OSs for the execution-target server]
(1) Windows Server 2008 R2 Standard/Enterprise/Datacenter
(2) Windows Server 2012 Standard/Datacenter, Windows Server 2012 R2 Standard/Datacenter
(3) Windows Server 2016 Standard/Datacenter
(4) Windows Server 2019 Standard/Datacenter
(5) Red Hat Enterprise Linux Server 6 (32-bit x86), Red Hat Enterprise Linux Server 6 (64-bit x86_64)
(6) Red Hat Enterprise Linux Server 7 (64-bit x86_64)
(7) Red Hat Enterprise Linux Server 8 (64-bit x86_64)
(8) CentOS 6 (64-bit x86_64)
(9) CentOS 7 (64-bit x86_64)
(10) CentOS 8 (64-bit x86_64)
(11) Oracle Linux 8 (64-bit x86_64)
[Conditions for using the execution-target server]
None.
Cautions
(1) Do not specify character strings containing double quotation marks (") or single quotation marks (') for properties of this plug-in.
(2) The command specification differs between Windows and UNIX, so even if you specify the same value for a calculated date/time (common.calculateDateAndTime property), the calculated result (common.calculateResult property) might differ depending on the OS of the execution-target server.
Version
02.10.00
Plug-in tags
Gather OS information,Linux,Windows
Plug-in name displayed in the task log
osCalculateDateAndTime
Return code
0: Normal
27: Error (Check the details on the error in the task log.)
41: Error (An error was detected in the component.): A property was not entered. (An error was detected in the component script.)
Property list
The following table lists the properties:
Property key |
Property name |
Description |
Default value |
I/O type |
Required |
---|---|---|---|---|---|
plugin.destinationHost |
Host name of the execution target server |
Specify the host name or IP address of the server on which this plugin will be executed. IPv6 addresses are not supported. |
-- |
Input |
R |
common.inputDateAndTime |
Input date and time |
Specify the date and time that is the calculation source as YYYY-MM-DD hh:mm:ss. |
-- |
Input |
R |
common.calculateUnit |
Calculation unit |
Specify the unit of time you want to add or subtract from the input date/time. Specify one of the following: "years", "months", "days", "hours", "minutes", or "seconds". |
-- |
Input |
R |
common.calculateDateAndTime |
Calculation date and time |
Specify the time you want to add or subtract from the input date/time, in halfwidth numerical values. To subtract, prepend the value with a minus sign (-). |
-- |
Input |
R |
common.dateAndTimeFormat |
Format |
Specify the format in which to output the date/time after calculation. |
%Y%m%d%H%M%S |
Input |
R |
common.calculateResult |
Calculation result |
The date and time after calculating is stored here in the specified format. |
-- |
Output |
O |
common.returnValue |
Return value for the plugin |
The return value of this plugin stored. |
-- |
Output |
O |