@@ -225,24 +225,15 @@ elif defined(posix):
225
225
226
226
type CTime = posix.Time
227
227
228
- when not defined (freebsd) and not defined (netbsd) and not defined (openbsd):
229
- var timezone {.importc , header : " <time.h>" .}: int
230
- when not defined (valgrind_workaround_10121):
231
- tzset ()
232
-
233
228
when defined (macosx):
234
229
proc gettimeofday (tp: var Timeval , unused: pointer = nil )
235
230
{.importc : " gettimeofday" , header : " <sys/time.h>" , sideEffect .}
236
231
237
232
elif defined (windows):
238
233
import winlean, std/ time_t
239
234
240
- type CTime = time_t.Time
241
-
242
- # visual c's c runtime exposes these under a different name
243
- var timezone {.importc : " _timezone" , header : " <time.h>" .}: int
244
-
245
235
type
236
+ CTime = time_t.Time
246
237
Tm {.importc : " struct tm" , header : " <time.h>" , final , pure .} = object
247
238
tm_sec* : cint # # Seconds [0,60].
248
239
tm_min* : cint # # Minutes [0,59].
@@ -2507,7 +2498,7 @@ proc `-=`*(t: var Time, b: TimeInterval) =
2507
2498
#
2508
2499
2509
2500
proc epochTime * (): float {.tags : [TimeEffect ].} =
2510
- # # gets time after the UNIX epoch (1970) in seconds. It is a float
2501
+ # # Gets time after the UNIX epoch (1970) in seconds. It is a float
2511
2502
# # because sub-second resolution is likely to be supported (depending
2512
2503
# # on the hardware/OS).
2513
2504
# #
@@ -2545,7 +2536,7 @@ when not defined(js):
2545
2536
clocksPerSec {.importc : " CLOCKS_PER_SEC" , nodecl , used .}: int
2546
2537
2547
2538
proc cpuTime * (): float {.tags : [TimeEffect ].} =
2548
- # # gets time spent that the CPU spent to run the current process in
2539
+ # # Gets time spent that the CPU spent to run the current process in
2549
2540
# # seconds. This may be more useful for benchmarking than ``epochTime``.
2550
2541
# # However, it may measure the real time instead (depending on the OS).
2551
2542
# # The value of the result has no meaning.
@@ -2581,40 +2572,34 @@ proc countLeapYears*(yearSpan: int): int
2581
2572
# # counts the number of leap years up to January 1st of a given year.
2582
2573
# # Keep in mind that if specified year is a leap year, the leap day
2583
2574
# # has not happened before January 1st of that year.
2584
- # #
2585
- # # **Deprecated since v0.20.0**.
2575
+ # Deprecated since v0.20.0
2586
2576
(yearSpan - 1 ) div 4 - (yearSpan - 1 ) div 100 + (yearSpan - 1 ) div 400
2587
2577
2588
2578
proc countDays * (yearSpan: int ): int
2589
2579
{.deprecated .} =
2590
2580
# # Returns the number of days spanned by a given number of years.
2591
- # #
2592
- # # **Deprecated since v0.20.0**.
2581
+ # Deprecated since v0.20.0
2593
2582
(yearSpan - 1 ) * 365 + countLeapYears (yearSpan)
2594
2583
2595
2584
proc countYears * (daySpan: int ): int
2596
2585
{.deprecated .} =
2597
2586
# # Returns the number of years spanned by a given number of days.
2598
- # #
2599
- # # **Deprecated since v0.20.0**.
2587
+ # Deprecated since v0.20.0
2600
2588
((daySpan - countLeapYears (daySpan div 365 )) div 365 )
2601
2589
2602
2590
proc countYearsAndDays * (daySpan: int ): tuple [years: int , days: int ]
2603
2591
{.deprecated .} =
2604
2592
# # Returns the number of years spanned by a given number of days and the
2605
2593
# # remainder as days.
2606
- # #
2607
- # # **Deprecated since v0.20.0**.
2594
+ # Deprecated since v0.20.0
2608
2595
let days = daySpan - countLeapYears (daySpan div 365 )
2609
2596
result .years = days div 365
2610
2597
result .days = days mod 365
2611
2598
2612
2599
proc toTimeInterval * (time: Time ): TimeInterval
2613
- {.deprecated : " Use ` between` instead" .} =
2600
+ {.deprecated : " Use ' between' instead" .} =
2614
2601
# # Converts a Time to a TimeInterval. To be used when diffing times.
2615
- # #
2616
- # # **Deprecated since version 0.20.0:** Use the `between proc
2617
- # # <#between,DateTime,DateTime>`_ instead.
2602
+ # Deprecated since version 0.20.0
2618
2603
runnableExamples:
2619
2604
let a = fromUnix (10 )
2620
2605
let b = fromUnix (1_500_000_000 )
@@ -2625,55 +2610,45 @@ proc toTimeInterval*(time: Time): TimeInterval
2625
2610
dt.monthday, 0 , dt.month.ord - 1 , dt.year)
2626
2611
2627
2612
proc weeks * (dur: Duration ): int64
2628
- {.inline , deprecated : " Use ` inWeeks` instead" .} =
2613
+ {.inline , deprecated : " Use ' inWeeks' instead" .} =
2629
2614
# # Number of whole weeks represented by the duration.
2630
- # #
2631
- # # **Deprecated since version v0.20.0**: Use the `inWeeks proc
2632
- # # <#inWeeks,Duration>`_ instead.
2615
+ # Deprecated since version v0.20.0
2633
2616
runnableExamples:
2634
2617
let dur = initDuration (weeks = 1 , days = 2 , hours = 3 , minutes = 4 )
2635
2618
doAssert dur.weeks == 1
2636
2619
dur.inWeeks
2637
2620
2638
2621
proc days * (dur: Duration ): int64
2639
- {.inline , deprecated : " Use ` inDays` instead" .} =
2622
+ {.inline , deprecated : " Use ' inDays' instead" .} =
2640
2623
# # Number of whole days represented by the duration.
2641
- # #
2642
- # # **Deprecated since version v0.20.0**: Use the `inDays proc
2643
- # # <#inDays,Duration>`_ instead.
2624
+ # Deprecated since version v0.20.0
2644
2625
runnableExamples:
2645
2626
let dur = initDuration (weeks = 1 , days = 2 , hours = 3 , minutes = 4 )
2646
2627
doAssert dur.days == 9
2647
2628
dur.inDays
2648
2629
2649
2630
proc hours * (dur: Duration ): int64
2650
- {.inline , deprecated : " Use ` inHours` instead" .} =
2631
+ {.inline , deprecated : " Use ' inHours' instead" .} =
2651
2632
# # Number of whole hours represented by the duration.
2652
- # #
2653
- # # **Deprecated since version v0.20.0**: Use the `inHours proc
2654
- # # <#inHours,Duration>`_ instead.
2633
+ # Deprecated since version v0.20.0
2655
2634
runnableExamples:
2656
2635
let dur = initDuration (days = 1 , hours = 2 , minutes = 3 )
2657
2636
doAssert dur.hours == 26
2658
2637
dur.inHours
2659
2638
2660
2639
proc minutes * (dur: Duration ): int64
2661
- {.inline , deprecated : " Use ` inMinutes` instead" .} =
2640
+ {.inline , deprecated : " Use ' inMinutes' instead" .} =
2662
2641
# # Number of whole minutes represented by the duration.
2663
- # #
2664
- # # **Deprecated since version v0.20.0**: Use the `inMinutes proc
2665
- # # <#inMinutes,Duration>`_ instead.
2642
+ # Deprecated since version v0.20.0
2666
2643
runnableExamples:
2667
2644
let dur = initDuration (days = 1 , hours = 2 , minutes = 3 )
2668
2645
doAssert dur.minutes == 1563
2669
2646
dur.inMinutes
2670
2647
2671
2648
proc seconds * (dur: Duration ): int64
2672
- {.inline , deprecated : " Use ` inSeconds` instead" .} =
2649
+ {.inline , deprecated : " Use ' inSeconds' instead" .} =
2673
2650
# # Number of whole seconds represented by the duration.
2674
- # #
2675
- # # **Deprecated since version v0.20.0**: Use the `inSeconds proc
2676
- # # <#inSeconds,Duration>`_ instead.
2651
+ # Deprecated since version v0.20.0
2677
2652
runnableExamples:
2678
2653
let dur = initDuration (minutes = 10 , seconds = 30 )
2679
2654
doAssert dur.seconds == 630
@@ -2682,8 +2657,7 @@ proc seconds*(dur: Duration): int64
2682
2657
proc milliseconds * (dur: Duration ): int {.inline , deprecated .} =
2683
2658
# # Number of whole milliseconds represented by the **fractional**
2684
2659
# # part of the duration.
2685
- # #
2686
- # # **Deprecated since version v0.20.0**.
2660
+ # Deprecated since version v0.20.0
2687
2661
runnableExamples:
2688
2662
let dur = initDuration (minutes = 5 , seconds = 6 , milliseconds = 7 ,
2689
2663
microseconds = 8 , nanoseconds = 9 )
@@ -2693,8 +2667,7 @@ proc milliseconds*(dur: Duration): int {.inline, deprecated.} =
2693
2667
proc microseconds * (dur: Duration ): int {.inline , deprecated .} =
2694
2668
# # Number of whole microseconds represented by the **fractional**
2695
2669
# # part of the duration.
2696
- # #
2697
- # # **Deprecated since version v0.20.0**.
2670
+ # Deprecated since version v0.20.0
2698
2671
runnableExamples:
2699
2672
let dur = initDuration (minutes = 5 , seconds = 6 , milliseconds = 7 ,
2700
2673
microseconds = 8 , nanoseconds = 9 )
@@ -2704,8 +2677,7 @@ proc microseconds*(dur: Duration): int {.inline, deprecated.} =
2704
2677
proc nanoseconds * (dur: Duration ): NanosecondRange {.inline , deprecated .} =
2705
2678
# # Number of whole microseconds represented by the **fractional**
2706
2679
# # part of the duration.
2707
- # #
2708
- # # **Deprecated since version v0.20.0**.
2680
+ # Deprecated since version v0.20.0
2709
2681
runnableExamples:
2710
2682
let dur = initDuration (minutes = 5 , seconds = 6 , milliseconds = 7 ,
2711
2683
microseconds = 8 , nanoseconds = 9 )
@@ -2714,121 +2686,37 @@ proc nanoseconds*(dur: Duration): NanosecondRange {.inline, deprecated.} =
2714
2686
2715
2687
proc fractional * (dur: Duration ): Duration {.inline , deprecated .} =
2716
2688
# # The fractional part of `dur`, as a duration.
2717
- # #
2718
- # # **Deprecated since version v0.20.0**.
2689
+ # Deprecated since version v0.20.0
2719
2690
runnableExamples:
2720
2691
let dur = initDuration (minutes = 5 , seconds = 6 , milliseconds = 7 ,
2721
2692
microseconds = 8 , nanoseconds = 9 )
2722
2693
doAssert dur.fractional == initDuration (milliseconds = 7 , microseconds = 8 ,
2723
2694
nanoseconds = 9 )
2724
2695
initDuration (nanoseconds = dur.nanosecond)
2725
2696
2726
- when not defined (js):
2727
- proc unixTimeToWinTime * (time: CTime ): int64
2728
- {.deprecated : " Use toWinTime instead" .} =
2729
- # # Converts a UNIX `Time` (``time_t``) to a Windows file time
2730
- # #
2731
- # # **Deprecated:** use ``toWinTime`` instead.
2732
- result = int64 (time) * rateDiff + epochDiff
2733
-
2734
- proc winTimeToUnixTime * (time: int64 ): CTime
2735
- {.deprecated : " Use fromWinTime instead" .} =
2736
- # # Converts a Windows time to a UNIX `Time` (``time_t``)
2737
- # #
2738
- # # **Deprecated:** use ``fromWinTime`` instead.
2739
- result = CTime ((time - epochDiff) div rateDiff)
2740
-
2741
- proc initInterval * (seconds, minutes, hours, days, months, years: int = 0 ):
2742
- TimeInterval {.deprecated .} =
2743
- # # **Deprecated since v0.18.0:** use ``initTimeInterval`` instead.
2744
- initTimeInterval (0 , 0 , 0 , seconds, minutes, hours, days, 0 , months, years)
2745
-
2746
2697
proc fromSeconds * (since1970: float ): Time
2747
- {.tags : [], raises : [], benign , deprecated : " Use fromUnixFloat or fromUnix" .} =
2698
+ {.tags : [], raises : [], benign , deprecated : " Use ` fromUnixFloat or ' fromUnix' instead " .} =
2748
2699
# # Takes a float which contains the number of seconds since the unix epoch and
2749
2700
# # returns a time object.
2750
- # #
2751
- # # **Deprecated since v0.18.0:** use ``fromUnix`` instead
2701
+ # Deprecated since v0.18.0
2752
2702
fromUnixFloat (since1970)
2753
2703
2754
2704
proc fromSeconds * (since1970: int64 ): Time
2755
- {.tags : [], raises : [], benign , deprecated .} =
2705
+ {.tags : [], raises : [], benign , deprecated : " Use 'fromUnix' instead " .} =
2756
2706
# # Takes an int which contains the number of seconds since the unix epoch and
2757
2707
# # returns a time object.
2758
- # #
2759
- # # **Deprecated since v0.18.0:** use ``fromUnix`` instead
2708
+ # Deprecated since v0.18.0
2760
2709
fromUnix (since1970)
2761
2710
2762
2711
proc toSeconds * (time: Time ): float
2763
- {.tags : [], raises : [], benign , deprecated : " Use toUnixFloat or toUnix" .} =
2712
+ {.tags : [], raises : [], benign , deprecated : " Use ' toUnixFloat' or ' toUnix' instead " .} =
2764
2713
# # Returns the time in seconds since the unix epoch, with subsecond resolution.
2714
+ # Deprecated since v0.18.0
2765
2715
toUnixFloat (time)
2766
2716
2767
- proc getLocalTime * (time: Time ): DateTime
2768
- {.tags : [], raises : [], benign , deprecated .} =
2769
- # # Converts the calendar time `time` to broken-time representation,
2770
- # # expressed relative to the user's specified time zone.
2771
- # #
2772
- # # **Deprecated since v0.18.0:** use ``local`` instead
2773
- time.local
2774
-
2775
2717
proc getGMTime * (time: Time ): DateTime
2776
- {.tags : [], raises : [], benign , deprecated .} =
2718
+ {.tags : [], raises : [], benign , deprecated : " Use 'utc' instead " .} =
2777
2719
# # Converts the calendar time `time` to broken-down time representation,
2778
2720
# # expressed in Coordinated Universal Time (UTC).
2779
- # #
2780
- # # **Deprecated since v0.18.0:** use ``utc`` instead
2721
+ # Deprecated since v0.18.0
2781
2722
time.utc
2782
-
2783
- proc getTimezone * (): int
2784
- {.tags : [TimeEffect ], raises : [], benign , deprecated .} =
2785
- # # Returns the offset of the local (non-DST) timezone in seconds west of UTC.
2786
- # #
2787
- # # **Deprecated since v0.18.0:** use ``now().utcOffset`` to get the current
2788
- # # utc offset (including DST).
2789
- when defined (js):
2790
- return newDate ().getTimezoneOffset () * 60
2791
- elif defined (freebsd) or defined (netbsd) or defined (openbsd):
2792
- # This is wrong since it will include DST offsets, but the behavior has
2793
- # always been wrong for bsd and the proc is deprecated so lets ignore it.
2794
- return now ().utcOffset
2795
- else :
2796
- return timezone
2797
-
2798
- proc getDayOfWeek * (day, month, year: int ): WeekDay
2799
- {.tags : [], raises : [], benign , deprecated .} =
2800
- # # **Deprecated since v0.18.0:** use
2801
- # # ``getDayOfWeek(monthday: MonthdayRange; month: Month; year: int)`` instead.
2802
- getDayOfWeek (day, month.Month , year)
2803
-
2804
- proc getDayOfWeekJulian * (day, month, year: int ): WeekDay {.deprecated .} =
2805
- # # Returns the day of the week enum from day, month and year,
2806
- # # according to the Julian calendar.
2807
- # # **Deprecated since v0.18.0**
2808
- # Day & month start from one.
2809
- let
2810
- a = (14 - month) div 12
2811
- y = year - a
2812
- m = month + (12 * a) - 2
2813
- d = (5 + day + y + (y div 4 ) + (31 * m) div 12 ) mod 7
2814
- result = d.WeekDay
2815
-
2816
- proc adjTime * (zt: ZonedTime ): Time
2817
- {.deprecated : " Use zt.time instead" .} =
2818
- # # **Deprecated since v0.19.0:** use the ``time`` field instead.
2819
- zt.time - initDuration (seconds = zt.utcOffset)
2820
-
2821
- proc `adjTime=` * (zt: var ZonedTime , adjTime: Time )
2822
- {.deprecated : " Use zt.time instead" .} =
2823
- # # **Deprecated since v0.19.0:** use the ``time`` field instead.
2824
- zt.time = adjTime + initDuration (seconds = zt.utcOffset)
2825
-
2826
- proc zoneInfoFromUtc * (zone: Timezone , time: Time ): ZonedTime
2827
- {.deprecated : " Use zonedTimeFromTime instead" .} =
2828
- # # **Deprecated since v0.19.0:** use ``zonedTimeFromTime`` instead.
2829
- zone.zonedTimeFromTime (time)
2830
-
2831
- proc zoneInfoFromTz * (zone: Timezone , adjTime: Time ): ZonedTime
2832
- {.deprecated : " Use zonedTimeFromAdjTime instead" .} =
2833
- # # **Deprecated since v0.19.0:** use the ``zonedTimeFromAdjTime`` instead.
2834
- zone.zonedTimeFromAdjTime (adjTime)
0 commit comments