Last active
August 3, 2020 04:50
-
-
Save xtex404/de5e35cddc4edce582e03f9de28f97ad to your computer and use it in GitHub Desktop.
XSplit Text Script - simplified clock with date and time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* a short xsplit custom text script that will provide a simple time/date display, | |
| in YYYY-MM-DD HH:MM:SS ZZZZ format... you can use different locales if you want | |
| it to display the time/date differently. | |
| this is pretty much my first time attempting to write anything in javascript since 1998, so... be gentle. :) | |
| v1.0.0 - 2020-08-03 - https://gist.github.com/xtex404/de5e35cddc4edce582e03f9de28f97ad | |
| */ | |
| /** | |
| * @name showDate | |
| * @label Show Date | |
| * @type boolean | |
| * @description Show the current date | |
| */ | |
| var showDate = true; | |
| /** | |
| * @name datePrefix | |
| * @label Date Prefix String | |
| * @type text | |
| * @description Text that will be inserted before the time | |
| */ | |
| var datePrefix = ""; | |
| /** | |
| * @name showWeekday | |
| * @label Show Weekday | |
| * @type boolean | |
| * @description Show the current weekday (abbreviation) | |
| */ | |
| var showWeekday = false; | |
| /** | |
| * @name showTime | |
| * @label Show Current Time | |
| * @type boolean | |
| * @description Show the current time | |
| */ | |
| var showTime = true; | |
| /** | |
| * @name timePrefix | |
| * @label Time Prefix String | |
| * @type text | |
| * @description Text that will be inserted before the time | |
| */ | |
| var timePrefix = " — "; | |
| /** | |
| * @name theDateLocale | |
| * @label Date Locale | |
| * @type text | |
| * @description Locale to use when showing date ('en-CA' = YYYY-MM-DD) | |
| */ | |
| var theDateLocale = "en-CA"; | |
| /** | |
| * @name theTimeLocale | |
| * @label Time Locale | |
| * @type text | |
| * @description Locale to use when showing time ('en-US' is default) | |
| */ | |
| var theTimeLocale = "en-US"; | |
| /** | |
| * @name showTwelve | |
| * @label Use 12-hour time | |
| * @type boolean | |
| * @description Use 12-hour time | |
| */ | |
| var showTwelve = false; | |
| /** | |
| * @name showSeconds | |
| * @label Show Seconds | |
| * @type boolean | |
| * @description Show seconds | |
| */ | |
| var showSeconds = true; | |
| /** | |
| * @name showTimeZone | |
| * @label Show Time Zone | |
| * @type boolean | |
| * @description Show the current time | |
| */ | |
| var showTimeZone = true; | |
| /** | |
| * @name timeSuffix | |
| * @label Time Suffix String | |
| * @type text | |
| * @description Text that will be inserted after the time | |
| */ | |
| var timeSuffix = ""; | |
| /** | |
| * @name updateInterval | |
| * @label Update Interval (ms) | |
| * @type spinner | |
| * @min 100 | |
| * @max 30000 | |
| * @step 100 | |
| * @description Milliseconds between updates (500 recommended)||If you turn off seconds, you could set this to 30000 and be fine. | |
| */ | |
| var updateInterval = 500; | |
| // ============================================= | |
| var the_zone = "short"; | |
| if (showTimeZone == false) | |
| { | |
| the_zone = undefined; | |
| } | |
| var is_second = '2-digit'; | |
| if (showSeconds == false) | |
| { | |
| is_second = undefined; | |
| } | |
| function getTimeString() | |
| { | |
| var date = new Date(); | |
| var theString = ""; | |
| if (showDate) | |
| { | |
| if (showWeekday) | |
| { | |
| theString = theString + date.toLocaleDateString([theDateLocale, 'en-CA'], | |
| { | |
| weekday: 'short' | |
| }).replace(/[.,\s]/g, "") + ' '; | |
| } | |
| theString = theString + datePrefix + date.toLocaleDateString([theDateLocale, 'en-CA'], | |
| { | |
| month: '2-digit', | |
| day: '2-digit', | |
| year: 'numeric' | |
| }); | |
| } | |
| if (showTime) | |
| { | |
| theString = theString + timePrefix + date.toLocaleTimeString([theTimeLocale, 'en-US'], | |
| { | |
| hour12: showTwelve, | |
| hour: '2-digit', | |
| minute: '2-digit', | |
| second: is_second, | |
| timeZoneName: the_zone | |
| }) + timeSuffix; | |
| } | |
| var theTimer = setTimeout(getTimeString, updateInterval); | |
| SetText(theString, "Timestamp"); | |
| } | |
| getTimeString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment