Skip to content

Commit

Permalink
Remove duplicate documentation.
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Jan 15, 2025
1 parent 570d952 commit 99df7d7
Showing 1 changed file with 1 addition and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,149 +82,7 @@ public class TimeUtils {

/**
* Returns the relative {@link ZonedDateTime} corresponding to the given relative string and zoned date time.
* <p>
* The relative time string has syntax {@code [+|-]<offset_time_integer><offset_time_unit>@<snap_time_unit>}, and
* is made up of two optional components:
* <ul>
* <li>
* An offset from the current timestamp at the start of query execution, which is composed of a sign
* ({@code +} or {@code -}), an optional time integer, and a time unit. If the time integer is not specified,
* it defaults to one. For example, {@code +2hr} corresponds to two hours after the current timestamp, while
* {@code -mon} corresponds to one month ago.
* </li>
* <li>
* A snap-to time using the {@code @} symbol followed by a time unit. The snap-to time is applied after the
* offset (if specified), and rounds the time <i>down</i> to the start of the specified time unit (i.e.
* backwards in time). For example, {@code @wk} corresponds to the start of the current week (Sunday is
* considered to be the first day of the week).
* </li>
* </ul>
* <p>
* The special relative timestamp string {@code now}, corresponding to the current timestamp, is also supported.
* <p>
* The current timestamp is determined once at the start of query execution, and is used for all relative timestamp
* calculations for that query. The Spark session time zone ({@code spark.sql.session.timeZone}) is used for
* determining relative timestamps, and accounts for changes in the time zone offset (e.g. daylight savings time);
* as a result, adding one day ({@code +1d}) is not the same as adding twenty-four hours ({@code +24h}).
* <p>
* The relative timestamp string is case-insensitive.
* <p>
* The following offset time units are supported:
* <table border="1">
* <body>
* <tr>
* <th>Time Unit</th>
* <th>Supported Keywords</th>
* </tr>
* <tr>
* <td>Seconds</td>
* <td>{@code s}, {@code sec}, {@code secs}, {@code second}, {@code seconds}</td>
* </tr>
* <tr>
* <td>Minutes</td>
* <td>{@code m}, {@code min}, {@code mins}, {@code minute}, {@code minutes}</td>
* </tr>
* <tr>
* <td>Hours</td>
* <td>{@code h}, {@code hr}, {@code hrs}, {@code hour}, {@code hours}</td>
* </tr>
* <tr>
* <td>Days</td>
* <td>{@code d}, {@code day}, {@code days}</td>
* </tr>
* <tr>
* <td>Weeks</td>
* <td>{@code w}, {@code wk}, {@code wks}, {@code week}, {@code weeks}</td>
* </tr>
* <tr>
* <td>Quarters</td>
* <td>{@code q}, {@code qtr}, {@code qtrs}, {@code quarter}, {@code quarters}</td>
* </tr>
* <tr>
* <td>Years</td>
* <td>{@code y}, {@code yr}, {@code yrs}, {@code year}, {@code years}</td>
* </tr>
* </body>
* </table>
* <p>
* The snap-to time supports all the time units above, as well as the following day of the week time units:
* <table border="1">
* <body>
* <tr>
* <th>Time Unit</th>
* <th>Supported Keywords</th>
* </tr>
* <tr>
* <td>Sunday</td>
* <td>{@code w0}, {@code w7}</td>
* </tr>
* <tr>
* <td>Monday</td>
* <td>{@code w1}</td>
* </tr>
* <tr>
* <td>Tuesday</td>
* <td>{@code w2}</td>
* </tr>
* <tr>
* <td>Wednesday</td>
* <td>{@code w3}</td>
* </tr>
* <tr>
* <td>Thursday</td>
* <td>{@code w4}</td>
* </tr>
* <tr>
* <td>Friday</td>
* <td>{@code w5}</td>
* </tr>
* <tr>
* <td>Saturday</td>
* <td>{@code w6}</td>
* </tr>
* </body>
* </table>
* <p>
* For example, if the current timestamp is Monday, January 03, 2000 at 01:01:01 am:
* <table border="1">
* <body>
* <tr>
* <th>Relative String</th>
* <th>Description</th>
* <th>Resulting Relative Time</th>
* </tr>
* <tr>
* <td>{@code -60m}</td>
* <td>Sixty minutes ago</td>
* <td>Monday, January 03, 2000 at 00:01:01 am</td>
* </tr>
* <tr>
* <td>{@code -H}</td>
* <td>One hour ago</td>
* <td>Monday, January 03, 2000 at 00:01:01 am</td>
* </tr>
* <tr>
* <td>{@code +2wk}</td>
* <td>Two weeks from now</td>
* <td>Monday, January 17, 2000 at 00:01:01 am</td>
* </tr>
* <tr>
* <td>{@code -1h@W3}</td>
* <td>One hour ago, rounded to the start of the previous Wednesday</td>
* <td>Wednesday, December 29, 1999 at 00:00:00 am</td>
* </tr>
* <tr>
* <td>{@code @d}</td>
* <td>Start of the current day</td>
* <td>Monday, January 03, 2000 at 00:00:00 am</td>
* </tr>
* <tr>
* <td>{@code now}</td>
* <td>Now</td>
* <td>Monday, January 03, 2000 at 01:01:01 am</td>
* </tr>
* </body>
* </table>
* @see <a href="docs/ppl-lang/functions/ppl-datetime#relative_timestamp">RELATIVE_TIMESTAMP</a> for more details.
*/
public static ZonedDateTime getRelativeZonedDateTime(String relativeString, ZonedDateTime zonedDateTime) {

Expand Down

0 comments on commit 99df7d7

Please sign in to comment.