hongji.li
2023-11-07 1a1ba3ad5ed9e4380185aa1ccad20204a0e5f115
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Quintiq file version 2.0
#parent: #root
Method PTF_GetClientTimeZoneOffset () as String id:Method_LibPTF_pnlTestController_PTF_GetClientTimeZoneOffset
{
  #keys: '[131464.1.896601338]'
  Body:
  [*
    // convert date time to string (based on client timezone)
    timezoneOffsetLength             := 5;
    timezoneOffsetMask               := "Z";
    dateTimeFormatWithTimezoneOffset := "dd-MMM-yyyy HH:mm:ss" + timezoneOffsetMask;
    
    converter := DateTimeToString::UserConverter();
    converter.SetCustomConversion();
    converter.CustomFormatString( dateTimeFormatWithTimezoneOffset );
    
    // Any time will do, the purpose is to able to get the timezone offset, example: +0800
    nowAsStringWithTimezoneOffset := converter.Convert( DateTime::Now() );  
    
    
    strTimezoneOffset := nowAsStringWithTimezoneOffset.SubString( nowAsStringWithTimezoneOffset.Length() - timezoneOffsetLength, timezoneOffsetLength );
    return strTimezoneOffset;
  *]
}