📄 insert_date.bsh
字号:
/* * Insert_Date.bsh - a BeanShell macro script for the * jEdit text editor - insert current date and "Internet Time" * at current caret position * Copyright (C) 2001 John Gellene (on behalf of author) * jgellene@nyc.rr.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the jEdit program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id: Insert_Date.bsh,v 1.2 2001/11/06 15:04:21 jgellene Exp $ * * Checked for jEdit 4.0 API * */// Inserts the current date and Internet Time at the caret position// "Internet Time" is a new and easy way to measure time across the world// To find more "Internet Time"-related information go to// http://www.swatch.com/alu_beat/fs_itime.html// Wed Jan 31 03:12:33 AKST 2001 @550 /Internet Time/void insertDate(){ Calendar rightNow = Calendar.getInstance(); // zone offset with daylight savings int zoffset = (rightNow.get(Calendar.ZONE_OFFSET) + rightNow.get(Calendar.DST_OFFSET)) / 60000; // parsing current hour, minute and second double h = rightNow.get(Calendar.HOUR_OF_DAY); double m = rightNow.get(Calendar.MINUTE); double s = rightNow.get(Calendar.SECOND); // calculating internet time double swatch = Math.floor ((h * 3600 + ((m - zoffset + 60) * 60) + s) * 1000 / 86400); if (swatch >= 1000) swatch -= 1000; else if (swatch < 0) swatch += 1000; // inserting date and internet time to textarea textArea.setSelectedText(Calendar.getInstance().getTime().toString() + " @" + (int)swatch + " /Internet Time/");}insertDate();/* Macro index data (in DocBook format)<listitem> <para><filename>Insert_Date.bsh</filename></para> <abstract><para> Inserts the current date and time in the current buffer. </para></abstract> <para> The inserted text includes a representation of the time in the <quote>Internet Time</quote> format. </para></listitem>*/// end Insert_Date.bsh
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -