Download the PHP package phpnomad/chrono without Composer

On this page you can find all versions of the php package phpnomad/chrono. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package chrono

PHPNomad Chrono

Time-related strategy interfaces for PHPNomad. A catalog of narrow capabilities that integration packages implement against any underlying time library — PSR-20, Carbon, Tokei, lcobucci/clock, symfony/clock, WordPress core, native PHP — so consumers can compose time-handling capabilities across libraries without touching call sites.

This package ships interfaces only. Pair it with one or more integration packages — for example phpnomad/wordpress-integration, which binds WordPress's current_datetime(), wp_timezone(), wp_date(), and human_time_diff() to the appropriate interfaces.

Requirements

PHP 8.2 or newer.

Installation

You will also need at least one concrete ClockStrategy binding. On WordPress, install phpnomad/wordpress-integration and the wiring is automatic. Elsewhere, bind any PSR-20 ClockInterface implementation (e.g. lcobucci/clock or symfony/clock) to ClockStrategy in your composition root.

Usage

Inject the capabilities you need. A consumer that does not care about formatting or arithmetic depends on ClockStrategy alone:

In tests, bind a frozen ClockStrategy and a stub CanCheckIfPast:

Catalog

Each interface is narrow — one or a few related methods — so integrators can implement whatever subset their underlying library naturally covers. A single concrete class can implement many interfaces.

Clock and provider state

Interface Method Notes
ClockStrategy now(): DateTimeImmutable Extends Psr\Clock\ClockInterface
HasTimezone getTimezone(): DateTimeZone Platform's configured timezone
HasLocale getLocale(): string Platform's configured locale (BCP 47 / POSIX style)

Predicates on a single instant

Interface Method
CanCheckIfPast isPast(DateTimeImmutable $instant): bool
CanCheckIfFuture isFuture(DateTimeImmutable $instant): bool
CanCheckIfWeekend isWeekend(DateTimeImmutable $instant): bool
CanCheckIfWeekday isWeekday(DateTimeImmutable $instant): bool

Predicates on two instants

Interface Method
CanCheckSameDay isSameDay(DateTimeImmutable $a, DateTimeImmutable $b): bool
CanCheckSameMonth isSameMonth(DateTimeImmutable $a, DateTimeImmutable $b): bool
CanCheckSameYear isSameYear(DateTimeImmutable $a, DateTimeImmutable $b): bool
CanCheckBetween isBetween(DateTimeImmutable $i, DateTimeImmutable $start, DateTimeImmutable $end): bool

Arithmetic

Interface Method
CanApplyModifier apply(DateTimeImmutable $instant, string $modifier): DateTimeImmutable
CanAddInterval add(DateTimeImmutable $instant, DateInterval $interval): DateTimeImmutable
CanSubtractInterval subtract(DateTimeImmutable $instant, DateInterval $interval): DateTimeImmutable

Calendar boundaries

Interface Method
CanGetStartOfDay startOfDay(DateTimeImmutable $instant): DateTimeImmutable
CanGetEndOfDay endOfDay(DateTimeImmutable $instant): DateTimeImmutable
CanGetStartOfMonth startOfMonth(DateTimeImmutable $instant): DateTimeImmutable
CanGetEndOfMonth endOfMonth(DateTimeImmutable $instant): DateTimeImmutable
CanGetStartOfYear startOfYear(DateTimeImmutable $instant): DateTimeImmutable
CanGetEndOfYear endOfYear(DateTimeImmutable $instant): DateTimeImmutable

Difference and duration

Interface Method
CanGetDifference diff(DateTimeImmutable $a, DateTimeImmutable $b): DateInterval
CanGetDifferenceInDays diffInDays(DateTimeImmutable $a, DateTimeImmutable $b): int
CanGetDifferenceInHours diffInHours(DateTimeImmutable $a, DateTimeImmutable $b): int
CanGetDifferenceInMinutes diffInMinutes(DateTimeImmutable $a, DateTimeImmutable $b): int
CanGetDifferenceInSeconds diffInSeconds(DateTimeImmutable $a, DateTimeImmutable $b): int

Parsing

Interface Method
CanParseDate parse(string $expression): DateTimeImmutable
CanParseDateWithFormat parseFormat(string $expression, string $format): DateTimeImmutable

Formatting

Interface Method
CanFormatDate format(DateTimeImmutable $instant, string $format): string
CanFormatLocalizedDate formatLocalized(DateTimeImmutable $instant, string $format): string
CanFormatRelativeTime relative(DateTimeImmutable $instant): string ("3 hours ago")

Model contracts

These two are model-side contracts for persisted records — every PHPNomad model that participates in audit trails implements them.

Interface Method
HasCreatedDate getCreatedDate(): DateTimeImmutable
HasModifiedDate getModifiedDate(): DateTimeImmutable

How integrations compose the catalog

An integration package ships one or more concrete classes that implement the cluster of interfaces its underlying library can naturally fulfill. phpnomad/wordpress-integration ships a class implementing the WordPress-specific subset:

A hypothetical phpnomad/carbon-integration would ship a class implementing the much broader Carbon-backed cluster (predicates, arithmetic, boundaries, diff, parsing, formatting). A consumer that needs WordPress's timezone alongside Carbon's diff math binds each interface to the appropriate concrete.

Why a catalog of narrow interfaces

A single fat TimeStrategy interface would force every integrator to implement methods their underlying library does not naturally support. A catalog of narrow interfaces lets integrators declare exactly what their library covers, and lets consumers depend only on the capabilities they use. Integrations declare PHPNomad support by implementing the relevant interfaces; consumers compose multiple integrations across libraries as needed.

License

MIT


All versions of chrono with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
psr/clock Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package phpnomad/chrono contains the following files

Loading the files please wait ...