Permalink
Browse files

Current date script.

  • Loading branch information...
1 parent 4805d9d commit 93372c1f313815a0cccd0bd2bdcff0d6e915caab @ccgus committed Apr 24, 2014
Showing with 18 additions and 0 deletions.
  1. +18 −0 plugins-script/Insert YYYY.MM.DD.jstalk
@@ -0,0 +1,18 @@
+function main(windowController, document) {
+
+ var dateFormat = "YYYY.MM.dd";
+
+ var dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
+ [dateFormatter setDateFormat:dateFormat];
+
+ var t = [dateFormatter stringFromDate:[NSDate date]]);
+
+ var textView = [windowController textView];
+ var r = [textView selectedRange];
+
+ if ([textView shouldChangeTextInRange:r replacementString:t]) {
+ [[[textView textStorage] mutableString] replaceCharactersInRange:r withString:t];
+ }
+
+
+}

0 comments on commit 93372c1

Please sign in to comment.