Alphred
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • Alphred
  • None

Classes

  • Alfred
  • AppleScript
  • Choose
  • Config
  • Date
  • Dialog
  • Filter
  • Globals
  • i18n
  • Ini
  • Keychain
  • Log
  • Notification
  • Request
  • Result
  • ScriptFilter
  • Text

Interfaces

  • ConfigKeyNotSet
  • Exception
  • FileDoesNotExist
  • InvalidKeychainAccount
  • InvalidScriptFilterArgument
  • InvalidSecurityAction
  • InvalidXMLProperty
  • PasswordExists
  • PasswordNotFound
  • PluginFunctionNotFound
  • RunningOutsideOfAlfred
  • ShouldBeBool
  • TooManyArguments
  • UnknownSecurityException
  • UseOnlyAsStatic

Class Date

Provides text filters for date objects

This class should be cleaned up quite a bit, and it needs to be made pluggable so that it can be used by languages other than English. But, I think right now it is good enough to be released because it falls into "special sauce" rather than necessary functionality.

Namespace: Alphred
Todo: Abstract the time dictionaries so that they can be translated
Todo: Add in a less precise version of "seconds to human time"
Todo: Make these work with dates before Jan 1, 1970
Located at Date.php

Methods summary

private array
# diff_a_date( integer $date1, integer $date2 )

Returns a slightly modified array of the difference between two dates

Returns a slightly modified array of the difference between two dates

Parameters

$date1
a date in seconds
$date2
a date in seconds

Returns

array
an array that represents the difference in granular units

Since

1.0.0

Todo

Fix for values before Jan 1, 1970
public string
# fuzzy_ago( integer $seconds, string $dictionary = 'english' )

Converts a time diff into a human readable approximation

Converts a time diff into a human readable approximation

Parameters

$seconds
a date represented in seconds since the unix epoch
$dictionary
what language to use (currently unsupported and ignored)

Returns

string
a fuzzy time

Since

1.0.0

Todo

Fix for values before Jan 1, 1970
make available for non-English languages
public string|array
# seconds_to_human_time( integer $seconds, boolean $words = false, string $type = 'string' )

Converts seconds to a human readable string or an array

Converts seconds to a human readable string or an array

Parameters

$seconds
a number of seconds
$words
whether or not the numbers should be numerals or words
$type
either 'string' or 'array'

Returns

string|array
a string or an array, depending on $type
public string
# ago( integer $seconds, boolean $words = false )

Explains how long ago something happened...

Explains how long ago something happened...

This also works with the future.

Parameters

$seconds
a number of seconds
$words
whether or not to return numerals or the word-equivalent

Returns

string
a string indicating a time in words

Since

1.0.0

Todo

Make this work with values before 1 Jan, 1970
public string
# convert_number_to_words( integer $number, $dictionary = 'english' )

Converts a number to words

Converts a number to words

Parameters

$number
a number
$dictionary

Returns

string
the number, but, as words

Todo

Add in an option for a shorter version...
Add in translation options so that we don't support only English

Magic methods summary

Properties summary

private static array $legend_english
# [ 'millenium' => [ 'multiple' => 'millenia', 'value' => 31536000000 ], 'century' => [ 'multiple' => 'centuries', 'value' => 3153600000 ], 'decade' => [ 'multiple' => 'decades', 'value' => 315360000 ], 'year' => [ 'multiple' => 'years', 'value' => 31536000 ], 'month' => [ 'multiple' => 'months', 'value' => 2592000 ], 'week' => [ 'multiple' => 'weeks', 'value' => 604800 ], 'day' => [ 'multiple' => 'days', 'value' => 86400 ], 'hour' => [ 'multiple' => 'hours', 'value' => 3600 ], 'minute' => [ 'multiple' => 'minutes', 'value' => 60 ], 'second' => [ 'multiple' => 'seconds', 'value' => 1 ] ]
Alphred API documentation generated by ApiGen