Esqarrouth/EZSwiftExtensions

Localization support for the timePassed method on DateExtensions.swift

jaja-digitalspaceexplorer opened this issue · 7 comments

Localization support for the timePassed method on DateExtensions.swift

The concept of time passed is relative. For instance if I live in the United States, and it passed 5 seconds for me, the method would return 5 seconds. For someone in India, if it passes 5 seconds for them, it still records 5 seconds.

I am unsure as to what your requirement here is. Could you give some examples of intended behavior?

I could update the calendar to be auto updating, but i do not see why locales should be passed as an arg here.

I apologize for not clarifying this. I meant to say was, if we could add localization support to the units of time returned by the timePassed method. I have something on my mind right now, which is to return an enum instead of string.

Sample Snippet

enum TimePassed { case year(Int) case month(Int) case day(Int) case hour(Int) case minute(Int) case second(Int) }

Returning this type of enum would force the consumer of this method to read the value returned, localize and pluralize it to their needs. This solution also removes our obligation to produce localization for each languages.

I like to hear your opinion about this.

Thanks!

@jaja-digitalspaceexplorer I am all for inventing a completely new extension method with this enum as a return type, but i cannot break backwards compatibility by changing the return type signature of the existing timePassed method.

@Khalian I'll make sure it's still backwards compatible with the existing consumers of the extension method.

Referencing #486

@Khalian This issue can now be closed, because the #486 solves this. Thanks!