Skip to content

Instantly share code, notes, and snippets.

@Bandd-k
Created October 7, 2017 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bandd-k/e7a9fc8d1c198a9f25b167de8c075335 to your computer and use it in GitHub Desktop.
Save Bandd-k/e7a9fc8d1c198a9f25b167de8c075335 to your computer and use it in GitHub Desktop.
var date:Date?{
didSet{
if(date != nil && (messageLabel.text != nil) ){
let currentDate = Date()
let formatter = DateFormatter()
formatter.dateStyle = .medium
formatter.timeStyle = .none
if(formatter.string(from: date!) != formatter.string(from: currentDate)){
timeLabel.text = "\(formatter.string(from: date!))"
}
else{
formatter.dateStyle = .none
formatter.timeStyle = .short
timeLabel.text = "\(formatter.string(from: date!))"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment