developer.jelix.org is not used any more and exists only for
history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
Opened 10 years ago
Closed 10 years ago
#1179 closed enhancement (fixed)
Ajout d'une méthode isNull à jDateTime
Reported by: | hadrien | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | Jelix 1.2RC1 |
Component: | jelix:utils | Version: | 1.2b1 |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Documentation needed: | no | |
Hosting Provider: | Php version: |
Description
Une méthode pratique pour savoir si un jDateTime est "null", en fait que ses valeurs sont à 0 :
diff --git a/lib/jelix/utils/jDateTime.class.php b/lib/jelix/utils/jDateTime.class.php index e42e9a2..b64b5da 100644 --- a/lib/jelix/utils/jDateTime.class.php +++ b/lib/jelix/utils/jDateTime.class.php @@ -135,6 +135,17 @@ class jDateTime { } /** + * Check if jDateTime is "null" (all values egals to 0) + * + * @return boolean + * @author Hadrien Lanneau (hadrien at over-blog dot com) + **/ + public function isNull() + { + return ($this->year === 0 and $this->month === 0 and $this->day === 0); + } + + /** * convert the date to a string format * @param int $format one of the class constant xxx_FORMAT, or -1 if it should use the default format * @return string the string date
Change History (3)
comment:1 Changed 10 years ago by laurentj
- Milestone set to Jelix 1.2
comment:2 Changed 10 years ago by laurentj
comment:3 Changed 10 years ago by laurentj
- Resolution set to fixed
- review changed from review? to review+
- Status changed from new to closed
pushed http://bitbucket.org/jelix/jelix-trunk/changeset/c772b93020b7
Avec des tests supplémentaires sur les minutes secondes
Note: See
TracTickets for help on using
tickets.
Pas de tests sur les heures/minutes/secondes ?