naoty / Timepiece

Intuitive date handling in Swift
MIT License
2.63k stars 147 forks source link

Just an idea: Parallel APIs for non-English languages #14

Closed willhains closed 9 years ago

willhains commented 9 years ago

I find this style of natural-language API exciting, when it is executed well, as it is in this case. Great stuff!

While browsing the API intro, I had random thought: while this API is very natural to English-language speakers — and it seems aimed directly at "sounding" like natural English — wouldn't it make equal sense to add similar APIs for other human languages?

For example:

let 今 = NSDate() // now
let 来週 = 今 + 1.週間 // next week
let 明後日 = 今 + 2.日間 // day after tomorrow

// shortcuts #1
let 今日 = NSDate.今日() // today
let 明日 = NSDate.明日() // tomorrow
let 昨日 = NSDate.昨日() // yesterday

// shortcuts #2
let 一昨日 = 2.日.前 // day before yesterday
let 東京オリンピックの年 = 5.年.後 // year of Tokyo Olympics

I chose Japanese above as a deliberately extreme example, but it fits almost perfectly as a natural-sounding API. (The only rough edge being that English implies "duration" when you say "2 days", but in Japanese it's explicit — "2日" is not the same as "2日間". But I think this could be easily covered by a small number of redirecting functions.)

kazmasaurus commented 9 years ago

:heart: this idea so much.

naoty commented 9 years ago

@willhains Since I'm Japanese, I agree with you. But, I want to provide these features as another library because these are a kind of localization features, not the calculation of dates.

willhains commented 9 years ago

@naoty That makes sense.

willhains commented 9 years ago

@kazmasaurus Not sure why you edited your comment, because it was spot-on! Thanks very much for the kind words.

naoty commented 9 years ago

@willhains I don't have enough time to develop these features as another library. If you want them, please develop yourself.