Coder Social home page Coder Social logo

Comments (4)

andrewroycarter avatar andrewroycarter commented on July 26, 2024

I'll look into this!
I'm not super informed when it comes to time localization, so if someone wants to contribute on this one quicker then me feel free!

from timescroller.

honkmaster avatar honkmaster commented on July 26, 2024

Im doing it this way.

if (dateComponents.year == todayComponents.year && dateComponents.month == todayComponents.month && dateComponents.day == todayComponents.day) {

    timeLabelFrame = CGRectMake(30.0f, 4.0f, 100.0f, 20.0f);
    dateLabelString = @"";
    dateLabelAlpha = 0.0f;

} else if ((dateComponents.year == todayComponents.year) && (dateComponents.month == todayComponents.month) && (dateComponents.day == todayComponents.day - 1)) {

    timeLabelFrame = CGRectMake(30.0f, 4.0f, 100.0f, 10.0f);
    dateLabelString = NSLocalizedString(@"Yesterday", @"Yesterday");
    dateLabelAlpha = 1.0f;

} else if ((dateComponents.year == todayComponents.year) && (dateComponents.weekOfYear == todayComponents.weekOfYear)) {

    timeLabelFrame = CGRectMake(30.0f, 4.0f, 100.0f, 10.0f);                
    dateLabelString = [self.dayOfWeekDateFormatter stringFromDate:date];
    dateLabelAlpha = 1.0f;

} else if (dateComponents.year == todayComponents.year) {

    timeLabelFrame = CGRectMake(30.0f, 4.0f, 100.0f, 10.0f);

    dateLabelString = [self.monthDayDateFormatter stringFromDate:date];
    dateLabelAlpha = 1.0f;

} else {

    timeLabelFrame = CGRectMake(30.0f, 4.0f, 100.0f, 10.0f);
    dateLabelString = [self.monthDayYearDateFormatter stringFromDate:date];
    dateLabelAlpha = 1.0f;

} 

CGFloat timeWidth = [timeLabelString sizeWithFont:_timeLabel.font].width;
CGFloat dateWidth = [dateLabelString sizeWithFont:_dateLabel.font].width;
CGFloat width = ( timeWidth > dateWidth ? timeWidth : dateWidth) + 40.0f;
backgroundFrame = CGRectMake(CGRectGetWidth(self.frame) - width, 0.0f, width, CGRectGetHeight(self.frame));

from timescroller.

andrewroycarter avatar andrewroycarter commented on July 26, 2024

@honkmaster It's been a while, but if you'd like to submit those changes as a pull request I'd be happy to check them out and merge them in! I've recently changed up the project a bit, but it's nothing that shouldn't take more than a few minutes to sync up with!

from timescroller.

honkmaster avatar honkmaster commented on July 26, 2024

I will see what i can do and submit a pull request in the next days,

from timescroller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.