package Ġcom . so y wiz . k lock Ċ Ċ import Ġcom . so y wiz . k lock . locale .* Ċ import Ġkotlin . test . Test Ċ import Ġkotlin . test . assertEquals Ċ Ċ class ĠDate Test Ġ{ Ċ ĉ @ Test Ċ ĉ fun Ġtest () Ġ{ Ċĉ ĉ val Ġdate Ġ= ĠDate ( 2 0 1 9 , ĠMonth . September , Ġ 1 8 ) Ċĉ ĉ val Ġdate 2 Ġ= ĠDate ( 2 0 1 9 , ĠMonth . September , Ġ 1 9 ) Ċĉ ĉ val Ġtime Ġ= ĠTime ( 1 3 , Ġ 9 , Ġ 3 7 , Ġ 1 5 0 ) ĊĊĉ ĉ assertEquals ( DayOfWeek . Wednesday , Ġdate . day OfWeek ) Ċĉ ĉ assertEquals ( DayOfWeek . Thursday , Ġdate 2 . day OfWeek ) Ċĉ ĉ assertEquals ( 4 , Ġdate 2 . day OfWeek Int ) Ċĉ ĉ assertEquals ( 1 , ĠDate ( 2 0 1 9 , ĠMonth . January , Ġ 1 ). day OfYear ) Ċĉ ĉ assertEquals ( 2 6 2 , Ġdate 2 . day OfYear ) Ċĉ ĉ assertEquals ( 2 0 1 9 , Ġdate 2 . year ) Ċĉ ĉ assertEquals ( Year ( 2 0 1 9 ), Ġdate 2 . year Year ) ĊĊĉ ĉ assertEquals (" 2 0 1 9 - 0 9 - 1 8 ", Ġdate . toString ()) Ċĉ ĉ assertEquals (" 1 3 : 0 9 : 3 7 . 1 5 0 ", Ġtime . toString ()) Ċĉ ĉ assertEquals (" Wed , Ġ 1 8 ĠSep Ġ 2 0 1 9 Ġ 0 0 : 0 0 : 0 0 ĠUTC ", Ġ( date . dateTime Day Start ). toString ()) Ċĉ ĉ assertEquals (" Wed , Ġ 1 8 ĠSep Ġ 2 0 1 9 Ġ 1 3 : 0 9 : 3 7 ĠUTC ", Ġ( date Ġ+ Ġtime ). toString ()) Ċĉ ĉ assertEquals (" 2 0 1 9 - 1 0 - 0 1 ", Ġ( Date ( 2 0 1 9 , ĠMonth . September , Ġ 3 0 ) Ġ+ Ġ 1 . days ). toString ()) Ċĉ ĉ assertEquals (" 2 0 1 9 - 1 0 - 3 0 ", Ġ( Date ( 2 0 1 9 , ĠMonth . September , Ġ 3 0 ) Ġ+ Ġ 1 . months ). toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 2 0 1 9 - 0 9 - 3 0 ", Ġ( Date ( 2 0 1 9 , ĠMonth . Oct ober , Ġ 1 ) Ġ- Ġ 1 . days ). toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 2 0 1 9 - 0 9 - 0 1 ", Ġ( Date ( 2 0 1 9 , ĠMonth . Oct ober , Ġ 1 ) Ġ- Ġ 1 . months ). toString ()) ĊĊĠĠĠĠĠĠĠ ĠassertEquals (" 2 0 1 9 - 1 0 - 3 1 ", Ġ( Date ( 2 0 1 9 , ĠMonth . September , Ġ 3 0 ) Ġ+ ĠDateTime Span ( 1 . months , Ġ 1 . days )). toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 2 0 1 9 - 0 8 - 3 1 ", Ġ( Date ( 2 0 1 9 , ĠMonth . Oct ober , Ġ 1 ) Ġ- ĠDateTime Span ( 1 . months , Ġ 1 . days )). toString ()) ĊĊĉ ĉ ( Time ( 9 , Ġ 0 ) Ġ.. ĠTime ( 1 9 , Ġ 3 0 )). let Ġ{ Ġrange Ġ-> Ċĉĉ ĉ assertEquals ( true , Ġrange . contains ( Time ( 1 1 , Ġ 0 ))) Ċĉĉ ĉ assertEquals ( false , Ġrange . contains ( Time ( 8 , Ġ 5 9 , Ġ 5 9 , Ġ 9 9 9 ))) Ċĉĉ ĉ assertEquals ( false , Ġrange . contains ( Time ( 1 9 , Ġ 3 1 ))) Ċĉ ĉ } ĊĊĉ ĉ ( Date ( 2 0 1 9 , Ġ 9 , Ġ 1 8 ) Ġ.. ĠDate ( 2 0 1 9 , Ġ 1 0 , Ġ 2 )). let Ġ{ Ġrange Ġ-> Ċĉĉ ĉ assertEquals ( true , Ġrange . contains ( Date ( 2 0 1 9 , Ġ 9 , Ġ 1 8 ))) Ċĉĉ ĉ assertEquals ( true , Ġrange . contains ( Date ( 2 0 1 9 , Ġ 1 0 , Ġ 1 ))) Ċĉĉ ĉ assertEquals ( false , Ġrange . contains ( Date ( 2 0 1 9 , Ġ 9 , Ġ 1 7 ))) Ċĉĉ ĉ assertEquals ( false , Ġrange . contains ( Date ( 2 0 1 9 , Ġ 1 0 , Ġ 3 ))) Ċĉ ĉ } ĊĊĉ ĉ assertEquals (" Wed , Ġ 1 8 ĠSep Ġ 2 0 1 9 Ġ 0 0 : 0 0 : 0 0 ĠUTC ", Ġ( Date ( 2 0 1 9 , ĠMonth . September , Ġ 1 7 ) Ġ+ ĠTime ( 2 4 )). toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Tue , Ġ 1 7 ĠSep Ġ 2 0 1 9 Ġ 0 0 : 0 0 : 0 0 ĠUTC ", Ġ( Date ( 2 0 1 9 , ĠMonth . September , Ġ 1 8 ) Ġ- ĠTime ( 2 4 )). toString ()) ĊĊĠĠĠĠĠĠĠ ĠassertEquals (" Wed , Ġ 1 8 ĠSep Ġ 2 0 1 9 Ġ 0 1 : 0 2 : 2 0 ĠUTC ", Ġ( Date ( 2 0 1 9 , ĠMonth . September , Ġ 1 8 ) Ġ+ ĠTime ( hour Ġ= Ġ 1 , Ġminute Ġ= Ġ 1 , Ġsecond Ġ= Ġ 8 0 )). toString ()) ĊĠĠĠĠĠĠĠ Ġval Ġformat Ġ= Ġ" EEE , Ġdd ĠM MM ĠYYYY ĠHH : mm : ss . SS S " ĊĠĠĠĠĠĠĠ ĠassertEquals (" Wed , Ġ 1 8 ĠSep Ġ 2 0 1 9 Ġ 0 1 : 0 2 : 2 0 . 3 0 0 ", Ġ( Date ( 2 0 1 9 , ĠMonth . September , Ġ 1 8 ) Ġ+ ĠTime ( hour Ġ= Ġ 1 , Ġminute Ġ= Ġ 1 , Ġsecond Ġ= Ġ 8 0 , Ġmilli second Ġ= Ġ 3 0 0 )). format ( format )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Wed , Ġ 1 8 ĠSep Ġ 2 0 1 9 Ġ 0 1 : 0 2 : 2 1 . 3 0 0 ", Ġ( Date ( 2 0 1 9 , ĠMonth . September , Ġ 1 8 ) Ġ+ ĠTime ( hour Ġ= Ġ 1 , Ġminute Ġ= Ġ 1 , Ġsecond Ġ= Ġ 8 0 , Ġmilli second Ġ= Ġ 1 3 0 0 )). format ( format )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Wed , Ġ 1 8 ĠSep Ġ 2 0 1 9 Ġ 2 3 : 5 8 : 3 9 . 7 0 0 ", Ġ( Date ( 2 0 1 9 , ĠMonth . September , Ġ 1 8 ) Ġ- ĠTime ( hour Ġ= Ġ 1 , Ġminute Ġ= Ġ 1 , Ġsecond Ġ= Ġ 8 0 , Ġmilli second Ġ= Ġ 3 0 0 )). format ( format )) ĊĠĠĠĠĠĠĠ ĠassertEquals (" Wed , Ġ 1 8 ĠSep Ġ 2 0 1 9 Ġ 2 3 : 5 8 : 3 8 . 7 0 0 ", Ġ( Date ( 2 0 1 9 , ĠMonth . September , Ġ 1 8 ) Ġ- ĠTime ( hour Ġ= Ġ 1 , Ġminute Ġ= Ġ 1 , Ġsecond Ġ= Ġ 8 0 , Ġmilli second Ġ= Ġ 1 3 0 0 )). format ( format )) Ċ ĉ } ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġdate ( day OfMonth : ĠInt , Ġday OfWeek : ĠDay OfWeek , Ġlocale : ĠK lock Locale ) Ġ= ĠDate ( 2 0 1 9 , ĠMonth . September , Ġday OfMonth ). in This Week ( day OfWeek , Ġlocale ). toString () ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 6 .. 2 2 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 1 6 ", Ġdate ( day OfMonth , ĠDay OfWeek . Monday , ĠK lock Locale . span ish ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 6 .. 2 2 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 1 7 ", Ġdate ( day OfMonth , ĠDay OfWeek . Tuesday , ĠK lock Locale . span ish ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 6 .. 2 2 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 1 8 ", Ġdate ( day OfMonth , ĠDay OfWeek . Wednesday , ĠK lock Locale . span ish ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 6 .. 2 2 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 1 9 ", Ġdate ( day OfMonth , ĠDay OfWeek . Thursday , ĠK lock Locale . span ish ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 6 .. 2 2 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 2 0 ", Ġdate ( day OfMonth , ĠDay OfWeek . Friday , ĠK lock Locale . span ish ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 6 .. 2 2 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 2 1 ", Ġdate ( day OfMonth , ĠDay OfWeek . Saturday , ĠK lock Locale . span ish ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 6 .. 2 2 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 2 2 ", Ġdate ( day OfMonth , ĠDay OfWeek . S unday , ĠK lock Locale . span ish ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 5 .. 2 1 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 1 5 ", Ġdate ( day OfMonth , ĠDay OfWeek . S unday , ĠK lock Locale . english ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 5 .. 2 1 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 1 6 ", Ġdate ( day OfMonth , ĠDay OfWeek . Monday , ĠK lock Locale . english ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 5 .. 2 1 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 1 7 ", Ġdate ( day OfMonth , ĠDay OfWeek . Tuesday , ĠK lock Locale . english ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 5 .. 2 1 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 1 8 ", Ġdate ( day OfMonth , ĠDay OfWeek . Wednesday , ĠK lock Locale . english ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 5 .. 2 1 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 1 9 ", Ġdate ( day OfMonth , ĠDay OfWeek . Thursday , ĠK lock Locale . english ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 5 .. 2 1 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 2 0 ", Ġdate ( day OfMonth , ĠDay OfWeek . Friday , ĠK lock Locale . english ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠĠĠĠĠ Ġfor Ġ( day OfMonth Ġin Ġ 1 5 .. 2 1 ) ĠassertEquals (" 2 0 1 9 - 0 9 - 2 1 ", Ġdate ( day OfMonth , ĠDay OfWeek . Saturday , ĠK lock Locale . english ), Ġ" failed Ġfor Ġday Ġ= Ġ$ day OfMonth ") ĊĠĠĠ Ġ} Ċ } Ċ