Commit a7329a8a authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add support for Cygwin envs without `date`

parent de0c4818
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -116,3 +116,21 @@ if has realpath; then
elif has readlink; then
	expand() { readlink -f "$1"; }
fi

if has date; then
	get_utime() {
		if [ -n "$1" ]; then
			date -r "$1" '+%s'
		else
			date '+%s'
		fi
	}
elif has cscript; then
	get_utime() {
		if [ -n "$1" ]; then
			cscript //nologo ~/.shell/lib/utime.js /from:"$1"
		else
			cscript //nologo ~/.shell/lib/utime.js
		fi
	}
fi
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ check_submodule()
do_update()
{
	local timestamp=${HOME}/.shell/.update
	local now=`date +%s` updated=`date -r "$timestamp" +%s 2>/dev/null`
	local now=`get_utime` updated=`get_utime "$timestamp"`
	local BOLD_BLUE=$'\033[34;1m' DEFAULT=$'\033[m'
	local prompt="${BOLD_BLUE}Would you like to update dotfiles?${DEFAULT} "
	local shell=`get_shell`

.shell/lib/utime.js

0 → 100644
+10 −0
Original line number Diff line number Diff line
FileSystemObject = new ActiveXObject("Scripting.FileSystemObject");
Opts = WScript.Arguments.Named;

if ( Opts.Exists("from") ) {
	date = new Date(FileSystemObject.GetFile(Opts.Item("from")).DateLastModified);
} else {
	date = new Date();
}

WScript.Echo(date.getTime());