SetAsString Method (DATETIME)


10.3A, PLBCMP GUI Only

 

The SetAsString method sets the value of a DATETIME object from a time/date string. The method uses the following format:

 

[label]

{object}.SetAsString

[GIVING {return}] USING [*Value=]{value}[:

 

 

[*Format=]{format}][,[*LocalTime=]{localtime}]

 

Where:

label

Optional. A Program Execution Label.

object

Required. A DATETIME object that has previously been declared.

return

Optional. A Numeric Variable that returns an error value if this method fails.

value

Required. A Character String Variable or string literal that specifies the time and date values.

format

Optional. A Character String Variable or string literal that specifies the format of the returned string.

localtime

Optional. A Numeric Variable or decimal number that specifies if the DATETIME value should be set to local time or UTC.

Flags Affected: EOS, OVER, ZERO

Note the following:

  1. If the {format} string is not given the value can be given as YYYY-MM-DD HH:MM:SS.FFF, YYYY-MM-DD HH:MM:SS, YYYY-MM-DD HH:MM, YYYY-MM-DD, HH:MM:SS.FFF, HH:MM:SS, HH:MM, the keyword now, or a numeric value. If the number is based off of Linux Time, an Adjust method using the Linux Epoch adjustment must be performed after the SetAsString.

  2. If the {format} string is given, the value string is processed using the provided format. The {format} string supports the following conversions:
     

  3. Format

    Description

    %d

    Day of month

    %m

    month (01 - 12)

    %y

    two digit year (00 -99) > 60 make 1960

    %Y

    four digit year (0000 - 9999)

    %f

    ** fractional seconds (SS.SSS)

    %H

    hour (00 -24)

    %M

    minute (00 - 59)

    %S

    seconds (00 - 59)

    %s

    seconds since 1970-01-01

    %P

    microseconds (000000 - 999999)

    %Z

    UTC

    %J

    ** julian day number

    %%

    %

     

  4. If the {localtime} is set to one (1), the DATETIME value is expressed as local time. If the {localtime} is set to 0, the DATETIME value is expressed as UTC. If the {localtime} is not given, the DATETIME value is expressed as it was stored.

  5. The ZERO flag is set when the return value is zero indicating success. When ZERO flag is cleared, a non-zero value indicates an error has occurred and the error values are found in the DATETIME object notes.

  6. The OVER flag is set if the {return} variable is too small to store that value without being truncated.

  7. The EOS flag is always cleared.

 

 

See Also: Method Syntax, DATETIME Methods

 



PL/B Language Reference GetAsSring Method (DATETIME) SetToDateTime Method (DATETIME)