diff --git a/src/Time.Duration.savi b/src/Time.Duration.savi index e427278..9fb597f 100644 --- a/src/Time.Duration.savi +++ b/src/Time.Duration.savi @@ -20,7 +20,7 @@ :: Represent a duration of the given number of nanoseconds. :new nanoseconds(n U64): - if (n < 1000000000) ( + if n < 1000000000 ( @total_seconds = 0 @nanosecond = n.u32 | @@ -30,7 +30,7 @@ :: Represent a duration of the given number of microseconds. :new microseconds(n U64) - if (n < 1000000) ( + if n < 1000000 ( @total_seconds = 0 @nanosecond = n.u32 * 1000 | @@ -40,7 +40,7 @@ :: Represent a duration of the given number of milliseconds. :new milliseconds(n U64) - if (n < 1000) ( + if n < 1000 ( @total_seconds = 0 @nanosecond = n.u32 * 1000000 | @@ -182,37 +182,37 @@ printed_anything = False output << "Time.Duration(" - if (weeks > 0) ( + if weeks > 0 ( Inspect.into(output, weeks), output << " weeks" printed_anything = True ) - if (days > 0) ( - if printed_anything (output << ", ") + if days > 0 ( + if printed_anything output << ", " Inspect.into(output, days), output << " days" printed_anything = True ) - if (hours > 0) ( - if printed_anything (output << ", ") + if hours > 0 ( + if printed_anything output << ", " Inspect.into(output, hours), output << " hours" printed_anything = True ) - if (minutes > 0) ( - if printed_anything (output << ", ") + if minutes > 0 ( + if printed_anything output << ", " Inspect.into(output, minutes), output << " minutes" printed_anything = True ) - if (seconds > 0) ( - if printed_anything (output << ", ") + if seconds > 0 ( + if printed_anything output << ", " Inspect.into(output, seconds), output << " seconds" printed_anything = True ) - if (nanoseconds > 0) ( - if printed_anything (output << ", ") + if nanoseconds > 0 ( + if printed_anything output << ", " Inspect.into(output, nanoseconds), output << " nanoseconds" printed_anything = True ) @@ -241,7 +241,7 @@ :fun "+"(other Time.Duration'box) total = @total_seconds + other.total_seconds nanos = @nanosecond + other.nanosecond - while (nanos >= Time._nanoseconds_per_second) ( + while nanos >= Time._nanoseconds_per_second ( nanos -= Time._nanoseconds_per_second total += 1 ) @@ -254,7 +254,7 @@ :fun "+!"(other Time.Duration'box) total = @total_seconds +! other.total_seconds nanos = @nanosecond + other.nanosecond - while (nanos >= Time._nanoseconds_per_second) ( + while nanos >= Time._nanoseconds_per_second ( nanos -= Time._nanoseconds_per_second total = total +! 1 ) @@ -267,7 +267,7 @@ :fun "-"(other Time.Duration'box) total = @total_seconds, other_total = other.total_seconds nanos = @nanosecond, other_nanos = other.nanosecond - while (nanos < other_nanos) ( + while nanos < other_nanos ( nanos += Time._nanoseconds_per_second total -= 1 ) @@ -280,7 +280,7 @@ :fun "-!"(other Time.Duration'box) total = @total_seconds, other_total = other.total_seconds nanos = @nanosecond, other_nanos = other.nanosecond - while (nanos < other_nanos) ( + while nanos < other_nanos ( nanos += Time._nanoseconds_per_second total = total -! 1 ) diff --git a/src/Time.Formatter.savi b/src/Time.Formatter.savi index fb8b9ff..46bd310 100644 --- a/src/Time.Formatter.savi +++ b/src/Time.Formatter.savi @@ -32,13 +32,13 @@ original_out_size = out.size is_bad_format = False - while (i < @pattern.size()) ( + while i < @pattern.size() ( try ( char U8 = @pattern.byte_at!(i) ok = True - if (char == '%') ( + if char == '%' ( char = @pattern.byte_at!(i + 1) case ( | char == 'a' | @short_day_name(time, out) @@ -328,11 +328,11 @@ :fun hour_12_zero_padded(time Time'box, out String'ref = String.new) h = (time.hour % 12).u64 - @pad2(if (h == 0) (12 | h), '0', out) + @pad2(if h == 0 (12 | h), '0', out) :fun hour_12_blank_padded(time Time'box, out String'ref = String.new) h = (time.hour % 12).u64 - @pad2(if (h == 0) (12 | h), ' ', out) + @pad2(if h == 0 (12 | h), ' ', out) :fun minute(time Time'box, out String'ref = String.new) @pad2(time.minute.u64, '0', out) @@ -374,10 +374,10 @@ out :fun am_pm(time Time'box) String - if (time.hour < 12) ("am" | "pm") + if time.hour < 12 ("am" | "pm") :fun am_pm_upcase(time Time'box) String - if (time.hour < 12) ("AM" | "PM") + if time.hour < 12 ("AM" | "PM") :fun day_of_week_monday_1_7(time Time'box, out String'ref = String.new) Inspect.into(out, time.day_of_week.u64) @@ -446,25 +446,25 @@ @get_day_name(time).substring(0, 3) :fun pad2(value U64, padding U8, out String'ref = String.new) - if (value < 10) out.push_byte(padding) + if value < 10 out.push_byte(padding) Inspect.into(out, value) out :fun pad3(value U64, padding U8, out String'ref = String.new) - if (value < 100) out.push_byte(padding) + if value < 100 out.push_byte(padding) @pad2(value, padding, out) :fun pad4(value U64, padding U8, out String'ref = String.new) - if (value < 1000) out.push_byte(padding) + if value < 1000 out.push_byte(padding) @pad3(value, padding, out) :fun pad6(value U64, padding U8, out String'ref = String.new) - if (value < 100000) out.push_byte(padding) - if (value < 10000) out.push_byte(padding) + if value < 100000 out.push_byte(padding) + if value < 10000 out.push_byte(padding) @pad4(value, padding, out) :fun pad9(value U64, padding U8, out String'ref = String.new) - if (value < 100000000) out.push_byte(padding) - if (value < 10000000) out.push_byte(padding) - if (value < 1000000) out.push_byte(padding) + if value < 100000000 out.push_byte(padding) + if value < 10000000 out.push_byte(padding) + if value < 1000000 out.push_byte(padding) @pad6(value, padding, out) diff --git a/src/Time.Measure.savi b/src/Time.Measure.savi index b646c35..52ff84b 100644 --- a/src/Time.Measure.savi +++ b/src/Time.Measure.savi @@ -48,7 +48,7 @@ // so we ask it for the timebase and multiple/divide to get nanoseconds. timebase = Pair(U32, U32).new(0, 0) timebase_res = _FFI.mach_timebase_info(stack_address_of_variable timebase) - return 0 if (timebase_res != 0) + return 0 if timebase_res != 0 _FFI.mach_absolute_time * timebase.first.u64 / timebase.last.u64 @@ -89,7 +89,7 @@ // so we ask it for the timebase and multiple/divide to get microseconds. timebase = Pair(U32, U32).new(0, 0) timebase_res = _FFI.mach_timebase_info(stack_address_of_variable timebase) - return 0 if (timebase_res != 0) + return 0 if timebase_res != 0 _FFI.mach_absolute_time * timebase.first.u64 / (timebase.last.u64 * 1000) @@ -130,7 +130,7 @@ // so we ask it for the timebase and multiple/divide to get milliseconds. timebase = Pair(U32, U32).new(0, 0) timebase_res = _FFI.mach_timebase_info(stack_address_of_variable timebase) - return 0 if (timebase_res != 0) + return 0 if timebase_res != 0 _FFI.mach_absolute_time * timebase.first.u64 / (timebase.last.u64 * 1000000) diff --git a/src/Time.savi b/src/Time.savi index d297b6d..e480092 100644 --- a/src/Time.savi +++ b/src/Time.savi @@ -84,7 +84,7 @@ :: DEPRECATED: Use `Time.Duration.nanoseconds` instead. :new nanoseconds(n U32): @total_seconds = 0 - while (@_nanoseconds_per_second < n) ( + while @_nanoseconds_per_second < n ( n -= @_nanoseconds_per_second @total_seconds += 1 ) @@ -197,21 +197,21 @@ total_days -= num400 * @_days_per_400_years num100 U64 = total_days / @_days_per_100_years // TODO: shouldn't need an explicit U64 here - if (num100 == 4) (num100 = 3) // account for leap years + if num100 == 4 (num100 = 3) // account for leap years total_days -= num100 * @_days_per_100_years num4 = total_days / @_days_per_4_years total_days -= num4 * @_days_per_4_years numyears U64 = total_days / 365 // TODO: shouldn't need an explicit U64 here - if (numyears == 4) (numyears = 3) // account for leap years + if numyears == 4 (numyears = 3) // account for leap years total_days -= numyears * 365 year = (num400 * 400 + num100 * 100 + num4 * 4 + numyears + 1).u32 month U8 = 0 days_in_month U64 = 0 - while (total_days >= days_in_month) ( + while total_days >= days_in_month ( total_days -= days_in_month month += 1 days_in_month = @_days_in_month(month, year).u64 @@ -249,12 +249,12 @@ :: by the given year, month, and day in the proleptic Gregorian calendar. :fun non _absolute_days(year U32, month U8, day U8) U64 // Normalize the month index, treating months beyond 12 as additional years. - while (month > 12) (year += 1, month -= 12) + while month > 12 (year += 1, month -= 12) // Calculate the number of days since day 1 of the given year. days_since_jan_1 = day.u64 - 1 scan_month U8 = 1 - while (scan_month < month) ( + while scan_month < month ( days_since_jan_1 += @_days_in_month(scan_month, year).u64 scan_month += 1 ) @@ -274,7 +274,7 @@ total_days -= num400 * @_days_per_400_years num100 U64 = (total_days / @_days_per_100_years) - if (num100 == 4) (// leap + if num100 == 4 (// leap num100 = 3 ) total_days -= num100 * @_days_per_100_years @@ -283,7 +283,7 @@ total_days -= num4 * @_days_per_4_years numyears = (total_days / 365) - if (numyears == 4) (// leap + if numyears == 4 (// leap numyears = 3 ) total_days -= numyears * 365 @@ -297,7 +297,7 @@ try ( while True ( days_in_month = @_days_in_month(month.u8, year.u32).u64 - if (total_days < days_in_month) ( + if total_days < days_in_month ( error! // TODO use break ) @@ -329,7 +329,7 @@ // previous year and the first Monday is actually in week 2. week_number = ((day_year - day_of_week.u64 + 10) / 7).u64 - if (week_number == 0) ( + if week_number == 0 ( // Week number 0 means the date belongs to the last week of the previous year. year -= 1 @@ -339,18 +339,18 @@ // year and January 1 is on a Saturday. jan1_day_of_week = Time.DayOfWeek.from_value(((day_of_week.u64 - day_year + 1) % 7).u8) - if ((jan1_day_of_week == Time.DayOfWeek.Friday) || (jan1_day_of_week == Time.DayOfWeek.Saturday && @_is_leap_year(year.u32))) ( + if (jan1_day_of_week == Time.DayOfWeek.Friday) || (jan1_day_of_week == Time.DayOfWeek.Saturday && @_is_leap_year(year.u32)) ( week_number = 53 | week_number = 52 ) | - if (week_number == 53) ( + if week_number == 53 ( // Week number 53 is actually week number 1 of the following year, if // December 31 is on a Monday, Tuesday or Wednesday. dec31_day_of_week = (day_of_week.u64 + 31 - day) % 7 - if (dec31_day_of_week <= Time.DayOfWeek.Wednesday.u64) ( + if dec31_day_of_week <= Time.DayOfWeek.Wednesday.u64 ( year += 1 week_number = 1 ) diff --git a/src/_FFI.savi b/src/_FFI.savi index 75df705..3fc4fcf 100644 --- a/src/_FFI.savi +++ b/src/_FFI.savi @@ -20,7 +20,7 @@ :: Wrapper for C functions used to get subsecond values on Windows. :fun windows_subseconds(factor U64) freq = @_windows_perf_freq - if (freq <= factor) ( + if freq <= factor ( @_windows_perf_counter * (factor / freq) | (@_windows_perf_counter * factor) / freq