@@ -21,7 +21,7 @@ public int Year {
2121 get { if ( CalType == CalendarTypeEnum . Earth )
2222 return _EarthDateTime . Year ;
2323 else
24- return KSPDateStructure . EpochYear + ( Int32 ) UT / KSPDateStructure . SecondsPerYear ;
24+ return KSPDateStructure . EpochYear + ( Int32 ) ( UT / KSPDateStructure . SecondsPerYear ) ;
2525 }
2626 }
2727
@@ -31,7 +31,7 @@ public int DayOfYear {
3131 get { if ( CalType == CalendarTypeEnum . Earth )
3232 return _EarthDateTime . DayOfYear ;
3333 else
34- return KSPDateStructure . EpochDayOfYear + ( Int32 ) UT / KSPDateStructure . SecondsPerDay % KSPDateStructure . DaysPerYear ;
34+ return KSPDateStructure . EpochDayOfYear + ( Int32 ) ( UT / KSPDateStructure . SecondsPerDay % KSPDateStructure . DaysPerYear ) ;
3535 }
3636 }
3737
@@ -184,7 +184,7 @@ public KSPDateTime(int year, int day, int hour, int minute, int second, int mill
184184 {
185185 //Test for entering values outside the norm - eg 25 hours, day 600
186186
187- UT = new KSPTimeSpan ( ( year - KSPDateStructure . EpochYear ) * KSPDateStructure . DaysPerYear +
187+ UT = new KSPTimeSpan ( ( Int32 ) ( ( year - KSPDateStructure . EpochYear ) * KSPDateStructure . DaysPerYear ) +
188188 ( day - KSPDateStructure . EpochDayOfYear ) ,
189189 hour ,
190190 minute ,
@@ -247,39 +247,54 @@ private enum AMPMEnum {
247247 AM , PM , OddHoursPerDay
248248 }
249249
250- /// <summary>Generates some standard Templated versions of output</summary>
251- /// <param name="DateFormat">Enum of some common formats</param>
252- /// <returns>A string that represents the value of this instance.</returns>
253- public String ToStringStandard ( DateStringFormatsEnum DateFormat ) {
254- switch ( DateFormat )
255- {
256- case DateStringFormatsEnum . TimeAsUT :
257- String strReturn = "" ;
258- if ( UT < 0 ) strReturn += "+ " ;
259- strReturn += String . Format ( "{0:N0}s" , Math . Abs ( UT ) ) ;
260- return strReturn ;
261- case DateStringFormatsEnum . KSPFormat :
262- return ToString ( ) ;
263- case DateStringFormatsEnum . KSPFormatWithSecs :
264- return ToString ( "Year y, Da\\ y d - H\\ h, m\\ m, s\\ s" ) ;
265- case DateStringFormatsEnum . DateTimeFormat :
266- if ( KSPDateStructure . CalendarType == CalendarTypeEnum . Earth )
250+ /// <summary>Generates some standard Templated versions of output</summary>
251+ /// <param name="DateFormat">Enum of some common formats</param>
252+ /// <returns>A string that represents the value of this instance.</returns>
253+ public String ToStringStandard ( DateStringFormatsEnum DateFormat )
254+ {
255+ switch ( DateFormat )
256+ {
257+ case DateStringFormatsEnum . TimeAsUT :
258+ return ( UT < 0 ? "+ " : "" ) + String . Format ( "{0:N0}s" , Math . Abs ( UT ) ) ;
259+ case DateStringFormatsEnum . KSPFormat :
260+ return ToString ( ) ;
261+ case DateStringFormatsEnum . KSPFormatWithSecs :
262+ if ( KSPDateStructure . UseStockDateFormatters )
263+ {
264+ return KSPUtil . dateTimeFormatter . PrintDate ( UT , true , true ) ;
265+ }
266+ return ToString ( "Year y, Da\\ y d - H\\ h, m\\ m, s\\ s" ) ;
267+ case DateStringFormatsEnum . DateTimeFormat :
268+ if ( KSPDateStructure . CalendarType == CalendarTypeEnum . Earth )
269+ {
267270 return ToString ( "d MMM yyyy, HH:mm:ss" ) ;
271+ }
268272 else
269- return ToString ( "Year y, Da\\ y d, HH:mm:ss" ) ;
270- default :
271- return ToString ( ) ;
272- }
273- }
273+ {
274+ if ( KSPDateStructure . UseStockDateFormatters )
275+ {
274276
275- /// <summary>Returns the string representation of the value of this instance.</summary>
276- /// <returns>A string that represents the value of this instance.</returns>
277- public override String ToString ( )
277+ return KSPUtil . dateTimeFormatter . PrintDateNew ( UT , true ) ;
278+ }
279+ return ToString ( "Year y, Da\\ y d, HH:mm:ss" ) ;
280+ }
281+ default :
282+ return ToString ( ) ;
283+ }
284+ }
285+
286+ /// <summary>Returns the string representation of the value of this instance.</summary>
287+ /// <returns>A string that represents the value of this instance.</returns>
288+ public override String ToString ( )
278289 {
279290 if ( CalType == CalendarTypeEnum . Earth ) {
280291 return ToString ( System . Globalization . CultureInfo . CurrentCulture . DateTimeFormat . ShortDatePattern + " " + System . Globalization . CultureInfo . CurrentCulture . DateTimeFormat . ShortTimePattern ) ;
281292 } else {
282- return ToString ( "Year y, Da\\ y d - H\\ h, m\\ m" , null ) ;
293+ if ( KSPDateStructure . UseStockDateFormatters )
294+ {
295+ return KSPUtil . dateTimeFormatter . PrintDate ( UT , true , false ) ;
296+ }
297+ return ToString ( "Year y, Da\\ y d - H\\ h, m\\ m" , null ) ;
283298 }
284299 }
285300 /// <summary>Returns the string representation of the value of this instance.</summary>
0 commit comments