Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing relative and non-relative format for different time components #164

Closed
andriichernenko opened this issue Feb 22, 2016 · 4 comments
Closed

Comments

@andriichernenko
Copy link

I need dates formatted the following way:
"yesterday 3:25 AM"
"today 4:00 PM"
"tomorrow 10:00 PM"
"3 days ago 10:00 PM"

I am not sure this is possible with SwiftDate 3.0.2 I am using (though I must admit I might not have understood something, there seem to be so many parameters). Here is what I tried:

screen shot 2016-02-22 at 10 40 00

date.toString(.ShortStyle, relative: true) is the closest to what I need, but not quite it. I need more control over the resulting string. For instance, I would like to be able to control capitalization, or get rid of comma, or output "yest" instead of "yesterday".

Deprecation note for toRelativeString() method says I should "Use toNaturalString() with relative parameters". However, I can't seem to figure out how to do this. FormatterStyle struct, which is supposed to be used for configuration, does not expose any parameters to configure relative formatting.

Also, there is Issue #79, toComponentsStrings might be of help, but it is not included in 3.0.2.

@malcommac
Copy link
Owner

I'm working on a new implementation. I'll post more infos during this week.

@Hout
Copy link
Contributor

Hout commented Feb 22, 2016

Do you have any specs yet so I can write the test code?

@malcommac
Copy link
Owner

Yup I'll post specs before weekend (hope later today)

@malcommac
Copy link
Owner

I'll close this. Now we have an initial implementation; we can continue here: #168
I've posted specs about the class and the implementation. We can start working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants