File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,25 @@ $duration = Duration::from(1200); // 1200 seconds
200200$duration = Duration::from(500, Duration::UNIT_MINUTES);
201201```
202202
203+ ### Set or Parse Values deferred
204+
205+ Sometimes, you may want to configure the Measurement object first and then parse the value later.
206+ You can create an empty Measurement object and set value or parse value later, all Measurement objects
207+ are ** immutable** , so you must assign the result to a new variable.
208+
209+ ``` php
210+ use Asika\BetterUnits\Duration;
211+
212+ $duration = new Duration()
213+ ->withTropicalCalendar();
214+
215+ $duration = $duration->with(123, 'hours'); // Set value and units
216+ // OR
217+ $duration = $duration->withParse('123hours'/*, $scale, $roundingMode*/);
218+ // OR
219+ $duration = $duration->withFrom('123hours'/*, $scale, $roundingMode*/);
220+ ```
221+
203222## Unit Conversion
204223
205224BetterUnits provides two ways to convert units: one retains the ` Measurement ` object after conversion, and the other
You can’t perform that action at this time.
0 commit comments