watson/colortime

此包已被弃用且不再维护。未建议替换包。

将时间看作颜色。

1.0.0 2015-09-25 01:50 UTC

This package is auto-updated.

Last update: 2020-12-17 10:04:15 UTC


README

Build Status Dependency Status Total Downloads Latest Stable Version Latest Unstable Version License

获取时间作为十六进制颜色,例如 颜色时钟

例如,上午 10:10:10 将有十六进制值 #101010。

安装

简单,使用 Composer!如果你还没有被依赖管理所启发或者喜欢挑战,请手动复制代码。

composer require "watson/colortime"

使用

创建一个新实例,传入你想要使用的 DateTime 实例,或者使用工厂获取当前时间的实例。

// Using a specific time.
$datTime = DateTime::createFromFormat('H:i:s', '10:10:10');

$colorTime = new \Watson\ColorTime\ColorTime($dateTime);

// Using the current time (you could also pass a DateTime instance to the factory if you so desired).
$colorTime = \Watson\ColorTime\ColorTime::make();

要获取时间的十六进制值,只需调用 hex() 方法。

$hex = $colorTime->hex(); // '#101010'

拼写检查

如果你更喜欢正确拼写颜色,只需将 ColorTime 实例子类化到你的应用程序中,并使用它代替。

这只是一个玩笑,不要这样做。除非你想,在这种情况下,请随意。

class ColourTime extends \Watson\ColorTime\ColorTime {}