TimeAPI 1.1

An extremely versatile API for parsing times.

  1. Okx
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    Source Code:
    https://github.com/okx-code/TimeAPI
    This is an easy API for parsing times (such as 5m2d) into seconds/minutes/hours etc.

    API Usage:
    The class is located in sh.okx.timeapi.api.TimeAPI. Remember to import the TimeAPI.jar into your project.

    TimeAPI has an accuracy of one second, as such it cannot hold something like 1 millisecond but has getter methods to convert its stored seconds to milliseconds.

    First, you'd want to create an instance of TimeAPI:
    Code (Text):
    TimeAPI api = new TimeAPI("1s 2m 3h"); // Creates a new instance of TimeAPI with 1 second, 2 minutes, and 3 hours.
    or
    TimeAPI api = new TimeAPI(seconds);
    Then, you can extract information from it (all methods return doubles):
    Code (Text):

    api.getNanoseconds();
    api.getMicroseconds();
    api.getMilliseconds();
    api.getSeconds(); // Would return the amount of total seconds in the TimeAPI instance.
        // For example, if you did 'new TimeAPI("5m and 10s");', you'd get 310.
    api.getMinutes(); // Same as above, with minutes
    api.getHours();
    api.getDays();
    api.getWeeks();
    api.getYears();

    api.reparse(String); // Reparses with a new string.
    What can be parsed:
    For seconds: s, secs, seconds, sec, second
    For minutes: m, mins, minutes, min, minute
    For hours: h, hr, hrs, hours, hour
    For days: d, dy, dys, day, days
    For weeks: w, week, weeks
    For months: m, mon, mnth, month, months
    For years: y, yr, yrs, year, years
    Also, if your string contains 'and', spaces or ',' they will get ignored.

    The API will throw an IllegalArgumentException if you use input something like 4asdf.

    Examples of Usage:
    All the following work with TimeAPI
    • 5s, 7d, 9weeks and 22 hours
    • 89 secs, 1 hour 17 days
    • 6d4h3s2m
    • 7h 2m
    • 1 day and 7h

    Commands:
    /timeapi <time> Parses a time using the TimeAPI (gives you seconds, minutes, hours, etc);
    /timeapi Information about the plugin

    Permissions:
    Code (Text):
    permissions:
        timeapi.*:
            children:
                timeapi.parse: true
                timeapi.command: true
        timeapi.parse:
            description: Parse TimeAPI strings
            default: op
        timeapi.command:
            description: TimeAPI Plugin Info
            default: true

    DO NOT ask for help or request additional things in the reviews. Use the forums.
    Mas likes this.

Recent Updates

  1. Recode API

Recent Reviews

  1. Mas
    Mas
    5/5,
    Version: 1.0
    Amazing plugin! No longer do I have to force people to input times by entering the exact number of milliseconds. Absolute lifesaver plugin, would recommend.
  2. Dartanman
    Dartanman
    5/5,
    Version: 1.0
    Amazing plugin. Works very well. Great job on it Okx! Keep up the good work! Can't wait to see more great things from you.
    1. Okx
  3. Casidesigns
    Casidesigns
    1/5,
    Version: 1.0
    Terrible plugin. It doesn't do what the thread says, and the API doesn't work properly. I do not recommend
    1. Okx
      Author's Response
      but you didn't even try using it.