Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how convert OFFSET to TIMEZONE ?

Former Member
0 Likes
2,867

Hello all,

Just want to ask a TimeZone question.

Already found a FM "TZON_GET_OFFSET", which convert a Timezone to OFFSET.

But vice versa i don't have any idea .

who can tell me, how convert a OFFSET to TIMEZONE?

Thx in advance!

best regards

Yaning

hello ,

Thanks for your antwort!

but i mean that, Given: OFFSET '0200' or '0545' ..

Result:TimeZone e.g 'CET' or 'NEPAL'

are there so FM, which convert OFFSET to TIMEZONE?

regards

Yaning

4 REPLIES 4
Read only

Former Member
1,692

can u check this which is written in method GET_LOCAL_TIMEZONE of class CL_BCOM_MIME_MESSAGE_SMTP

CALL FUNCTION 'TZON_GET_OFFSET'
    EXPORTING
      if_timezone   = l_tzone
      if_local_date = me->date
      if_local_time = me->time
    IMPORTING
      ef_utcdiff    = l_utcdiff
      ef_utcsign    = l_utcsign.

* determine hours and minutes
  l_tzone_hours   = l_utcdiff(2).
  l_tzone_minutes = l_utcdiff+2(2).

* determine comment
  CONCATENATE '(' sy-zonlo ')' INTO l_tzone_comment_s.

* concatenate timezone string
  CONCATENATE l_utcsign l_tzone_hours l_tzone_minutes
         INTO timezone_string.

  timezone = timezone_string.

  CONCATENATE timezone_string l_tzone_comment_s
         INTO timezone_string SEPARATED BY space.

Read only

0 Likes
1,692

hello ,

Thanks for your antwort!

but i mean that, Given: OFFSET '0200' or '0545' ..

Result:TimeZone e.g 'CET' or 'NEPAL'

are there so FM, which convert OFFSET to TIMEZONE?

regards

Yaning

Read only

0 Likes
1,692

Hello ,

for normal Timezone this is easy.

e.g '0200'--->'UTC2'

but for '+0545' the Timezone is special 'NEPAL'.

therefore i meet the Problem, how convert the '+0545' to right TIMEZONE 'NEPAL'?

I wanna find a FM, or a special method.

wer can help me!

Thx

regards

Yaning

Read only

Former Member
0 Likes
1,692

Hi,

The belowsaid example would help you,


The best way to measure the runtime of a specific program segment is to calculate the difference between the relative runtimes before and after the segment.



DATA: T1 TYPE I, 
T2 TYPE I,
T TYPE P DECIMALS 2, 
N TYPE I VALUE 1000.

T = 0.
DO N TIMES.
  GET RUN TIME FIELD T1.

*****************************
* Code to be tested *
*****************************

  GET RUN TIME FIELD T2.
  T2 = T2 - T1.
  T = T + T2 / N.
ENDDO.

WRITE: / 'Mean Runtime: ', T, 'microseconds'.

This example shows a DO loop that is constructed around a program segment to be tested. In this example, the program segment is just a comment. The difference of the relative runtimes after (T2) and before (T1) the program segment is measured N times. The mean value (T) is calculated from the results. The output might look as follows:

Mean Runtime:            23,40 microseconds

The output shows the offset time that results from the runtime measurement itself. This offset must be subtracted from the runtime of a real program segment.

If you replace the comment block in the program with the simple assignment

T = T.

the result might be:

Mean Runtime:            28,84 microseconds

This shows that the runtime of a simple assignment (without type conversion) is about 5 microseconds. If you assign T to a field of type C, the runtime is increased by a factor of about four due to the type conversion.

<b><i>Reward if helpful.</i></b>

Regards