➤➤➤网站首页 > 更新日志 > >

logo
推荐软件

[微信聊天时间随意改]防微信聊天时间生成

作者:admin
来源:www.pptvwang.com
时间:2020-10-17 点击:

微信聊天时间随意改

  #import

  ChatTimeUtil : NSObject

   (NSString *)showDate:(NSDate *)date upDate:(NSDate *)a;

  //nsstring 转 nsdate

   (NSDate *)dateFromString:(NSString *)dateString format:(NSString *)format;

   (NSString *)stringFromDate:(NSDate *)date format:(NSString *)format;

  //

  //? ChatTimeUtil.m

  //? Test1111

  //

  //? Created by victor-lee on 14-12-11.

  //? Copyright (c) 今年 自由者. All rights reserved.

  //

  #import "ChatTimeUtil.h"

  ChatTimeUtil()

  @implementation ChatTimeUtil

  //假如一个方式中,必须外界自变量时,并且这一自变量有生命期时,就不能用工具类.

   (NSString *)showDate:(NSDate *)date upDate:(NSDate *)a{

  ? NSDate *tmpDate =[[NSDate alloc] initWithTimeIntervalSinceReferenceDate:([a timeIntervalSinceReferenceDate] 5*60)];

  ? if([tmpDate earlierDate:date] == tmpDate){

  ? if([self isToday:date]){

  ? return? [ChatTimeUtil stringFromDate:date format:@"HH:mm"];

  ? }else{

  ? return? [self returnDate:date];

  ? }

  ? }else{

  ? return nil;

  ? }

  }

  //nsstring 转 nsdate

   (NSDate *)dateFromString:(NSString *)dateString format:(NSString *)format{

  ? NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

  ? [dateFormatter setDateFormat: format];

  ? NSDate *destDate= [dateFormatter dateFromString:dateString];

  ? return destDate;

  }

  //nsdate 转 nsstring

   (NSString *)stringFromDate:(NSDate *)date format:(NSString *)format{

  ? NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

  ? [dateFormatter setDateFormat:format];

  ? return [dateFormatter stringFromDate:date];

   ?

  }

  //假如时间是一星期内,便回到礼拜N,如果是一星期前就回到中间的时间

   (NSString *)returnDate:(NSDate *)d{

  ? NSDate *tmpDate =[[NSDate alloc] initWithTimeIntervalSinceReferenceDate:([[NSDate date] timeIntervalSinceReferenceDate] - 7*24*60*60)];

   ?

  ? if([tmpDate earlierDate:d] == tmpDate){

   ?

  ? NSDateComponents *componets = [[NSCalendar autoupdatingCurrentCalendar] components:NSWeekdayCalendarUnit fromDate:d];

  ? ;

   ?

  ? return [ NSString stringWithFormat:@"%@ %@",[self getWeek:[componets weekday]-1],[ChatTimeUtil stringFromDate:d format:@"HH:mm"]] ;

  ? }else{

  ? return [ChatTimeUtil stringFromDate:d format:@"yyyy-MM-dd HH:mm:ss"];

  ? }

   ?

  }

  //分辨是不是今日


  • 上一篇:[微信生成聊天记录文件]如何将微信聊天记录导出成文档形式
  • 下一篇:[微信聊天p图更改聊天记录]有一个软件可以p图p成微信聊天界面,叫什么?急求! 微信聊天记录修改器是什么?
  • 大家还在看

    网站地图 | 关于网站 | 

    Copyright © 2015-2019 www.pptvwang.com All Rights Reserved