Skip to content

Instantly share code, notes, and snippets.

@GUIEEN
Last active January 25, 2022 06:40
Show Gist options
  • Save GUIEEN/0693b6009e79c882e55c5b15fc13cbeb to your computer and use it in GitHub Desktop.
Save GUIEEN/0693b6009e79c882e55c5b15fc13cbeb to your computer and use it in GitHub Desktop.
log with time #swift #time #logWithTime
import Foundation
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS "
func log_with_time(_ items: Any...) {
print(formatter.string(from: Date()), terminator: "")
for idx in items.indices {
print(items[idx], terminator: idx == items.count-1 ? "\n" : " ")
}
}
public func quadrantOf(x: Int, y: Int) -> String {
var quadrant = ""
switch (x, y) {
case (1..., 1...):
quadrant = "1"
case (..<0, 1...):
quadrant = "2"
case (..<0, ..<0):
quadrant = "3"
case (1..., ..<0):
quadrant = "4"
default:
quadrant = "boundary"
}
return quadrant
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment