How to get the modification date of a file in Racket? - racket

I need to determine what has changed in the file system.
How can I a get the time when a file was last modified?

The modification time of a file will always be returned by file-or-directory-modify-seconds. This will also return the modification date of directories except from the FAT format file systems - for directories a FAT file system will return the creation date instead.
To convert the file modification time, or any time in seconds to a more readable format you can use seconds->date.
> (require racket/date) ;for date->string only
> (date->string
(seconds->date
(file-or-directory-modify-seconds
(string->path "/home/ben/.emacs"))))
"Wednesday, June 4th, 2014"
reference: racket discussion list

Related

How to move file into another directory which have current date and time stamp (YYYY-MM-DD_HH-MM) in shell

I want to move one file from one folder to another. Another folder is randomly generating with date and time stamp at run time in YYYY-MM-DD_DD-MM format. The code is given below. I need to give path of current timestamp in this YYYY-MM-DD_DD-MM format.
Written Some Code for same
# Command to execute
execute_cmd=mv
path=/home/centos
# Files inside actual_dir has to be moved
actual_dir="$path/Input_File"
# This is the directory where files will be moved and kept
backup_dir="$path/Archive/{$Here I want to write some code so that I can move into one particular folder with date and time stamp YYYY-MM-DD_DD-MM} "

How to remove the file extension using a snippet variable. List of snippet variables

I use vscode.
I want to use costum snippets, but {TM_FILENAME} has an extension name.
How can I delete the extension from {TM_FILENAME}?
like this:`
In file MyModule.js:
Transform: ${TM_FILENAME/(\w+)\.js/\1/g}
Output:
MyModule
You can use TM_FILENAME_BASE to get only the filename:
${TM_FILENAME_BASE}
Actually, since the question was posed a few new built-in variables have been added,
including TM_FILENAME_BASE. See snippet variables documentation. So there is no need to do a transform just to get the filename without the extension.
Here is the current list of snippet variables:
TM_SELECTED_TEXT The currently selected text or the empty string
TM_CURRENT_LINE The contents of the current line
TM_CURRENT_WORD The contents of the word under cursor or the empty string
TM_LINE_INDEX The zero-index based line number
TM_LINE_NUMBER The one-index based line number
TM_FILENAME The filename of the current document
TM_FILENAME_BASE The filename of the current document without its extensions
TM_DIRECTORY The directory of the current document
TM_FILEPATH The full file path of the current document
CLIPBOARD The contents of your clipboard
WORKSPACE_NAME The name of the opened workspace or folder
CURRENT_YEAR The current year
CURRENT_YEAR_SHORT The current year's last two digits
CURRENT_MONTH The month as two digits (example '02')
CURRENT_MONTH_NAME The full name of the month (example 'July')
CURRENT_MONTH_NAME_SHORT The short name of the month (example 'Jul')
CURRENT_DATE The day of the month
CURRENT_DAY_NAME The name of day (example 'Monday')
CURRENT_DAY_NAME_SHORT The short name of the day (example 'Mon')
CURRENT_HOUR The current hour in 24-hour clock format
CURRENT_MINUTE The current minute
CURRENT_SECOND The current second
CURRENT_SECONDS_UNIX The number of seconds since the Unix epoch
For inserting line or block comments, honoring the current language:
BLOCK_COMMENT_START Example output: in PHP /* or in HTML <!--
BLOCK_COMMENT_END Example output: in PHP */ or in HTML -->
LINE_COMMENT Example output: in PHP // or in HTML <!-- -->
vscode v1.66 will add two new variables:
CURSOR_INDEX 0-based
CURSOR_NUMBER 1-based
The above two work with multiple cursors so that each cursor position (same as a selection) will have an incremented integer inserted.
For an example of this, see https://stackoverflow.com/a/69946559/836330
It looks like v1.40 will add:
WORKSPACE_FOLDER Path of workspace directory
RANDOM Insert 6 random digits
RANDOM_HEX Insert 6 random hex digits
See https://github.com/microsoft/vscode/pull/82529 and https://github.com/microsoft/vscode/pull/79764
v1.53 will add the relative path from the root folder to the current file:
RELATIVE_FILEPATH
UUID
See https://github.com/microsoft/vscode/pull/114208 and https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_53.md#new-snippet-variables
You can't do this at the moment but there's a feature request on the vscode GitHub page for what you want: https://github.com/Microsoft/vscode/issues/6920.
[EDIT]
My answer above is now out of date - you can use the ${TM_FILENAME_BASE} variable as mentioned by other contributors.
You can try something like this if you know the file extension,
${TM_FILENAME/(.js)//}
It will turn FileName.js to FileName

Why do I get scheduler Invalid Date error on JasperServer 6.0.1?

I am migrating the jasperserver from 3.7 to jasperserver 6.0.1, now in new jasperserver i want the date format to be dd/mm/yyyy but by default the date format is yyyy-mm-dd.
For this i changed the jasperserver_config.properties file at
apache-tomcat-7.0.65\webapps\jasperserver\WEB-INF\bundles\jasperserver_config.properties
i changed it to
# Used for parsing and formatting dates by server
date.format=dd/MM/yyyy
datetime.format=dd/MM/yyyy HH:mm:ss
time.format=HH:mm:ss
# Used for parsing and formatting dates by calendar component (UI).
# Pattern for date should match appropriated pattern from server properties.
# The format for calendar component can be combinations of the following:
# d - day of month (no leading zero)
# dd - day of month (two digit)
# o - day of year (no leading zeros)
# oo - day of year (three digit)
# D - day name short
# DD - day name long
# m - month of year (no leading zero)
# mm - month of year (two digit)
# M - month name short
# MM - month name long
# y - year (two digit)
# yy - year (four digit)
calendar.date.format=dd/mm/yyyy
calendar.datetime.format=dd/mm/yyyy HH:mm:ss
calendar.time.format=HH:mm:ss
It changed the date format but when I am going to schedule any report the date field is showing as invalid date(see below). Can some one help me in changing the date format that work correctly all over jasperserver
There is a bug with this up to version 6.10 of JasperReports Server, see bug report. I've had to use the solution #2 at the time being.
Solution #1
If possible, update to version 6.10.
Solution #2
This solution is a bit lengthy but works properly if both steps (changing the source, generating the optimized js file) are done:
You have to edit a js file for this to work properly. Use the pattern you need for your case.
in file /opt/jasperreports-server-cp-5.5.0a/apache-tomcat/webapps/jasperserver/scripts/scheduler/model/job.js you have to change this:
row 5
from:
var UI_DATE_PATTERN = "YYYY-MM-DD HH:mm";
to:
var UI_DATE_PATTERN = "DD.MM.YYYY HH:mm";
row 766
from:
data.trigger.startDate = moment(data.trigger.startDate).format(SERVICE_DATE_PATTERN);
to:
data.trigger.startDate = moment(data.trigger.startDate,UI_DATE_PATTERN).format(SERVICE_DATE_PATTERN);
Source
Optimized Java Script
NOTE: Because of the optimized Javascript files (which is not the one which is edited as far as I remember), keep in mind you might need to recreate the optimized js file - since the optimized one is the one which is used by JRS. This was the case in v 5.6.x at least:
Create a working directory where you can copy JavaScript files and install and run the required scripts. In
this example, the directory is called Working.
Create a subdirectory for a copy of the JavaScript files from JasperReports Server. This directory is called jssources.
Copy the following directories from the JasperReports Server directory, <js-webapp>, to js-sources:
• Copy <js-webapp>/scripts to js-sources/scripts.
• Copy <js-webapp>/fusion to js-sources/fusion (optional, Pro version only)
Back up your js-sources directory.
Create a js-optimization-output directory for the output of the optimization process.
Download and install node.js from http://nodejs.org/. Place the nodejs folder directly in your Working folder.
Download r.js, a requirejs optimization file, from http://requirejs.org and place it directly in the Working folder.
Make your changes to the JavaScript files in Working/js-sources.
Open a command line tool and run the commands to optimize the JavaScript. The following example is for Windows, it places the output in the Working/js-optimization-output folder:
% cd Working
% nodejs\node r.js -o js-sources\scripts\build.js appDir=js-sources\scripts baseUrl=. optimize=uglify2 dir=js-optimization-output
Copy the optimized scripts from js-optimization-output to <webapp>/optimized-scripts (where webapp is the location of your JRS)
Reload the web app in the app server to see the changes.
Source
NOTE: Keep in mind to clear your browser cache if there are problems after doing all this.

Batch file: Get yesterday's date in format: M_d_yyyy

How does one get yesterday's date format in a batch file?
I'd like it to look like so: M_d_yyyy
Note that if there's a single digit day and month, I'd like it to be single digits.
Example: 8_5_2013 is August 5th, 2013.
I looked around for a few days but couldn't find a solution.. any lead is much appreciated.
Nothing wrong with free 3rd party executables, but some of us are not allowed to use them on our work machines.
I have written a powerful hybrid JScript/batch utility called getTimestamp.bat that can do nearly any date and time computation on a Windows machine.
There are a great many options for specifying the base date and time, many options for adding positive or negative offsets to the date and time, many options for formatting the result, and an option to capture the result in a variable. Both input and output can be directly expressed as local time, UTC, or any time zone of your choosing. Full documentation is embedded within the script.
The utility is pure script that will run on any modern Windows machine from XP forward - no 3rd party executable required.
Assuming getTimestamp.bat is in your current directory, or better yet, somewhere within your PATH, then the following simple call will define a dt variable containing yesterday's date in M_D_YYYY format:
call getTimestamp -od -1 -f {m}_{d}_{yyyy} -r dt
Note: when I put a date in a file name, I like to use YYYY_MM_DD format because that format will sort chronologically when getting a directory listing.
I think you should get date.exe from UnxUtils.
date.exe --date="1 day ago" "+%-m_%d_%Y"
Download: http://sourceforge.net/projects/unxutils/files/unxutils/current/
Man page: http://www.ss64.com/bash/date.html
#echo off
setlocal
set magic="c:\unx\usr\local\wbin\date.exe" --date="1 day ago" "+%%-m_%%d_%%Y"
for /f %%i in ('%magic%') do set yesterdate=%%i
echo yesterdate = %yesterdate%
If you want to do it with just batch language, you'll end up with nearly 100 lines of incomprehensible batch code. UPDATE: or use dbenham's hybrid batch/JScript solution posted in the answer below, which at least uses sane Windows APIs.
See Also:
How to get current datetime on Windows command line, in a suitable format for using in a filename?

Emacs dired how to set date/time format

Now dired writes the last access date/time in the following format:
Jun 20 14:22
How to make it write:
20.06.2012 14:22
one of these options:
1 you can set the appropriate variables.
(setq ls-lisp-format-time-list '("%d.%m.%Y %H:%M" "%d.%m.%Y %H:%M")
ls-lisp-use-localized-time-format t)
explanation: The ls-lisp-format-time-list is a list of two format strings, which work as they do with the format-time-string function. There are two, because by default emacs is set up to display "recent" files with a higher-resolution timestamp than "older" files, where the recent vs older threshold is 6 months (I think). The first is the format used for recent files; the latter is for older files.
I never liked the default behavior; I just want the files to be displayed the same way. So I set the list to use the same time format for newer and older files.
2 You can redefine the function ls-lisp-format-time.
For example, if I do this:
(defun ls-lisp-format-time (file-attr time-index now)
"################")
Then dired looks like this:
The original definition of the function is in ls-lisp.el.