Skip to content

Commit 144e9e6

Browse files
update
1 parent fd40e8d commit 144e9e6

File tree

7 files changed

+435
-30
lines changed

7 files changed

+435
-30
lines changed

Capsule/TimeHelper.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ static public function setPassedTimezone($timezone = null)
107107
*/
108108
static public function setPassedDate($date = null)
109109
{
110+
// backdate default time
111+
$default = 'Jan 01 1970';
112+
110113
if(empty($date)){
111114
// $date = date('M d Y', strtotime('this year January'));
112-
$date = "Jan 01 1970";
115+
$date = $default;
113116
}
114117

115118
if (is_numeric($date)) {
@@ -121,8 +124,11 @@ static public function setPassedDate($date = null)
121124
if($date instanceof \Illuminate\Support\Carbon){
122125
$date = $date->toDateTimeString();
123126
}
127+
128+
// convert to time int
129+
$time = strtotime($date);
124130

125-
return strtotime($date);
131+
return !$time ? strtotime($default) : $time;
126132
}
127133

128134
/**

README.md

Lines changed: 110 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ Support Package For PHP and Laravel
1010
* [Installation](#installation)
1111
* [All Paths](#all-paths)
1212
* [Number to Words](#number-to-words)
13+
* [ISO](#iso)
14+
* [Cents](#Cents)
15+
* [Value](#value)
16+
* [toText](#toText)
17+
* [toNumber](#toNumber)
1318
* [Tame](#tame)
1419
* [byteToUnit](#byteToUnit)
1520
* [unitToByte](#unitToByte)
@@ -67,7 +72,65 @@ Support Package For PHP and Laravel
6772
* [PDF](#pdf)
6873
* [Read PDF](#read-pdf)
6974
* [Time](#time)
75+
* [now](#now)
76+
* [ago](#ago)
77+
* [sec](#sec)
78+
* [min](#min)
79+
* [day](#day)
80+
* [hour](#hour)
81+
* [weeks](#weeks)
82+
* [month](#month)
83+
* [year](#year)
84+
* [today](#today)
85+
* [date](#date)
86+
* [format](#format)
87+
* [yesterday](#yesterday)
88+
* [timestamp](#timestamp)
89+
* [toJsTimer](#toJsTimer)
90+
* [getSeconds](#getSeconds)
91+
* [getMinutes](#getMinutes)
92+
* [getHours](#getHours)
93+
* [getDays](#getDays)
94+
* [getWeeks](#getWeeks)
95+
* [getMonths](#getMonths)
96+
* [getYears](#getYears)
97+
* [addSeconds](#addSeconds)
98+
* [subSeconds](#subSeconds)
99+
* [addMinutes](#addMinutes)
100+
* [subMinutes](#subMinutes)
101+
* [addHours](#addHours)
102+
* [subHours](#subHours)
103+
* [addDays](#addDays)
104+
* [subDays](#subDays)
105+
* [addWeeks](#addWeeks)
106+
* [subWeeks](#subWeeks)
107+
* [addMonths](#addMonths)
108+
* [subMonths](#subMonths)
109+
* [addYears](#addYears)
110+
* [subYears](#subYears)
111+
* [dateRange](#dateRange)
112+
* [greeting](#greeting)
113+
* [timeDiff](#timeDiff)
114+
* [allTimezone](#allTimezone)
115+
* [setTimeZone](#setTimeZone)
116+
* [getTimeZone](#getTimeZone)
117+
* [toDateTimeString](#toDateTimeString)
118+
* [setGlobalTimeZone](#setGlobalTimeZone)
119+
* [getGlobalTimeZone](#getGlobalTimeZone)
120+
* [UrlHelper](#UrlHelper)
121+
* [url](#url)
122+
* [http](#http)
123+
* [host](#host)
124+
* [full](#full)
125+
* [path](#path)
126+
* [server](#server)
127+
* [request](#request)
128+
* [referral](#referral)
70129
* [Cookie](#cookie)
130+
* [Set](#set)
131+
* [Get](#get)
132+
* [Forget](#forget)
133+
* [Has](#has)
71134
* [Hash](#hash)
72135
* [Asset](#Asset)
73136
* [Asset config](#asset-config)
@@ -147,7 +210,7 @@ NumberToWords::cents(true);
147210
NumberToWords::value(1290);
148211
```
149212

150-
### Usage -- `toText()`
213+
### toText
151214
- Convert number to readable words
152215
- Below, we're using the function helper method
153216
```
@@ -157,10 +220,10 @@ NumberToWords()
157220
->cents(true)
158221
->toText();
159222
160-
// One hundred and twenty lira, nine hundred and fifty-three kuruş
223+
// Output: One hundred and twenty lira, nine hundred and fifty-three kuruş
161224
```
162225

163-
### Usage -- `toNumber()`
226+
### toNumber
164227
- Convert words to number
165228
- comma `, ` is used to seperate decimals in words
166229
```
@@ -171,7 +234,7 @@ NumberToWords::value('twelve million three hundred thousand, six hundred and nin
171234
->cents(true)
172235
->toNumber()
173236
174-
// 12300000.698
237+
// Output: 12300000.698
175238
```
176239

177240
## Tame
@@ -483,8 +546,50 @@ This will read the PDF to the browser
483546
```
484547

485548
## Time
549+
- Helper function is called using `TameTime()`
550+
- Visit the Tests/ folder to see more examples.
551+
552+
```
553+
$time = TameTime('now', 'Africa/Lagos');
554+
```
555+
556+
### allTimezone
557+
```
558+
Time::allTimezone();
559+
```
560+
561+
### setTimeZone
562+
```
563+
Time::setTimeZone('Pacific/Pago_Pago');
564+
```
565+
566+
### getTimeZone
567+
```
568+
Time::getTimeZone();
569+
```
570+
571+
### setGlobalTimeZone
572+
```
573+
Time::setGlobalTimeZone('Pacific/Pago_Pago');
574+
```
575+
576+
### getGlobalTimeZone
577+
```
578+
Time::getGlobalTimeZone();
579+
```
580+
581+
## UrlHelper
486582
```
487-
Visit the Tests/ folder to see more examples.
583+
[
584+
urlHelper()->server(),
585+
urlHelper()->url(),
586+
urlHelper()->full(),
587+
urlHelper()->request(),
588+
urlHelper()->referral(),
589+
urlHelper()->http(),
590+
urlHelper()->host(),
591+
urlHelper()->path(),
592+
]
488593
```
489594

490595
## Cookie

Tests/mail.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,31 @@
1616
]);
1717

1818

19-
$mailer->to('tamedevelopers@gmail.com, fredi.peter@gmail.com')
20-
->subject('New subject')
21-
->body('Hello this is a body text')
22-
->attach(base_path("thousand_units.png"), 'New Name')
23-
->send(function($response){
24-
// dd(
25-
// $response
26-
// );
27-
});
19+
$time = TameTime('first day of December 2008');
20+
21+
22+
dd(
23+
$time->timeDifference(),
24+
$time->addDay(2000)->ago('date'),
25+
$time->subDay(10)->ago('date'),
26+
$time->ago(),
27+
$time->today()->format(),
28+
$time->now()->addMonth(1)->subDay(1)->format(),
29+
$time->yesterday()->toDateTimeString(),
30+
$time->format(null, 'first day of December 2008'),
31+
// $time->toJs(),
32+
);
33+
34+
35+
// $mailer->to('tamedevelopers@gmail.com, fredi.peter@gmail.com')
36+
// ->subject('New subject')
37+
// ->body('Hello this is a body text')
38+
// ->attach(base_path("thousand_units.png"), 'New Name')
39+
// ->send(function($response){
40+
// // dd(
41+
// // $response
42+
// // );
43+
// });
2844

2945

3046

Tests/time.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@
2727
$time3 = Time::setTimezone('Indian/Antananarivo');
2828

2929
dd(
30-
TameTime()->format('yesterday')->ago(),
30+
TameTime()->date('yesterday')->ago(),
3131
TameTime()->toJs('now'),
3232

3333
Time::setTimezone('Asia/Tokyo'),
3434

35-
$mainTime->format('last year december'),
35+
$mainTime->date('last year december')->format(),
3636
$mainTime->getTimeZone(),
3737

38-
$time2->format('this year october')->ago(),
38+
$time2->date('this year october')->ago(),
3939
$time2->getTimeZone(),
4040

4141
$time3,
4242
$time3->greetings(),
4343

4444
Time::getGlobalTimeZone(),
4545

46-
TameTime()->formatRange('1-14')->get(false, true),
46+
TameTime()->dateRange('1-14')->get(false, true),
4747
TameTime()->dateRange('0-40')->get(true),
4848

4949
// Time::allTimezone(),

Tests/url.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
urlHelper()->server(),
2121

2222
[
23+
urlHelper()->server(),
2324
urlHelper()->url(),
2425
urlHelper()->full(),
2526
urlHelper()->request(),

0 commit comments

Comments
 (0)