Pdate

Материал из СисадминВики (SysadminWiki.ru)
Перейти к: навигация, поиск
Эта страница — перевод страницы Pdate. Перевод выполнен на 95%.

Другие языки:
English • ‎русский

Description

pDate is a console utility for Windows to format date output from 4000 BC to 4000 AC. It is a free and opensource software aimed to provide the same functionality as date utility in Linux and Unix-like OSs. It is comfortable to use in bat and cmd scripts.

pDate is issued under Public Domain licence and is free to use, change and redistribute without any limitation.


Download


Examples

1) Short day of the week and date:

pdate.exe "a D" Wed 19.10.2005


2) A day before yesterday:

pdate.exe "a d b" -2 Mon 17 Oct


3) Tomorrow:

pdate.exe "A B d" 1 Thursday October 20


4) Add any text to date by using symbol "\":

pdate.exe "\T\o\d\a\y \i\s D \w\h\i\c\h \i\s a" Today is 19.10.2005 which is Wed


5) Two lines output:

<nowiki>pdate.exe Y.m.d-H:M:S:NnD_T

2005.10.19-17:15:58:125

19.10.2005_17:15:58


Here is a script to build a date-based file name:

rem --- set and get variable %dm% with current date ---
pdate.exe "\s\e\t \d\m\=Y.M.d" >tmp.bat
call tmp.bat
del tmp.bat
set FileName=name_%dm%.log

For September 1st we will get variable FileName equal to name_2007.09.01.log.


Synopsis and keys

pdate.exe FORMAT [DAYS]

FORMAT controls the output and consists of the keys or other characters up to 255. Be aware of space character which is a delimiter for keys. If you want to use it in output use quotation marks ("). Keys are:

  • a - day of the week, short name (Mon..Sun)
  • A - day of the week, full name (Monday..Sunday)
  • b - month, short name(Jan..Dec)
  • B - month, full name(January..December)
  • c - date and time
  • C - age
  • d - day (01..31)
  • D - date (dd.mm.yy)
  • e - day (1..31)
  • F - same as "a D"
  • H - hour in 24 mode (00..23)
  • I - hour in 12 mode (00..12)
  • j - day of the year (001..366)
  • m - day of the month (01..12)
  • M - minute (00..59)
  • n - new line
  • N - millisecond (0..999)
  • p - AM/PM indicator
  • P - am/pm indicator
  • S - second(00..59)
  • T - time(hh:mm:ss)
  • u - day of the week (1..7), 1 = Monday
  • V - week of the year (01..53), first week counts as a whole one, i.e. no matter what day of the week was January 1st.
  • W - week of the year (00..52), how many 7-days periods, i.e. = days passed / 7
  • y - last two digits of the year (00..99)
  • Y - year
  • z - date and time if format 2006.01.31_05:38:45
  • Z - date and time if format 31.01.2006 05:38:45
  • ?,/? - help


DAYS day shift from today (see examples).

  • =0 today, default.
  • >0 future, i.e. 1 = tomorrow
  • <0 past, i.e. -1 = yesterday

For programmers

  • В программе создан свой тип pDate и pTime, для которых определены свои операторы сложения и вычитания.
  • Используются одно- и двухмерные массивы, числовые и строковые.
  • Есть функции преобразования типов.