Skip to content

Ph/170 date time support#9

Merged
OndrejKunc merged 15 commits intomasterfrom
ph/170-date-time-support
Jun 30, 2019
Merged

Ph/170 date time support#9
OndrejKunc merged 15 commits intomasterfrom
ph/170-date-time-support

Conversation

@Pavel-Hrdy
Copy link
Collaborator

What is implemented:

  • constructors
    dateTime(string) -  string is standardized format of date-time (ISO 8601)
    duration(string) - string is subset of standardized format of duration (ISO 8601)
    • allowed designators: D, T, H, M, S
    • only natural numbers are allowed
  • functions - below

Examples:
dateTime("1997-07-16T19:20")
duration("P5D1H3S")

Functions

  • arithmetic operations
    • +(DateTime,Duration) - adds Duration to DateTime and returns the sum as a new DateTime (commutative)
    • -(DateTime,Duration) - subtracts Duration from DateTime and returns the difference as a new DateTime 
    • +(Duration,Duration) - adds two Durations and returns the sum as a new Duration (commutative)
    • -(Duration,Duration) - subtracts two Durations and returns the difference as a new Duration
    • *(Duration,Integer) - multiplies Duration by the given Number and returns the result as a new Duration (commutative)
    • -(Duration) - negates Duration and returns it as a new Duration
    • /(Duration,Integer) - divides Duration by the given number and returns the truncated result as a new Duration
  • relational operations
    • <,<=,==,!=,>=,>(DateTime,DateTime) - compares two DateTimes, returns boolean
    • <,<=,==,!=,>=,>(Duration,Duration) - compares two Durations, returns boolean
    • all comparisons are independent of whether the time is in UTC or in the local time zone.
  • now() - returns DateTime with current date and time in the local time zone
  • nowInUtc() - returns DateTime with current date and time in the UTC time zone
  • diffDateTime(DateTime, DateTime) - returns difference between two DateTimes as an Duration in absolute value
  • durationInHours(Duration) - returns the Integer which represents the number of whole hours spanned by this Duration
  • durationInDays(Duration) - returns the Integer which represents the number of whole days spanned by this Duration
  • durationInMinutes(Duration) - returns the Integer which represents the number of whole minutes spanned by this Duration
  • durationInSeconds(Duration) - returns the Integer which represents the number of whole seconds spanned by this Duration

@Pavel-Hrdy Pavel-Hrdy requested a review from OndrejKunc June 26, 2019 13:14
@OndrejKunc OndrejKunc merged commit 00824a8 into master Jun 30, 2019
@OndrejKunc OndrejKunc deleted the ph/170-date-time-support branch July 1, 2019 12:07
@OndrejKunc OndrejKunc mentioned this pull request Oct 20, 2019
@muziling muziling mentioned this pull request Dec 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants