Ask HN: Library that maps clock times to human terms ("early morning", etc.)?
natural language processingtime representationweather forecasting
Ask HN: Library that maps clock times to human terms ("early morning", etc.)?
Synthesized Answer
Based on 2 community responses
While there may not be a specific library that directly maps clock times to human terms, you can achieve this by using a combination of existing libraries and custom rules. For instance, you can use a date/time library like Moment.js or dateutil to handle time-related operations. To map times to human-readable terms, you can define a set of rules based on the hour of the day. For example, you can consider 6-11 AM as 'morning', 12-4 PM as 'afternoon', and so on. You can also use natural language processing (NLP) libraries to generate more human-like descriptions.
Key Takeaways
Use a date/time library to handle time operations
Define custom rules to map times to human-readable terms
Consider using NLP libraries for more human-like descriptions
There are probably several libraries that offer this functionality, the question is just what your other requirements are. It is also built into most modern web browsers, just check out the MDN for Intl.DateTimeFormat with the dayPeriod option [1].