You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1KB

  1. @interface UIDateLabel : UILabel
  2. @property (nonatomic, strong) NSDate *date;
  3. @end
  4. static bool is24h;
  5. %hook CKConversationListCell
  6. -(void)layoutSubviews{
  7. %orig;
  8. if(MSHookIvar<UIDateLabel *>(self, "_dateLabel")){
  9. UIDateLabel *dateLabel = MSHookIvar<UIDateLabel *>(self, "_dateLabel");
  10. if(![dateLabel.text containsString:@":"]){
  11. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  12. if(is24h){
  13. [dateFormatter setDateFormat:@" • HH:mm"];
  14. }else{
  15. [dateFormatter setDateFormat:@" • h:mm a"];
  16. }
  17. dateLabel.text = [dateLabel.text stringByAppendingString:[dateFormatter stringFromDate:dateLabel.date]];
  18. }
  19. }
  20. }
  21. %end
  22. %ctor{
  23. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  24. [formatter setLocale:[NSLocale currentLocale]];
  25. [formatter setDateStyle:NSDateFormatterNoStyle];
  26. [formatter setTimeStyle:NSDateFormatterShortStyle];
  27. NSString *dateString = [formatter stringFromDate:[NSDate date]];
  28. NSRange amRange = [dateString rangeOfString:[formatter AMSymbol]];
  29. NSRange pmRange = [dateString rangeOfString:[formatter PMSymbol]];
  30. is24h = (amRange.location == NSNotFound && pmRange.location == NSNotFound);
  31. }