Skip to content

Commit

Permalink
fix: format & info (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-jerry-ye authored Aug 8, 2024
1 parent 81b8871 commit 3e65272
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
11 changes: 6 additions & 5 deletions crypto/sha1.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ pub fn sha1(input : Bytes) -> Bytes {
let words = FixedArray::make(80, 0)
for i = 0; i < 16; i = i + 1 {
let slice_start = chunk * bytes_per_chunk + i * 4
words[i] = bytes[slice_start].to_int().lsl(24).lor(
bytes[slice_start + 1].to_int().lsl(16),
).lor(bytes[slice_start + 2].to_int().lsl(8)).lor(
bytes[slice_start + 3].to_int(),
)
words[i] = bytes[slice_start]
.to_int()
.lsl(24)
.lor(bytes[slice_start + 1].to_int().lsl(16))
.lor(bytes[slice_start + 2].to_int().lsl(8))
.lor(bytes[slice_start + 3].to_int())
}
for i = 16; i < 80; i = i + 1 {
words[i] = rotate_left(
Expand Down
4 changes: 1 addition & 3 deletions json5/json5.mbti
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package moonbitlang/x/json5

alias @moonbitlang/core/json as @json

// Values
fn parse(String) -> @json.JsonValue!ParseError
fn parse(String) -> Json!ParseError

// Types and methods
type ParseError
Expand Down
6 changes: 3 additions & 3 deletions time/duration.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ pub fn to_string(self : Duration) -> String {
buf.write_string(secs.to_string())
if nanos > 0L {
buf.write_char('.')
let nanos_str = (nanos + nanoseconds_per_second).to_string().substring(
start=1,
)
let nanos_str = (nanos + nanoseconds_per_second)
.to_string()
.substring(start=1)
buf.write_string(remove_suffix_zero(nanos_str))
}
buf.write_char('S')
Expand Down
7 changes: 4 additions & 3 deletions time/period.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ pub fn add_period(self : Period, other : Period) -> Period!Error {
if other.is_zero() {
return self
}
self.add_years!(other.years()).add_months!(other.months()).add_days!(
other.days(),
)
self
.add_years!(other.years())
.add_months!(other.months())
.add_days!(other.days())
}

pub fn op_add(self : Period, other : Period) -> Period!Error {
Expand Down
6 changes: 3 additions & 3 deletions time/plain_date.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ pub fn add_days(self : PlainDate, days : Int64) -> PlainDate!Error {
/// Adds a period to this date, and returns a new date.
pub fn add_period(self : PlainDate, period : Period) -> PlainDate!Error {
let mut d = self
d = d.add_months!(period.to_total_months()).add_days!(
period.days().to_int64(),
)
d = d
.add_months!(period.to_total_months())
.add_days!(period.days().to_int64())
d
}

Expand Down
4 changes: 3 additions & 1 deletion time/plain_date_time.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ pub fn PlainDateTime::from_unix_second(

/// Converts this datetime to the elapsed seconds since the unix epoch.
pub fn to_unix_second(self : PlainDateTime) -> Int64 {
self.date.to_unix_day() * seconds_per_day + self.time.second_of_day().to_int64()
self.date.to_unix_day() * seconds_per_day + self.time
.second_of_day()
.to_int64()
}

/// Creates a PlainTime from a string, like '2008-08-08T20:00:00'.
Expand Down
6 changes: 3 additions & 3 deletions time/plain_time.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ pub fn PlainTime::to_string(self : PlainTime) -> String {
buf.write_string(add_prefix_zero(self.second.to_string(), 2))
if self.nanosecond > 0 {
buf.write_char('.')
let nanos_str = (self.nanosecond.to_int64() + nanoseconds_per_second).to_string().substring(
start=1,
)
let nanos_str = (self.nanosecond.to_int64() + nanoseconds_per_second)
.to_string()
.substring(start=1)
buf.write_string(remove_suffix_zero(nanos_str))
}
buf.to_string()
Expand Down
6 changes: 3 additions & 3 deletions uuid/uuid.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ pub fn from_hex(hex : String) -> UUID!Error {
}
}

let hex_table : Array[Int] = "0123456789abcdef".to_array().map(
fn { c => c.to_int() },
)
let hex_table : Array[Int] = "0123456789abcdef"
.to_array()
.map(fn { c => c.to_int() })

let dash : Int = '-'.to_int()

Expand Down

0 comments on commit 3e65272

Please sign in to comment.