Last active
October 6, 2015 18:56
-
-
Save hobbes3/ab94a4a30e6edfe6e8fb to your computer and use it in GitHub Desktop.
format _time oneshot earliest latest modifier
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
function format_time(time, token_name) { | |
var service = mvc.createService(); | |
var convert_search = 'search index=foo earliest=' + time + ' | localop | stats count | addinfo | eval output=strftime(info_min_time, "%F %T")'; | |
// Run a oneshot search to convert the date string to epoch *to the user's timezone preference* | |
service.oneshotSearch(convert_search, {}, function(err, results) { | |
var time_formatted = results.rows[0][results.fields.indexOf("output")]; | |
unsubmitted_tokens.set(token_name, time_formatted); | |
submit_and_update_url(); | |
}); | |
} | |
submitted_tokens.on("change:earliest", function() { | |
var earliest = unsubmitted_tokens.get("earliest"); | |
format_time(earliest, "earliest_formatted"); | |
}); | |
submitted_tokens.on("change:latest", function() { | |
var latest = unsubmitted_tokens.get("latest"); | |
format_time(latest, "latest_formatted"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment