@@ -2656,18 +2656,18 @@ public static DateTime CToD2(string value)
26562656 }
26572657 return nullDate ;
26582658 }
2659- internal static DateTime CToDT2 ( string jsonDate ) {
2659+ internal static DateTime CToDT2 ( string jsonDate , IGxContext context ) {
26602660
26612661 if ( ! string . IsNullOrEmpty ( jsonDate ) && ( jsonDate . Contains ( ISO_8601_TIME_SEPARATOR ) || jsonDate . Contains ( ISO_8601_TIME_SEPARATOR_1 ) ) )
26622662 {
2663- return CToT2 ( jsonDate ) ;
2663+ return CToT2 ( jsonDate , context ) ;
26642664 }
26652665 else
26662666 {
26672667 return CToD2 ( jsonDate ) ;
26682668 }
26692669 }
2670- public static DateTime CToT2 ( string value )
2670+ public static DateTime CToT2 ( string value , IGxContext context )
26712671 {
26722672 if ( isNullJsonDate ( value ) )
26732673 return nullDate ;
@@ -2684,38 +2684,76 @@ public static DateTime CToT2(string value)
26842684 }
26852685 }
26862686 if ( Preferences . useTimezoneFix ( ) )
2687- ret = fromUniversalTime ( ret ) ;
2687+ {
2688+ if ( context == null )
2689+ ret = fromUniversalTime ( ret ) ;
2690+ else
2691+ ret = fromUniversalTime ( ret , context ) ;
2692+ }
26882693 return ret ;
26892694 }
26902695 }
2696+ //[Obsolete("CToT2 is deprecated, use CToT2(string, IGxContext) instead", false)]
2697+ public static DateTime CToT2 ( string value )
2698+ {
2699+ return CToT2 ( value , null ) ;
2700+ }
2701+ //[Obsolete("TToC2 is deprecated, use TToC2(DateTime, IGxContext) instead", false)]
26912702 public static string TToC2 ( DateTime dt )
26922703 {
26932704 return TToC2 ( dt , true ) ;
26942705 }
2706+ public static string TToC2 ( DateTime dt , IGxContext context )
2707+ {
2708+ return TToC2 ( dt , true , context ) ;
2709+ }
2710+ //[Obsolete("TToC2 is deprecated, use TToC2(DateTime, bool, IGxContext) instead", false)]
26952711 public static string TToC2 ( DateTime dt , bool toUTC )
26962712 {
2697- return TToCRest ( dt , "0000-00-00T00:00:00" , JsonDateFormat , toUTC ) ;
2713+ return TToCRest ( dt , "0000-00-00T00:00:00" , JsonDateFormat , null , toUTC ) ;
2714+ }
2715+ internal static string TToC2 ( DateTime dt , bool toUTC , IGxContext context )
2716+ {
2717+ return TToCRest ( dt , "0000-00-00T00:00:00" , JsonDateFormat , context , toUTC ) ;
26982718 }
2719+ //[Obsolete("TToC3 is deprecated, use TToC3(DateTime, IGxContext) instead", false)]
26992720
27002721 public static string TToC3 ( DateTime dt )
27012722 {
27022723 return TToC3 ( dt , true ) ;
27032724 }
2725+ public static string TToC3 ( DateTime dt , IGxContext context )
2726+ {
2727+ return TToC3 ( dt , true , context ) ;
2728+ }
27042729 internal const string JsonDateFormatMillis = "yyyy-MM-ddTHH:mm:ss.fff" ;
27052730 internal const string JsonDateFormat = "yyyy-MM-ddTHH:mm:ss" ;
2706-
2731+
2732+ //[Obsolete("TToC3 is deprecated, use TToC3(DateTime, bool, IGxContext) instead", false)]
27072733 public static string TToC3 ( DateTime dt , bool toUTC )
27082734 {
2709- return TToCRest ( dt , "0000-00-00T00:00:00.000" , JsonDateFormatMillis , toUTC ) ;
2735+ return TToCRest ( dt , "0000-00-00T00:00:00.000" , JsonDateFormatMillis , null , toUTC ) ;
2736+ }
2737+ internal static string TToC3 ( DateTime dt , bool toUTC , IGxContext context )
2738+ {
2739+ return TToCRest ( dt , "0000-00-00T00:00:00.000" , JsonDateFormatMillis , context , toUTC ) ;
27102740 }
27112741
2712- static string TToCRest ( DateTime dt , String nullString , String formatStr , bool toUTC = true )
2742+ static string TToCRest ( DateTime dt , String nullString , String formatStr , IGxContext context , bool toUTC = true )
27132743 {
27142744 if ( dt == nullDate )
27152745 return FormatEmptyDate ( nullString ) ;
27162746 else
27172747 {
2718- DateTime ret = Preferences . useTimezoneFix ( ) ? ( toUTC ? toUniversalTime ( dt ) : dt ) : dt ;
2748+ DateTime ret ;
2749+ if ( context != null )
2750+ {
2751+ ret = Preferences . useTimezoneFix ( ) ? ( toUTC ? toUniversalTime ( dt , context ) : dt ) : dt ;
2752+ }
2753+ else
2754+ {
2755+ ret = Preferences . useTimezoneFix ( ) ? ( toUTC ? toUniversalTime ( dt ) : dt ) : dt ;
2756+ }
27192757 return ret . ToString ( formatStr , CultureInfo . InvariantCulture ) ;
27202758 }
27212759 }
@@ -3536,7 +3574,7 @@ static private bool isNullDateCompatible(DateTime dt)
35363574 else
35373575 return isNullDate ( dt ) ;
35383576 }
3539-
3577+ //[Obsolete("fromUniversalTime is deprecated, use fromUniversalTime(DateTime, IGxContext) instead", false)]
35403578 static public DateTime fromUniversalTime ( DateTime dt )
35413579 {
35423580#if NODATIME
@@ -3545,7 +3583,15 @@ static public DateTime fromUniversalTime(DateTime dt)
35453583 return isNullDateCompatible ( dt ) ? dt : fromUniversalTime ( dt , GxContext . Current . GetOlsonTimeZone ( ) ) ;
35463584#endif
35473585 }
3548-
3586+ static public DateTime fromUniversalTime ( DateTime dt , IGxContext context )
3587+ {
3588+ #if NODATIME
3589+ return isNullDateCompatible ( dt ) ? dt : fromUniversalTime ( dt , context . GetTimeZone ( ) ) ;
3590+ #else
3591+ return isNullDateCompatible ( dt ) ? dt : fromUniversalTime ( dt , context . GetOlsonTimeZone ( ) ) ;
3592+ #endif
3593+ }
3594+ //[Obsolete("toUniversalTime is deprecated, use toUniversalTime(DateTime, IGxContext) instead", false)]
35493595 static public DateTime toUniversalTime ( DateTime dt )
35503596 {
35513597#if NODATIME
0 commit comments