Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Create master branch via GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
meysampg authored Sep 7, 2016
1 parent e25543c commit 916b5da
Show file tree
Hide file tree
Showing 7 changed files with 945 additions and 0 deletions.
Binary file added images/arrow-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/octocat-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
372 changes: 372 additions & 0 deletions index.html

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions javascripts/scale.fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
fixScale = function(doc) {

var addEvent = 'addEventListener',
type = 'gesturestart',
qsa = 'querySelectorAll',
scales = [1, 1],
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];

function fix() {
meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
doc.removeEventListener(type, fix, true);
}

if ((meta = meta[meta.length - 1]) && addEvent in doc) {
fix();
scales = [.25, 1.6];
doc[addEvent](type, fix, true);
}

};
6 changes: 6 additions & 0 deletions params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Intldate",
"tagline": "A small php library for date converting between multiple calendar",
"body": "Intl. Date\r\n==========\r\nPHP Library for Converting Date to Multiple Calendars\r\n\r\nInstallation\r\n------------\r\n\r\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\r\n\r\nEither run\r\n\r\n```bash\r\ncomposer require --prefer-dist meysampg/intldate \"*\"\r\n```\r\n\r\nor add\r\n\r\n```json\r\n\"meysampg/intldate\": \"*\"\r\n```\r\n\r\nto the require section of your `composer.json` file.\r\n\r\nAlso easily you can [Download](https://github.com/meysampg/intldate/archive/master.zip) and use it.\r\n\r\nUsage\r\n-----\r\n\r\nOnce the library is installed, simply use it in your php file:\r\n\r\n```php\r\nuse meysampg\\intldate\\IntlDateTrait;\r\n```\r\nand use it on your desired class:\r\n\r\n```php\r\n<?php\r\n\r\nnamespace foo\\bar;\r\n\r\nuse meysampg\\intldate\\IntlDateTrait;\r\n\r\nclass Bar\r\n{\r\n use IntlDateTrait;\r\n // Some codes are here!\r\n \r\n echo $this->fromGregorian([2017, 9, 7, 12, 23, 45])->toPersian('en')->asDateTime();\r\n}\r\n```\r\n\r\nAnathomy\r\n--------\r\n\r\n`IntlDateTrait` has a simple logic for naming methods: \"A date starts from *origin* and ends to *final*. So all methods (setters and getters) that are related to incoming date are named by `setOriginXXXX` and `getOriginXXXX` (which `XXXX` shows a feature of time, like *timezone* or *locale*) and all methods that are corresponded to outgoing date are regarded as `setFinalXXXX` and `getFinalXXXX`. A list of available methods can be find in bottom of this document.\r\n\r\nConversion\r\n----------\r\nAt first I must note that incoming date must be an array in this form:\r\n\r\n```php\r\n[\r\n year, // 2016\r\n month, // 2\r\n day, // 23\r\n hour, // 12\r\n minute, // 23\r\n second // 4\r\n]\r\n```\r\nCurrently, the library **CAN'T** parse a string as time (See ToDo section), so before converting a date, you **MUST** parse it on a acceptable array (It can be done with `preg_match` or each tools that you know). Now you can easily use\r\n`IntlDateTrait::from($datetimeArray, $locale, $calendar)` for importing an incoming date and `IntlDateTrait::to($locale, $calendar)` for converting it to another system. We disccuesed about `$datetimeArray` in the first of this section, it's our date for converting on a accepted format. `$locale` is the regional information of a language. For example for The *English* it's `en`, for *Farsi* it's `fa`, for *Spanish* it's `es` and so on. You can find a complete list of them at [this link](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). And finally calendar is your desired date system. This library use the `Intl*` family of `php` and so you can use all supported calendar in `ICU` project. Now this calendars are supported:\r\n - persian\r\n - gregorian\r\n - japanese\r\n - buddhist\r\n - chinese\r\n - indian\r\n - islamic\r\n - hebrew\r\n - coptic\r\n - ethiopic\r\n\r\nIt's better to use their handler in code instead of using direct name. These handlers are:\r\n\r\n```php\r\n// Use them in `self::$CAL_CALENDAR, for example `$calendar = self::$CAL_HEBREW`.\r\n$CAL_PERSIAN\r\n$CAL_JAPANESE\r\n$CAL_BUDDHIST\r\n$CAL_CHINESE\r\n$CAL_INDIAN\r\n$CAL_ISLAMIC\r\n$CAL_HEBREW\r\n$CAL_COPTIC\r\n$CAL_ETHIOPIC\r\n$CAL_GREGORIAN\r\n```\r\n\r\nShortHands\r\n----------\r\nThere are some shorthands for converting dates in a painless way (Yeah! With all of my proud, I'm a **Lazy** man :D). This shorthands are formatted as `fromYyyy()` for incoming date function and `toZzzz()` for outgoing date function such that, `Yyyy` and `Zzzz` are the name of calendars. For incoming function, the signature is `fromYyyy($datetimeArray, $locale = 'en_US')` and for outgoing is `toZzzz($locale = 'fa')`. Use `$locale` in incoming function if you have non-latin digits and use it on outgoing function, if you wanna show the converted date by latin digits (Based on region of calendar, `$locales` are defined, for example the default locate of `Persian` calendar for outgoing function is `fa`). Shorthands are listed in table.\r\n\r\n| Incoming | Outgoing |\r\n|---------------|---------------|\r\n|fromPersian | toPersian |\r\n|fromJapanese |toJapanese |\r\n|fromBuddhist |toBuddhist |\r\n|fromChinese |toChinese |\r\n|fromIndian |toIndian |\r\n|fromIslamic |toIslamic |\r\n|fromHebrew |toHebrew |\r\n|fromCoptic |toCoptic |\r\n|fromEthiopic |toEthiopic |\r\n|fromGregorian |toGregorian |\r\n\r\nShowing Date\r\n------------\r\nThere are two functions for showing converted dates. The first is `asDateTime` and the last one is `asTimestamp`.\r\n\r\nSignature of `asDateTime` is `asDateTime($pattern = 'yyyy/MM/dd, HH:mm:ss')`. This function accepts an `ICU`-acceptable format. You can find more info from [this link](http://www.icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details). Also it's good idea for implementing a function that parse traditional php `date`-acceptable format (See ToDo section).\r\n\r\n`asTimestamp` function return the unix epoch, positive integer for time after that and negative integer for before that.\r\n\r\nExamples\r\n--------\r\nThere are some examples for using `IntlDateTrait`. I think they are necessary and sufficent.\r\n\r\n```php\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->toPersian('en')->asDateTime();\r\n// '1396/06/16, 07:53:45'\r\n\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->toPersian()->asDateTime();\r\n// '۱۳۹۶/۰۶/۱۶, ۰۷:۵۳:۴۵'\r\n\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->toJapanese()->asDateTime();\r\n// '0029/09/07, 07:53:45'\r\n\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->toIslamic()->asDateTime();\r\n// '١٤٣٨/١٢/١٧, ٠٧:٥٣:٤٥'\r\n\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->toBuddhist()->asDateTime();\r\n// '2560/09/07, 07:53:45'\r\n\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->toChinese()->asDateTime();\r\n// '0034/07/17, 07:53:45'\r\n\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->toIndian()->asDateTime();\r\n// '1939/06/16, 07:53:45'\r\n\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->toHebrew()->asDateTime();\r\n// 'תשע״ז/י״ב/ט״ז, 07:53:45'\r\n\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->toCoptic()->asDateTime();\r\n// '1733/13/02, 07:53:45'\r\n\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->toEthiopic()->asDateTime();\r\n// '2009/13/02, 07:53:45'\r\n\r\n$this->fromPersian([1396, 6, 16, 12, 23, 45])->toIslamic()->asDateTime();\r\n// '١٤٣٨/١٢/١٧, ٠٧:٥٣:٤٥'\r\n\r\n$this->fromPersian([1396, 6, 16, 12, 23, 45])->toGregorian()->asDateTime();\r\n// '2017/09/07, 07:53:45'\r\n\r\n$this->fromPersian([1396, 6, 16, 12, 23, 45])->toGregorian()->setFinalTimeZone('Asia/Tehran')->asDateTime();\r\n// '2017/09/07, 12:23:45'\r\n\r\n$this->fromPersian([1396, 6, 16, 12, 23, 45])->toGregorian()->setFinalTimeZone('Asia/Tehran')->asDateTime('yyyy');\r\n// '2017'\r\n\r\n$this->fromGregorian([2017, 9, 7, 12, 23, 45])->asTimestamp();\r\n// '1504770825'\r\n\r\n$this->fromPersian([1396, 6, 16, 12, 23, 45])->asTimestamp();\r\n// '1504770825'\r\n```\r\n\r\nIntlDateTrait API\r\n-----------------\r\nThere are some methods that help to control more on converting process. I just list them in this section. I think thier name complain their usages, If it's not, please write document for them :D.\r\n\r\n|Setters |Gettes |\r\n|--------------------------------|--------------------------|\r\n|`setOriginDate($datetimeArray)` | `getFinalDate()` |\r\n|`setFromLocale($locale)` |`getFromLocale()` |\r\n|`setFromCalendar($calendar)` |`getFromCalendar()` |\r\n|`setToLocale($locale)` |`getToLocale()` |\r\n|`setToCalendar($calendar)` |`getToCalendar()` |\r\n|`getFromLocaleAndCalendar()` |`getToLocaleAndCalendar()`|\r\n|`setOriginTimeZone($timezone)` |`getOriginTimeZone()` |\r\n|`setFinalTimeZone($timezone)` |`getFinalTimeZone()` |\r\n|`setOriginCalendar($locale)` |`getOriginCalendar()` |\r\n|`setFinalCalendar($locale)` |`getFinalCalendar()` |\r\n|`setFinalDateType($datetype)` |`getFinalDateType()` |\r\n|`setFinalTimeType($timetype)` |`getFinalTimeType()` |\r\n|`setFinalCalendarType($calendarType)`|`getFinalCalendarType()`|\r\n|`setFinalPattern($pattern)` |`getFinalPattern()` |\r\n|`setIntlDateFormatter($locale = \"en_US\", $datetype = IntlDateFormatter::FULL, $timetype = IntlDateFormatter::FULL, $timezone = 'UTC', $calendar = IntlDateFormatter::GREGORIAN, $pattern = 'yyyy/MM/dd HH:mm:ss')`|`getIntlDateFormatter()`|\r\n|`setIntlCalendar($timezone = 'Asia/Tehran', $locale = 'fa_IR@calendar=persian')`|`getIntlCalendar()`|\r\n\r\nToDo\r\n----\r\n - Implement `parsePattern($pattern)` method.\r\n\r\n ```php\r\n/**\r\n * Implement a function to parse both ICU patterns and php date\r\n * function patterns and return a pattern that is compatible on\r\n * ICU format. The php pattern must start with php keyword, for\r\n * example `php:Y-F-d, H:i:s` is a php pattern.\r\n */\r\n ```\r\n\r\n - Implement `guessDateTime($timestring)` method.\r\n\r\n ```php\r\n /**\r\n * Implement a function to convert '2016/01/22 11:43:24' to an array\r\n * like\r\n * [\r\n * 0 => 2016, // Year\r\n * 1 => 0, // Month. IntlCalendar use 0 for first month and so on.\r\n * 2 => 22, // Day\r\n * 3 => 11, // Hour\r\n * 4 => 43, // Minute\r\n * 5 => 24, // Seconds\r\n * ]\r\n */\r\n ```\r\n\r\n - Write tests!\r\n \r\n Contribute\r\n ----------\r\n Just fork this repository, do your modification or addition and send a pull request!",
"note": "Don't delete this file! It's used internally to help with page regeneration."
}
124 changes: 124 additions & 0 deletions stylesheets/github-light.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
The MIT License (MIT)
Copyright (c) 2016 GitHub, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

.pl-c /* comment */ {
color: #969896;
}

.pl-c1 /* constant, variable.other.constant, support, meta.property-name, support.constant, support.variable, meta.module-reference, markup.raw, meta.diff.header */,
.pl-s .pl-v /* string variable */ {
color: #0086b3;
}

.pl-e /* entity */,
.pl-en /* entity.name */ {
color: #795da3;
}

.pl-smi /* variable.parameter.function, storage.modifier.package, storage.modifier.import, storage.type.java, variable.other */,
.pl-s .pl-s1 /* string source */ {
color: #333;
}

.pl-ent /* entity.name.tag */ {
color: #63a35c;
}

.pl-k /* keyword, storage, storage.type */ {
color: #a71d5d;
}

.pl-s /* string */,
.pl-pds /* punctuation.definition.string, string.regexp.character-class */,
.pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */,
.pl-sr /* string.regexp */,
.pl-sr .pl-cce /* string.regexp constant.character.escape */,
.pl-sr .pl-sre /* string.regexp source.ruby.embedded */,
.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */ {
color: #183691;
}

.pl-v /* variable */ {
color: #ed6a43;
}

.pl-id /* invalid.deprecated */ {
color: #b52a1d;
}

.pl-ii /* invalid.illegal */ {
color: #f8f8f8;
background-color: #b52a1d;
}

.pl-sr .pl-cce /* string.regexp constant.character.escape */ {
font-weight: bold;
color: #63a35c;
}

.pl-ml /* markup.list */ {
color: #693a17;
}

.pl-mh /* markup.heading */,
.pl-mh .pl-en /* markup.heading entity.name */,
.pl-ms /* meta.separator */ {
font-weight: bold;
color: #1d3e81;
}

.pl-mq /* markup.quote */ {
color: #008080;
}

.pl-mi /* markup.italic */ {
font-style: italic;
color: #333;
}

.pl-mb /* markup.bold */ {
font-weight: bold;
color: #333;
}

.pl-md /* markup.deleted, meta.diff.header.from-file */ {
color: #bd2c00;
background-color: #ffecec;
}

.pl-mi1 /* markup.inserted, meta.diff.header.to-file */ {
color: #55a532;
background-color: #eaffea;
}

.pl-mdr /* meta.diff.range */ {
font-weight: bold;
color: #795da3;
}

.pl-mo /* meta.output */ {
color: #1d3e81;
}

Loading

0 comments on commit 916b5da

Please sign in to comment.