Coder Social home page Coder Social logo

serhiicho / ago Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 2.0 213 KB

Converts given date into a nice readable format. Supports multiple languages. Example will be "1 hour ago", "2 days ago", "1 second ago", "Online" and so on.

Home Page: https://serhiicho.github.io/ago-docs/

License: MIT License

PHP 100.00%
datetime time converts timeago converter php package

ago's Introduction

Ago package

Ago Total Downloads PHP Version Require License

Date/time converter into "n time ago" format that supports multiple languages, such as ๐Ÿ‡ท๐Ÿ‡บ ๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿ‡ณ๐Ÿ‡ฑ ๐Ÿ‡บ๐Ÿ‡ฆ ๐Ÿ‡ฉ๐Ÿ‡ช. You can contribute any language that you wish easily by creating a pull request. When new PHP version comes out, this package will be updated to support it as soon as possible.

This package is well tested, optimized and already used in many production apps. It has shown itself pretty well. If you find any issues or bugs ๐Ÿž, please create an issue, and I'll fix it as soon as I can.

Follow the official documentation for more information

๐Ÿš€ Quick Start

composer require serhii/ago

License

The Ago project is licensed under the MIT License

ago's People

Contributors

serhiicho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

awojtczyk exbbxak

ago's Issues

Changed string options

Instead of passing array of string options it has to be constant variables. If you pass 1 variable then you don't need to wrap it in array

TimeAgo::trans($date, NO_SUFFIX)
TimeAgo::trans($date, [NO_SUFFIX, UPCOMMING])

Add ability for trans() method to except different types of arguments

TimeAgo::trans() excepts only string as the first argument. Add ability for trans() method to except timestamp, DateTime object, Carbon and CarbonImmutable.

TimeAgo::trans('now - 10 seconds'); // output: 10 seconds ago
TimeAgo::trans(new DateTime('now - 1 day')); // output should be: 1 day ago
TimeAgo::trans(time()); // output should be: 0 seconds ago
TimeAgo::trans(CarbonImmutable::now()); // output should be: 0 seconds ago
TimeAgo::trans(Carbon::now()); // output should be: 0 seconds ago

Make easy way to add new language

Make that if you want to make add new language, all you need is to add single file to lang directory with all translations without changing anything else.

๐Ÿ‡ฎ๐Ÿ‡ณ Contribute translation to Indian language

Intro

Indian language is very popular in programming world because there are countless developers out there and many applications written in PHP programming language. I want to add Indian language support for this package, but I don't have a knowledge of Indian.

Todo

If you are a software developer who knows language PHP and you want to contribute to Open source, feel free to add Indian language support for this ago package. Here is the ๐Ÿ“„ documentation for contributing a translation. Please follow the instructions there.

If there is anything you don't understand in ๐Ÿ“„ CONTRINUTE.md guide, or it lacks of information, let me know, and I'll make sure to add more detailed information.

๐Ÿ‡ณ๐Ÿ‡ฑ Contribute translation to Dutch language

Intro

Dutch language is very popular in programming world because there are many developers out there and many applications written in PHP programming language. I want to add Dutch language support for this package, but I don't have a knowledge of Dutch.

Todo

If you are a software developer who knows language PHP and you want to contribute to Open source, feel free to add Dutch language support for this ago package. Here is the ๐Ÿ“„ documentation for contributing a translation. Please follow the instructions there.

๐Ÿ‡จ๐Ÿ‡ณ Contribute translation to Chinese language

Intro

Chinese language is very popular in programming world because there are countless developers out there and many applications written in PHP programming language. I want to add Chinese language support for this package, but I don't have a knowledge of Chinese.

Todo

If you are a software developer who knows language PHP and you would like to contribute to Open source, feel free to add Chinese language support for this ago package. Here is the ๐Ÿ“„ documentation for contributing a translation. Please follow the instructions there.

If there is anything you don't understand in ๐Ÿ“„ CONTRINUTE.md guide, or it lacks of information, let me know, and I'll make sure to add more detailed information.

Make trans() function more flexible

Currently, if you pass the past date to the trans() function, it will return date in x time ago format. If you pass the date from future, it will return 0 seconds ago.

We need to change that behavior in the next version, so that instead of 0 seconds ago it will return interval to that given date. For example, if now is 1 January 2023, and we pass the date 1 January 2024, it should return 1 year. So basically, we need to deprecate the option Option::UPCOMING and make it as a default behavior if you passed a future date.

It will be a nice improvement because before you had to give a Option::UPCOMING flag, but after the update the program will check if the given date is a future date, then use Option::UPCOMING. If the date is in the past, don't use the flag UPCOMING.

This functionality will allows us to use it for showing future dates. One case can be if you need to show how long is to wait to a certain event in the future.

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.