File tree Expand file tree Collapse file tree 1 file changed +30
-5
lines changed 
tp11/src/main/kotlin/fmt/kotlin/fundamentals Expand file tree Collapse file tree 1 file changed +30
-5
lines changed Original file line number Diff line number Diff line change 11package  fmt.kotlin.fundamentals 
22
33import  kotlinx.datetime.* 
4+ import  kotlinx.datetime.DateTimeUnit.Companion.DAY 
45import  kotlinx.datetime.format.MonthNames 
56import  kotlinx.datetime.format.alternativeParsing 
67import  kotlinx.datetime.format.char 
7- import  kotlin.time.Duration.Companion.days  
8+ import  kotlin.time.Duration.Companion.hours  
89
910class  Tp11  {
1011
11-     fun  whichDayIsIn48h (clock :  Clock ): DayOfWeek  =  TODO ()
12+     fun  whichDayIsIn48h (clock :  Clock ) =  (clock.now() +  48 .hours)
13+         .toLocalDateTime(TimeZone .of(" Europe/Paris"  ))
14+         .dayOfWeek
1215
13-     fun  whichDayIsInTwoDays (clock :  Clock ): DayOfWeek  =  TODO ()
16+     fun  whichDayIsInTwoDays (clock :  Clock ) =  clock.now()
17+         .toLocalDateTime(TimeZone .of(" Europe/Paris"  ))
18+         .date
19+         .plus(2 , DAY )
20+         .dayOfWeek
1421
15-     fun  parseInstant (s :  String ): LocalDateTime  =  TODO ()
22+     fun  parseInstant (s :  String ) = 
23+         LocalDateTime .Format  {
24+             dayOfMonth()
25+             alternativeParsing({
26+                 char(' /'  )
27+                 monthNumber()
28+                 char(' /'  )
29+             }) {
30+                 char('  '  )
31+                 monthName(frenchMonthNames)
32+                 char('  '  )
33+             }
34+             yearTwoDigits(1900 )
35+             chars("  à "  )
36+             hour()
37+             char(' h'  )
38+             minute()
39+         }.parse(s)
1640
17-     fun  daysBetween (instant1 :  Instant , instant2 :  Instant ): Long  =  TODO ()
41+     fun  daysBetween (instant1 :  Instant , instant2 :  Instant ) = 
42+         (instant2 -  instant1).inWholeDays
1843
1944    companion  object  {
2045        private  val  frenchMonthNames =  MonthNames (
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments