@@ -2508,6 +2508,7 @@ let ignoreFormatProvider compiledName args =
2508
2508
| _ -> args
2509
2509
2510
2510
let makeDateOrTimeMemberCall com ctx r t i moduleName memberName ( thisArg : Expr option ) ( args : Expr list ) =
2511
+ let memberName = Naming.removeGetSetPrefix memberName |> Naming.lowerFirst
2511
2512
let args = ignoreFormatProvider i.CompiledName args
2512
2513
2513
2514
match thisArg with
@@ -2584,10 +2585,7 @@ let dateTimes (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr o
2584
2585
| " Subtract" ->
2585
2586
Operation( Binary( BinaryOperator.BinaryMinus, thisArg.Value, args.Head), Tags.empty, t, r)
2586
2587
|> Some
2587
- | meth ->
2588
- let meth = Naming.removeGetSetPrefix meth |> Naming.lowerFirst
2589
-
2590
- makeDateOrTimeMemberCall com ctx r t i " DateTime" meth thisArg args |> Some
2588
+ | meth -> makeDateOrTimeMemberCall com ctx r t i " DateTime" meth thisArg args |> Some
2591
2589
2592
2590
let dateTimeOffsets ( com : ICompiler ) ( ctx : Context ) r t ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
2593
2591
match i.CompiledName with
@@ -2598,24 +2596,30 @@ let dateTimeOffsets (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg:
2598
2596
| ExprType( DeclaredType( ent, [])) :: [] when ent.FullName = Types.datetime -> " new_datetime" |> Some
2599
2597
| ExprType( DeclaredType( ent, [])) :: _ when ent.FullName = Types.datetime -> " new_datetime2" |> Some
2600
2598
| ExprType( DeclaredType( ent, [])) :: _ when ent.FullName = Types.dateOnly -> " new_date_time" |> Some
2601
- | ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32,
2602
- _)) :: ExprType( Number( Int32,
2603
- _)) :: ExprType( Number( Int32,
2604
- _)) :: _ offset :: [] ->
2605
- " new_ymdhms" |> Some
2606
- | ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32,
2607
- _)) :: ExprType( Number( Int32,
2608
- _)) :: ExprType( Number( Int32,
2609
- _)) :: ExprType( Number( Int32,
2610
- _)) :: _ offset :: [] ->
2611
- " new_ymdhms_milli" |> Some
2612
- | ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32,
2613
- _)) :: ExprType( Number( Int32,
2614
- _)) :: ExprType( Number( Int32,
2615
- _)) :: ExprType( Number( Int32,
2616
- _)) :: ExprType( Number( Int32,
2617
- _)) :: _ offset :: [] ->
2618
- " new_ymdhms_micro" |> Some
2599
+ | [ ExprType( Number( Int32, _))
2600
+ ExprType( Number( Int32, _))
2601
+ ExprType( Number( Int32, _))
2602
+ ExprType( Number( Int32, _))
2603
+ ExprType( Number( Int32, _))
2604
+ ExprType( Number( Int32, _))
2605
+ _ offset ] -> " new_ymdhms" |> Some
2606
+ | [ ExprType( Number( Int32, _))
2607
+ ExprType( Number( Int32, _))
2608
+ ExprType( Number( Int32, _))
2609
+ ExprType( Number( Int32, _))
2610
+ ExprType( Number( Int32, _))
2611
+ ExprType( Number( Int32, _))
2612
+ ExprType( Number( Int32, _))
2613
+ _ offset ] -> " new_ymdhms_milli" |> Some
2614
+ | [ ExprType( Number( Int32, _))
2615
+ ExprType( Number( Int32, _))
2616
+ ExprType( Number( Int32, _))
2617
+ ExprType( Number( Int32, _))
2618
+ ExprType( Number( Int32, _))
2619
+ ExprType( Number( Int32, _))
2620
+ ExprType( Number( Int32, _))
2621
+ ExprType( Number( Int32, _))
2622
+ _ offset ] -> " new_ymdhms_micro" |> Some
2619
2623
| _ -> None
2620
2624
|> Option.map ( fun meth -> makeStaticMemberCall com r t i " DateTimeOffset" meth args)
2621
2625
| " Compare"
@@ -2629,8 +2633,6 @@ let dateTimeOffsets (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg:
2629
2633
Operation( Binary( BinaryOperator.BinaryMinus, thisArg.Value, args.Head), Tags.empty, t, r)
2630
2634
|> Some
2631
2635
| meth ->
2632
- let meth = Naming.removeGetSetPrefix meth |> Naming.lowerFirst
2633
-
2634
2636
makeDateOrTimeMemberCall com ctx r t i " DateTimeOffset" meth thisArg args
2635
2637
|> Some
2636
2638
@@ -2646,10 +2648,7 @@ let dateOnly (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr op
2646
2648
| " Equals"
2647
2649
| " GetHashCode" -> valueTypes com ctx r t i thisArg args
2648
2650
| " ToDateTime" when args.Length = 2 -> makeInstanceCall r t i thisArg.Value " toDateTime2" args |> Some
2649
- | meth ->
2650
- let meth = Naming.removeGetSetPrefix meth |> Naming.lowerFirst
2651
-
2652
- makeDateOrTimeMemberCall com ctx r t i " DateOnly" meth thisArg args |> Some
2651
+ | meth -> makeDateOrTimeMemberCall com ctx r t i " DateOnly" meth thisArg args |> Some
2653
2652
2654
2653
let timeOnly ( com : ICompiler ) ( ctx : Context ) r t ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
2655
2654
match i.CompiledName with
@@ -2674,26 +2673,30 @@ let timeOnly (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr op
2674
2673
| " Equals"
2675
2674
| " GetHashCode" -> valueTypes com ctx r t i thisArg args
2676
2675
| " Add" when args.Length = 2 -> makeInstanceCall r t i thisArg.Value " add2" args |> Some
2677
- | meth ->
2678
- let meth = Naming.removeGetSetPrefix meth |> Naming.lowerFirst
2679
-
2680
- makeDateOrTimeMemberCall com ctx r t i " TimeOnly" meth thisArg args |> Some
2676
+ | meth -> makeDateOrTimeMemberCall com ctx r t i " TimeOnly" meth thisArg args |> Some
2681
2677
2682
2678
let timeSpans ( com : ICompiler ) ( ctx : Context ) r t ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
2683
2679
// let callee = match i.callee with Some c -> c | None -> i.args.Head
2684
2680
match i.CompiledName with
2685
2681
| " .ctor" ->
2686
2682
match args with
2687
- | ExprType( Number( Int64, _)) :: [] -> " new_ticks" |> Some
2688
- | ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: [] ->
2689
- " new_hms" |> Some
2690
- | ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32,
2691
- _)) :: [] ->
2692
- " new_dhms" |> Some
2693
- | ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32, _)) :: ExprType( Number( Int32,
2694
- _)) :: ExprType( Number( Int32,
2695
- _)) :: [] ->
2696
- " new_dhms_milli" |> Some
2683
+ | [ ExprType( Number( Int64, _)) ] -> " new_ticks" |> Some
2684
+ | [ ExprType( Number( Int32, _)); ExprType( Number( Int32, _)); ExprType( Number( Int32, _)) ] -> " new_hms" |> Some
2685
+ | [ ExprType( Number( Int32, _))
2686
+ ExprType( Number( Int32, _))
2687
+ ExprType( Number( Int32, _))
2688
+ ExprType( Number( Int32, _)) ] -> " new_dhms" |> Some
2689
+ | [ ExprType( Number( Int32, _))
2690
+ ExprType( Number( Int32, _))
2691
+ ExprType( Number( Int32, _))
2692
+ ExprType( Number( Int32, _))
2693
+ ExprType( Number( Int32, _)) ] -> " new_dhms_milli" |> Some
2694
+ | [ ExprType( Number( Int32, _))
2695
+ ExprType( Number( Int32, _))
2696
+ ExprType( Number( Int32, _))
2697
+ ExprType( Number( Int32, _))
2698
+ ExprType( Number( Int32, _))
2699
+ ExprType( Number( Int32, _)) ] -> " new_dhms_micro" |> Some
2697
2700
| _ -> None
2698
2701
|> Option.map ( fun meth -> makeStaticMemberCall com r t i " TimeSpan" meth args)
2699
2702
| " Compare"
@@ -2713,12 +2716,22 @@ let timeSpans (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Expr o
2713
2716
| " Divide" ->
2714
2717
Operation( Binary( BinaryOperator.BinaryDivide, thisArg.Value, args.Head), Tags.empty, t, r)
2715
2718
|> Some
2716
- | meth ->
2717
- let meth =
2718
- Naming.removeGetSetPrefix meth
2719
- |> Naming.applyCaseRule Fable.Core.CaseRules.SnakeCase
2720
-
2721
- makeDateOrTimeMemberCall com ctx r t i " TimeSpan" meth thisArg args |> Some
2719
+ | " FromDays"
2720
+ | " FromHours"
2721
+ | " FromMinutes"
2722
+ | " FromSeconds"
2723
+ | " FromMilliseconds"
2724
+ | " FromMicroseconds" as meth ->
2725
+ match args with
2726
+ | [ ExprType( Number( Float64, _)) ] ->
2727
+ // overloads that take a float
2728
+ makeDateOrTimeMemberCall com ctx r t i " TimeSpan" meth thisArg args |> Some
2729
+ | _ ->
2730
+ // overloads with variable argument counts
2731
+ let argCount = List.length args
2732
+ let meth = meth + ( string argCount)
2733
+ makeDateOrTimeMemberCall com ctx r t i " TimeSpan" meth thisArg args |> Some
2734
+ | meth -> makeDateOrTimeMemberCall com ctx r t i " TimeSpan" meth thisArg args |> Some
2722
2735
2723
2736
let timers ( com : ICompiler ) ( ctx : Context ) r t ( i : CallInfo ) ( thisArg : Expr option ) ( args : Expr list ) =
2724
2737
match i.CompiledName, thisArg, args with
0 commit comments