Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

NLSFormatTime

NLS Function: Returns a correctly formatted string containing the time for the current locale. This routine is only available for Windows.

Module

USE IFNLS

result = NLSFormatTime (outstr [, intime] [, flags])

outstr

(Output) Character*(*). Is a string containing the correctly formatted time for the current locale. If outstr is longer than the formatted time, it is blank-padded.

intime

(Input; optional) INTEGER(4). If specified, the time to be formatted for the current locale. Must be an integer time such as the packed time created with PACKTIMEQQ. If you omit intime, the current system time is formatted and returned in outstr.

flags

(Input; optional) INTEGER(4). If specified, modifies the time conversion. If you omit flags, the flag NLS$Normal is used. Available values (defined in IFNLS.F90) are:

  • NLS$Normal - No special formatting

  • NLS$NoUserOverride - Do not use user overrides

  • NLS$NoMinutesOrSeconds - Do not return minutes or seconds

  • NLS$NoSeconds - Do not return seconds

  • NLS$NoTimeMarker - Do not add a time marker string

  • NLS$Force24HourFormat - Return string in 24 hour format

Results

The result type is INTEGER(4). The result is the number of characters written to outstr (bytes are counted, not multibyte characters).

If an error occurs, the result is one of the following negative values:

  • NLS$ErrorInsufficentBuffer - outstr buffer is too small

  • NLS$ErrorInvalidFlags - flags has an illegal value

  • NLS$ErrorInvalidInput - intime has an illegal value

Example

 USE IFNLS
 INTEGER(4) i
 CHARACTER(20) str
 i = NLSFORMATTIME(str, FLAGS=NLS$NORMAL)              ! 11:38:28 PM
 i = NLSFORMATTIME(str, FLAGS=NLS$NOMINUTESORSECONDS)  ! 11 PM
 i = NLSFORMATTIME(str, FLAGS=NLS$NOTIMEMARKER)        ! 11:38:28 PM
 i = NLSFORMATTIME(str, FLAGS=IOR(NLS$FORCE24HOURFORMAT,               &
 &                      NLS$NOSECONDS))          ! 23:38 PM
 END