/usr/lib/swi-prolog/doc/Manual/system.html is in swi-prolog-nox 5.10.4-3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>SWI-Prolog 5.11.18 Reference Manual: Section 4.33</TITLE><LINK REL=home HREF="index.html">
<LINK REL=contents HREF="Contents.html">
<LINK REL=index HREF="DocIndex.html">
<LINK REL=summary HREF="summary.html">
<LINK REL=previous HREF="tty.html">
<LINK REL=next HREF="files.html">
<STYLE type="text/css">
/* Style sheet for SWI-Prolog latex2html
*/
dd.defbody
{ margin-bottom: 1em;
}
dt.pubdef
{ background-color: #c5e1ff;
}
dt.multidef
{ background-color: #c8ffc7;
}
.bib dd
{ margin-bottom: 1em;
}
.bib dt
{ float: left;
margin-right: 1.3ex;
}
pre.code
{ margin-left: 1.5em;
margin-right: 1.5em;
border: 1px dotted;
padding-top: 5px;
padding-left: 5px;
padding-bottom: 5px;
background-color: #f8f8f8;
}
div.navigate
{ text-align: center;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
}
div.title
{ text-align: center;
padding-bottom: 1em;
font-size: 200%;
font-weight: bold;
}
div.author
{ text-align: center;
font-style: italic;
}
div.abstract
{ margin-top: 2em;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
margin-left: 10%; margin-right:10%;
}
div.abstract-title
{ text-align: center;
padding: 5px;
font-size: 120%;
font-weight: bold;
}
div.toc-h1
{ font-size: 200%;
font-weight: bold;
}
div.toc-h2
{ font-size: 120%;
font-weight: bold;
margin-left: 2em;
}
div.toc-h3
{ font-size: 100%;
font-weight: bold;
margin-left: 4em;
}
div.toc-h4
{ font-size: 100%;
margin-left: 6em;
}
span.sec-nr
{
}
span.sec-title
{
}
span.pred-ext
{ font-weight: bold;
}
span.pred-tag
{ float: right;
padding-top: 0.2em;
font-size: 80%;
font-style: italic;
color: #202020;
}
/* Footnotes */
sup.fn { color: blue; text-decoration: underline; }
span.fn-text { display: none; }
sup.fn span {display: none;}
sup:hover span
{ display: block !important;
position: absolute; top: auto; left: auto; width: 80%;
color: #000; background: white;
border: 2px solid;
padding: 5px; margin: 10px; z-index: 100;
font-size: smaller;
}
</STYLE>
</HEAD>
<BODY BGCOLOR="white">
<DIV class="navigate"><A class="nav" href="index.html"><IMG SRC="home.gif" BORDER=0 ALT="Home"></A>
<A class="nav" href="Contents.html"><IMG SRC="index.gif" BORDER=0 ALT="Contents"></A>
<A class="nav" href="DocIndex.html"><IMG SRC="yellow_pages.gif" BORDER=0 ALT="Index"></A>
<A class="nav" href="summary.html"><IMG SRC="info.gif" BORDER=0 ALT="Summary"></A>
<A class="nav" href="tty.html"><IMG SRC="prev.gif" BORDER=0 ALT="Previous"></A>
<A class="nav" href="files.html"><IMG SRC="next.gif" BORDER=0 ALT="Next"></A>
</DIV>
<H2><A NAME="sec:4.33"><SPAN class="sec-nr">4.33</SPAN> <SPAN class="sec-title">Operating
System Interaction</SPAN></A></H2>
<A NAME="sec:system"></A>
<DL class="latex">
<DT class="pubdef"><A NAME="shell/2"><STRONG>shell</STRONG>(<VAR>+Command,
-Status</VAR>)</A></DT>
<DD class="defbody">
Execute <VAR>Command</VAR> on the operating system. <VAR>Command</VAR>
is given to the Bourne shell (/bin/sh). <VAR>Status</VAR> is unified
with the exit status of the command.
<P>On <VAR>Win32</VAR> systems, <A NAME="idx:shell12:1093"></A><A class="pred" href="system.html#shell/1">shell/[1,2]</A>
executes the command using the CreateProcess() API and waits for the
command to terminate. If the command ends with a <CODE>&</CODE>
sign, the command is handed to the WinExec() API, which does not wait
for the new task to terminate. See also <A NAME="idx:winexec2:1094"></A><A class="pred" href="system.html#win_exec/2">win_exec/2</A>
and <A NAME="idx:winshell2:1095"></A><A class="pred" href="system.html#win_shell/2">win_shell/2</A>.
Please note that the CreateProcess() API does <B>not</B> imply the
Windows command interpreter (<B>command.exe</B> on Windows 95/98 and <B>cmd.exe</B>
on Windows-NT) and therefore commands built-in to the
command-interpreter can only be activated using the command interpreter.
For example:
<CODE>'command.exe /C copy file1.txt file2.txt'</CODE></DD>
<DT class="pubdef"><A NAME="shell/1"><STRONG>shell</STRONG>(<VAR>+Command</VAR>)</A></DT>
<DD class="defbody">
Equivalent to `<CODE>shell(Command, 0)</CODE>'.</DD>
<DT class="pubdef"><A NAME="shell/0"><STRONG>shell</STRONG></A></DT>
<DD class="defbody">
Start an interactive Unix shell. Default is <CODE>/bin/sh</CODE>, the
environment variable <CODE>SHELL</CODE> overrides this default. Not
available for Win32 platforms.</DD>
<DT class="pubdef"><A NAME="win_exec/2"><STRONG>win_exec</STRONG>(<VAR>+Command,
+Show</VAR>)</A></DT>
<DD class="defbody">
Win32 systems only. Spawns a Windows task without waiting for its
completion. <VAR>Show</VAR> is one of the Win32 <CODE>SW_*</CODE>
constants written in lowercase without the <CODE>SW_*</CODE>:
<CODE>hide</CODE>
<CODE>maximize</CODE>
<CODE>minimize</CODE>
<CODE>restore</CODE>
<CODE>show</CODE>
<CODE>showdefault</CODE>
<CODE>showmaximized</CODE>
<CODE>showminimized</CODE>
<CODE>showminnoactive</CODE>
<CODE>showna</CODE>
<CODE>shownoactive</CODE>
<CODE>shownormal</CODE>. In addition, <CODE>iconic</CODE> is a synonym
for <CODE>minimize</CODE> and
<CODE>normal</CODE> for <CODE>shownormal</CODE></DD>
<DT class="pubdef"><A NAME="win_shell/2"><STRONG>win_shell</STRONG>(<VAR>+Operation,
+File, +Show</VAR>)</A></DT>
<DD class="defbody">
Win32 systems only. Opens the document <VAR>File</VAR> using the windows
shell-rules for doing so. <VAR>Operation</VAR> is one of <CODE>open</CODE>,
<CODE>print</CODE> or <CODE>explore</CODE> or another operation
registered with the shell for the given document-type. On modern systems
it is also possible to pass a <A NAME="idx:URL:1096"></A>URL as <VAR>File</VAR>,
opening the URL in Windows default browser. This call interfaces to the
Win32 API ShellExecute(). The <VAR>Show</VAR> argument determines the
initial state of the opened window (if any). See <A NAME="idx:winexec2:1097"></A><A class="pred" href="system.html#win_exec/2">win_exec/2</A>
for defined values.</DD>
<DT class="pubdef"><A NAME="win_shell/2"><STRONG>win_shell</STRONG>(<VAR>+Operation,
+File</VAR>)</A></DT>
<DD class="defbody">
Same as <CODE>win_shell(Operation, File, normal)</CODE></DD>
<DT class="pubdef"><A NAME="win_registry_get_value/3"><STRONG>win_registry_get_value</STRONG>(<VAR>+Key,
+Name, -Value</VAR>)</A></DT>
<DD class="defbody">
Win32 systems only. Fetches the value of a Win32 registry key.
<VAR>Key</VAR> is an atom formed as a path-name describing the desired
registry key. <VAR>Name</VAR> is the desired attribute name of the key.
<VAR>Value</VAR> is unified with the value. If the value is of type
<CODE>DWORD</CODE>, the value is returned as an integer. If the value is
a string it is returned as a Prolog atom. Other types are currently not
supported. The default `root' is <CODE>HKEY_CURRENT_USER</CODE>. Other
roots can be specified explicitly as <CODE>HKEY_CLASSES_ROOT</CODE>,
<CODE>HKEY_CURRENT_USER</CODE>, <CODE>HKEY_LOCAL_MACHINE</CODE> or
<CODE>HKEY_USERS</CODE>. The example below fetches the extension to use
for Prolog files (see <CODE>README.TXT</CODE> on the Windows version):
<PRE class="code">
?- win_registry_get_value('HKEY_LOCAL_MACHINE/Software/SWI/Prolog',
fileExtension,
Ext).
Ext = pl
</PRE>
</DD>
<DT class="pubdef"><A NAME="win_folder/2"><STRONG>win_folder</STRONG>(<VAR>?Name,
-Directory</VAR>)</A></DT>
<DD class="defbody">
Is true if <VAR>Name</VAR> is the Windows `CSIDL' of <VAR>Directory</VAR>.
If
<VAR>Name</VAR> is unbound all known Windows special paths are
generated.
<VAR>Name</VAR> is the CSIDL after deleting the leading <CODE>CSIDL_</CODE>
and mapping the constant to lowercase. Check the Windows documentation
for the function SHGetSpecialFolderPath() for a description of the
defined constants. This example extracts the `My Documents' folder:
<PRE class="code">
?- win_folder(personal, MyDocuments).
MyDocuments = 'C:/Documents and Settings/jan/My Documents'
</PRE>
</DD>
<DT class="pubdef"><A NAME="getenv/2"><STRONG>getenv</STRONG>(<VAR>+Name,
-Value</VAR>)</A></DT>
<DD class="defbody">
Get environment variable. Fails silently if the variable does not exist.
Please note that environment variable names are case-sensitive on Unix
systems and case-insensitive on Windows.</DD>
<DT class="pubdef"><A NAME="setenv/2"><STRONG>setenv</STRONG>(<VAR>+Name,
+Value</VAR>)</A></DT>
<DD class="defbody">
Set an environment variable. <VAR>Name</VAR> and <VAR>Value</VAR> must
be instantiated to atoms or integers. The environment variable will be
passed to <A NAME="idx:shell02:1098"></A><A class="pred" href="system.html#shell/0">shell/[0-2]</A>
and can be requested using <A NAME="idx:getenv2:1099"></A><A class="pred" href="system.html#getenv/2">getenv/2</A>.
They also influence <A NAME="idx:expandfilename2:1100"></A><A class="pred" href="files.html#expand_file_name/2">expand_file_name/2</A>.
Environment variables are shared between threads. Depending on the
underlying C library, <A NAME="idx:setenv2:1101"></A><A class="pred" href="system.html#setenv/2">setenv/2</A>
and <A NAME="idx:unsetenv1:1102"></A><A class="pred" href="system.html#unsetenv/1">unsetenv/1</A>
may not be thread-safe and may cause memory leaks. Only changing the
environment once and before starting threads is safe in all versions of
SWI-Prolog.</DD>
<DT class="pubdef"><A NAME="unsetenv/1"><STRONG>unsetenv</STRONG>(<VAR>+Name</VAR>)</A></DT>
<DD class="defbody">
Remove an environment variable from the environment. Some systems lack
the underlying unsetenv() library function. On these systems <A NAME="idx:unsetenv1:1103"></A><A class="pred" href="system.html#unsetenv/1">unsetenv/1</A>
sets the variable to the empty string.</DD>
<DT class="pubdef"><A NAME="setlocale/3"><STRONG>setlocale</STRONG>(<VAR>+Category,
-Old, +New</VAR>)</A></DT>
<DD class="defbody">
Set/Query the <EM>locale</EM> setting which tells the C-library how to
interpret text-files, write numbers, dates, etc. Category is one of
<CODE>all</CODE>, <CODE>collate</CODE>, <CODE>ctype</CODE>, <CODE>messages</CODE>,
<CODE>monetary</CODE>, <CODE>numeric</CODE> or <CODE>time</CODE>. For
details, please consult the C-library locale documentation. See also <A class="sec" href="widechars.html">section
2.17.1</A>. Please note that the locale is shared between all threads
and thread-safe usage of <A NAME="idx:setlocale3:1104"></A><A class="pred" href="system.html#setlocale/3">setlocale/3</A>
is in general not possible. Do locale operations before starting threads
or thoroughly study threading aspects of locale support in your
environment before use in multi-threaded environments. Locale settings
are used by <A NAME="idx:formattime3:1105"></A><A class="pred" href="system.html#format_time/3">format_time/3</A>, <A NAME="idx:collationkey2:1106"></A><A class="pred" href="chartype.html#collation_key/2">collation_key/2</A>
and <A NAME="idx:localesort2:1107"></A><A class="pred" href="chartype.html#locale_sort/2">locale_sort/2</A>.</DD>
<DT class="pubdef"><A NAME="unix/1"><STRONG>unix</STRONG>(<VAR>+Command</VAR>)</A></DT>
<DD class="defbody">
This predicate comes from the Quintus compatibility library and provides
a partial implementation thereof. It provides access to some operating
system features and unlike the name suggests, is not operating system
specific. Defined <VAR>Command</VAR>'s are below.
<DL class="latex">
<DT><STRONG>system</STRONG>(<VAR>+Command</VAR>)</DT>
<DD class="defbody">
Equivalent to calling <A NAME="idx:shell1:1108"></A><A class="pred" href="system.html#shell/1">shell/1</A>.
Use for compatibility only.</DD>
<DT><STRONG>shell</STRONG>(<VAR>+Command</VAR>)</DT>
<DD class="defbody">
Equivalent to calling <A NAME="idx:shell1:1109"></A><A class="pred" href="system.html#shell/1">shell/1</A>.
Use for compatibility only.</DD>
<DT><STRONG>shell</STRONG></DT>
<DD class="defbody">
Equivalent to calling <A NAME="idx:shell0:1110"></A><A class="pred" href="system.html#shell/0">shell/0</A>.
Use for compatibility only.</DD>
<DT><STRONG>cd</STRONG></DT>
<DD class="defbody">
Equivalent to calling <A NAME="idx:workingdirectory2:1111"></A><A class="pred" href="files.html#working_directory/2">working_directory/2</A>
to the expansion (see
<A NAME="idx:expandfilename2:1112"></A><A class="pred" href="files.html#expand_file_name/2">expand_file_name/2</A>)
of <CODE><CODE>~</CODE></CODE>. For compatibility only.</DD>
<DT><STRONG>cd</STRONG>(<VAR>+Directory</VAR>)</DT>
<DD class="defbody">
Equivalent to calling <A NAME="idx:workingdirectory2:1113"></A><A class="pred" href="files.html#working_directory/2">working_directory/2</A>.
Use for compatibility only.</DD>
<DT><STRONG>argv</STRONG>(<VAR>-Argv</VAR>)</DT>
<DD class="defbody">
Unify <VAR>Argv</VAR> with the list of command-line arguments provides
to this Prolog run. Please note that Prolog system-arguments and
application arguments are separated by <CODE>--</CODE>. Integer
arguments are passed as Prolog integers, float arguments and Prolog
floating point numbers and all other arguments as Prolog atoms. New
applications should use the Prolog flag <A class="flag" href="flags.html#flag:argv">argv</A>.
See also prolog Prolog flag
<A class="flag" href="flags.html#flag:argv">argv</A>.
<P>A stand-alone program could use the following skeleton to handle
command-line arguments. See also <A class="sec" href="compilation.html">section
2.10.2.4</A>.
<PRE class="code">
main :-
current_prolog_flag(argv, Argv),
append(_PrologArgs, [--|AppArgs], Argv), !,
main(AppArgs).
</PRE>
<P></DD>
</DL>
</DD>
</DL>
<H3><A NAME="sec:4.33.1"><SPAN class="sec-nr">4.33.1</SPAN> <SPAN class="sec-title">Dealing
with time and date</SPAN></A></H3>
<A NAME="sec:timedate"></A>
<P>Representing time in a computer system is surprisingly complicated.
There are a large number of time representations in use and the correct
choice depends on factors such as compactness, resolution and desired
operations. Humans tend to think about time in hours, days, months,
years or centuries. Physicists think about time in seconds. But, a month
does not have a defined number of seconds. Even a day does not have a
defined number of seconds as sometimes a leap-second is introduced to
synchronise properly with our earth's rotation. At the same time,
resolution demands range from better then pico-seconds to millions of
years. Finally, civilizations have a wide range of calendars. Although
there exist libraries dealing with most if this complexity, our desire
to keep Prolog clean and lean stops us from fully supporting these.
<P>For human-oriented tasks, time can be broken into years, months,
days, hours, minutes, seconds and a timezone. Physicists prefer to have
time in an arithmetic type representing seconds or fraction thereof, so
basic arithmetic deal with comparison and durations. An additional
advantage of the physicists approach is that it requires much less
space. For these reasons, SWI-Prolog uses an arithmetic type as its
prime time representation.
<P>Many C libraries deal with time using fixed-point arithmetic, dealing
with a large but finite time interval at constant resolution. In our
opinion using a floating point number is a more natural choice as we can
use a natural unit and the interface does not need to be changed if a
higher resolution is required in the future. Our unit of choice is the
second as it is the scientific unit.<SUP class="fn">68<SPAN class="fn-text">Using
Julian days is a choice made by the Eclipse team. As conversion to dates
is needed for a human readable notation of time and Julian days cannot
deal naturally with leap seconds, we decided for second as our unit.</SPAN></SUP>
We have placed our origin at 1970-1-1T0:0:0Z for compatibility with the
POSIX notion of time as well as with older time support provided by
SWI-Prolog.
<P>Where older versions of SWI-Prolog relied on the POSIX conversion
functions, the current implementation uses
<A class="url" href="http://cr.yp.to/libtai.html">libtai</A> to realise
conversion between time-stamps and calendar dates for a period of 10
million years.
<H4><A NAME="sec:4.33.1.1"><SPAN class="sec-nr">4.33.1.1</SPAN> <SPAN class="sec-title">Time
and date data-structures</SPAN></A></H4>
<A NAME="sec:dattimedata"></A>
<P>We use the following time representations
<DL class="latex">
<DT><B>TimeStamp</B></DT>
<DD class="defbody">
A TimeStamp is a floating point number expression the time in seconds
since the Epoch at 1970-1-1.</DD>
<DT><STRONG>date</STRONG>(<VAR>Y,M,D,H,Mn,S,Off,TZ,DST</VAR>)</DT>
<DD class="defbody">
We call this term a <EM>date-time</EM> structure. The first 5 fields are
integers expressing the year, month (1..12), day (1..31), hour (0..23),
Minute (0..59). The <VAR>S</VAR> field holds the seconds as a floating
point number between 0.0 and 60.0. <VAR>Off</VAR> is an integer
representing the offset relative to UTC in seconds where positive values
are west of Greenwich. If converted from local time (see <A NAME="idx:stampdatetime3:1114"></A><A class="pred" href="system.html#stamp_date_time/3">stamp_date_time/3</A>,
<VAR>TZ</VAR> holds the name of the local timezone. If the timezone is
not known <VAR>TZ</VAR> is the atom <CODE><CODE>-</CODE></CODE>. <VAR>DST</VAR>
is <CODE>true</CODE> if daylight saving time applies to the current
time, <CODE>false</CODE> if daylight saving time is relevant but not
effective and <CODE><CODE>-</CODE></CODE> if unknown or the timezone has
no daylight saving time.</DD>
<DT><STRONG>date</STRONG>(<VAR>Y,M.D</VAR>)</DT>
<DD class="defbody">
Date using the same values as described above. Extracted using
<A NAME="idx:datetimevalue3:1115"></A><A class="pred" href="system.html#date_time_value/3">date_time_value/3</A>.</DD>
<DT><STRONG>time</STRONG>(<VAR>H,Mn,S</VAR>)</DT>
<DD class="defbody">
Time using the same values as described above. Extracted using
<A NAME="idx:datetimevalue3:1116"></A><A class="pred" href="system.html#date_time_value/3">date_time_value/3</A>.
</DD>
</DL>
<H4><A NAME="sec:4.33.1.2"><SPAN class="sec-nr">4.33.1.2</SPAN> <SPAN class="sec-title">Time
and date predicates</SPAN></A></H4>
<A NAME="sec:datimepreds"></A>
<DL class="latex">
<DT class="pubdef"><A NAME="get_time/1"><STRONG>get_time</STRONG>(<VAR>-TimeStamp</VAR>)</A></DT>
<DD class="defbody">
Return the current time as a <VAR>TimeStamp</VAR>. The granularity is
system dependent. See <A class="sec" href="system.html">section 4.33.1.1</A>.</DD>
<DT class="pubdef"><A NAME="stamp_date_time/3"><STRONG>stamp_date_time</STRONG>(<VAR>+TimeStamp,
-DateTime, +TimeZone</VAR>)</A></DT>
<DD class="defbody">
Convert a <VAR>TimeStamp</VAR> to a <VAR>DateTime</VAR> in the given
time zone. See <A class="sec" href="system.html">section 4.33.1.1</A>
for details on the data-types. <VAR>TimeZone</VAR> describes the
timezone for the conversion. It is one of <CODE>local</CODE> to extract
the local time, <CODE>'UTC'</CODE> to extract at UTC time or an integer
describing the seconds west of Greenwich.</DD>
<DT class="pubdef"><A NAME="date_time_stamp/2"><STRONG>date_time_stamp</STRONG>(<VAR>+DateTime,
-TimeStamp</VAR>)</A></DT>
<DD class="defbody">
Compute the timestamp from a date/9 term. Values for month, day, hour,
minute or second need not be normalized. This flexibility allows for
easy computation of the time at any given number of these units from a
given timestamp. Normalization can be achieved following this call with <A NAME="idx:stampdatetime3:1117"></A><A class="pred" href="system.html#stamp_date_time/3">stamp_date_time/3</A>.
This example computes the date 200 days after 2006-7-14:
<PRE class="code">
?- date_time_stamp(date(2006,7,214,0,0,0,0,-,-), Stamp),
stamp_date_time(Stamp, D, 0),
date_time_value(date, D, Date).
Date = date(2007, 1, 30)
</PRE>
</DD>
<DT class="pubdef"><A NAME="date_time_value/3"><STRONG>date_time_value</STRONG>(<VAR>?Key,
+DateTime, ?Value</VAR>)</A></DT>
<DD class="defbody">
Extract values from a date/9 term. Provided keys are:
<P>
<CENTER>
<TABLE BORDER=2 FRAME=hsides RULES=groups>
<TR VALIGN=top><TD><B>key</B></TD><TD><B>value </B></TD></TR>
<TBODY>
<TR VALIGN=top><TD><CODE>year</CODE> </TD><TD>Calendar year as an
integer </TD></TR>
<TR VALIGN=top><TD><CODE>month</CODE> </TD><TD>Calendar month as an
integer 1..12 </TD></TR>
<TR VALIGN=top><TD><CODE>day</CODE> </TD><TD>Calendar day as an integer
1..31 </TD></TR>
<TR VALIGN=top><TD><CODE>hour</CODE> </TD><TD>Clock hour as an integer
0..23 </TD></TR>
<TR VALIGN=top><TD><CODE>minute</CODE> </TD><TD>Clock minute as an
integer 0..59 </TD></TR>
<TR VALIGN=top><TD><CODE>second</CODE> </TD><TD>Clock second as a float
0.0..60.0 </TD></TR>
<TR VALIGN=top><TD><CODE>utc_offset</CODE> </TD><TD>Offset to UTC in
seconds (positive is west) </TD></TR>
<TR VALIGN=top><TD><CODE>time_zone</CODE> </TD><TD>Name of timezone;
fails if unknown </TD></TR>
<TR VALIGN=top><TD><CODE>daylight_saving</CODE> </TD><TD>Bool <CODE>daylight_saving</CODE>true)
if dst is effective </TD></TR>
<TR VALIGN=top><TD><CODE>date</CODE> </TD><TD>Term <CODE>date(Y,M,D)</CODE> </TD></TR>
<TR VALIGN=top><TD><CODE>time</CODE> </TD><TD>Term <CODE>time(H,M,S)</CODE> </TD></TR>
</TABLE>
</CENTER>
</DD>
<DT class="pubdef"><A NAME="format_time/3"><STRONG>format_time</STRONG>(<VAR>+Out,
+Format, +StampOrDateTime</VAR>)</A></DT>
<DD class="defbody">
Modelled after POSIX strftime(), using GNU extensions. <VAR>Out</VAR> is
a destination as specified with <A NAME="idx:withoutputto2:1118"></A><A class="pred" href="IO.html#with_output_to/2">with_output_to/2</A>. <VAR>Format</VAR>
is an atom or string with the following conversions. Conversions start
with a tilde (%) character.<SUP class="fn">69<SPAN class="fn-text">Descriptions
taken from Linux Programmer's Manual</SPAN></SUP>
<VAR>StampOrDateTime</VAR> is either a (numeric time-stamp, a term
<CODE>date(Y,M,D,H,M,S,O,TZ,DST)</CODE> or a term <CODE>date(Y,M,D)</CODE>.
<P>
<UL class="latex">
<LI><CODE>a</CODE><BR>
The abbreviated weekday name according to the current locale. Use
<A NAME="idx:formattime4:1119"></A><A class="pred" href="system.html#format_time/4">format_time/4</A>
for POSIX locale.
<LI><CODE>A</CODE><BR>
The full weekday name according to the current locale. Use
<A NAME="idx:formattime4:1120"></A><A class="pred" href="system.html#format_time/4">format_time/4</A>
for POSIX locale.
<LI><CODE>b</CODE><BR>
The abbreviated month name according to the current locale. Use
<A NAME="idx:formattime4:1121"></A><A class="pred" href="system.html#format_time/4">format_time/4</A>
for POSIX locale.
<LI><CODE>B</CODE><BR>
The full month name according to the current locale. Use
<A NAME="idx:formattime4:1122"></A><A class="pred" href="system.html#format_time/4">format_time/4</A>
for POSIX locale.
<LI><CODE>c</CODE><BR>
The preferred date and time representation for the current locale.
<LI><CODE>C</CODE><BR>
The century number (year/100) as a 2-digit integer.
<LI><CODE>d</CODE><BR>
The day of the month as a decimal number (range 01 to 31).
<LI><CODE>D</CODE><BR>
Equivalent to %m/%d/%y. (Yecch — for Americans only. Americans should
note that in other countries %d/%m/%y is rather common. This means that
in international context this format is ambiguous and should not be
used.)
<LI><CODE>e</CODE><BR>
Like %d, the day of the month as a decimal number, but a leading zero is
replaced by a space.
<LI><CODE>E</CODE><BR>
Modifier. Not implemented.
<LI><CODE>f</CODE><BR>
Number of microseconds. The <CODE>f</CODE> can be prefixed by an integer
to print the desired number of digits. E.g., <CODE>%3f</CODE> prints
milliseconds. This format is not covered by any standard, but available
with different format-specifiers in various incarnations of the
strftime() function.
<LI><CODE>F</CODE><BR>
Equivalent to %Y-%m-%d (the ISO 8601 date format).
<LI><CODE>g</CODE><BR>
Like %G, but without century, i.e., with a 2-digit year (00-99).
<LI><CODE>G</CODE><BR>
The ISO 8601 year with century as a decimal number. The 4-digit year
corresponding to the ISO week number (see %V). This has the same format
and value as %y, except that if the ISO week number belongs to the
previous or next year, that year is used instead.
<LI><CODE>V</CODE><BR>
The ISO 8601:1988 week number of the current year as a decimal number,
range 01 to 53, where week 1 is the first week that has at least 4 days
in the current year, and with Monday as the first day of the week. See
also %U and %W.
<LI><CODE>h</CODE><BR>
Equivalent to %b.
<LI><CODE>H</CODE><BR>
The hour as a decimal number using a 24-hour clock (range 00 to 23).
<LI><CODE>I</CODE><BR>
The hour as a decimal number using a 12-hour clock (range 01 to 12).
<LI><CODE>j</CODE><BR>
The day of the year as a decimal number (range 001 to 366).
<LI><CODE>k</CODE><BR>
The hour (24-hour clock) as a decimal number (range 0 to 23); single
digits are preceded by a blank. (See also %H.)
<LI><CODE>l</CODE><BR>
The hour (12-hour clock) as a decimal number (range 1 to 12); single
digits are preceded by a blank. (See also %I.)
<LI><CODE>m</CODE><BR>
The month as a decimal number (range 01 to 12).
<LI><CODE>M</CODE><BR>
The minute as a decimal number (range 00 to 59).
<LI><CODE>n</CODE><BR>
A newline character.
<LI><CODE>O</CODE><BR>
Modifier to select locale-specific output. Not implemented.
<LI><CODE>p</CODE><BR>
Either `AM' or `PM' according to the given time value, or the
corresponding strings for the current locale. Noon is treated as `pm'
and midnight as `am'.
<LI><CODE>P</CODE><BR>
Like %p but in lowercase: `am' or `pm' or a corresponding string for the
current locale.
<LI><CODE>r</CODE><BR>
The time in a.m. or p.m. notation. In the POSIX locale this is
equivalent to `%I:%M:%S %p'.
<LI><CODE>R</CODE><BR>
The time in 24-hour notation (%H:%M). For a version including the
seconds, see %T below.
<LI><CODE>s</CODE><BR>
The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00
UTC.
<LI><CODE>S</CODE><BR>
The second as a decimal number (range 00 to 60). (The range is up to 60
to allow for occasional leap seconds.)
<LI><CODE>t</CODE><BR>
A tab character.
<LI><CODE>T</CODE><BR>
The time in 24-hour notation (%H:%M:%S).
<LI><CODE>u</CODE><BR>
The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w.
<LI><CODE>U</CODE><BR>
The week number of the current year as a decimal number, range 00 to 53,
starting with the first Sunday as the first day of week 01. See also %V
and %W.
<LI><CODE>w</CODE><BR>
The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u.
<LI><CODE>W</CODE><BR>
The week number of the current year as a decimal number, range 00 to 53,
starting with the first Monday as the first day of week 01.
<LI><CODE>x</CODE><BR>
The preferred date representation for the current locale without the
time.
<LI><CODE>X</CODE><BR>
The preferred time representation for the current locale without the
date.
<LI><CODE>y</CODE><BR>
The year as a decimal number without a century (range 00 to 99).
<LI><CODE>Y</CODE><BR>
The year as a decimal number including the century.
<LI><CODE>z</CODE><BR>
The time-zone as hour offset from GMT using the format HHmm. Required to
emit RFC822-conforming dates (using
<TT>'%a, %d %b %Y %T %z'</TT>). Our
implementation supports
<TT>%:z</TT>, which modifies the output to HH:mm as required by
XML-Schema. Note that both notations are valid in ISO8601. The sequence <TT>%:z</TT>
is compatible to the GNU date(1) command.
<LI><CODE>Z</CODE><BR>
The time zone or name or abbreviation.
<LI><CODE><CODE>+</CODE></CODE><BR>
The date and time in date(1) format.
<LI><CODE>%</CODE><BR>
A literal `%' character.
</UL>
<P>The table below, gives some format strings for popular time
representations. RFC1123 is used by HTTP. The full implementation of
<A NAME="idx:httptimestamp2:1123"></A><SPAN class="pred-ext">http_timestamp/2</SPAN>
as available from <CODE>library(http/http_header)</CODE> is here.
<PRE class="code">
http_timestamp(Time, Atom) :-
stamp_date_time(Time, Date, 'UTC'),
format_time(atom(Atom),
'%a, %d %b %Y %T GMT',
Date, posix).
</PRE>
<P>
<CENTER>
<TABLE BORDER=2 FRAME=hsides RULES=groups>
<TR VALIGN=top><TD><B>Standard</B> </TD><TD><B>Format string</B> </TD></TR>
<TBODY>
<TR VALIGN=top><TD><B>xsd</B> </TD><TD><TT>'%FT%T%:z'</TT> </TD></TR>
<TR VALIGN=top><TD><B>ISO8601</B> </TD><TD><TT>'%FT%T%z'</TT> </TD></TR>
<TR VALIGN=top><TD><B>RFC822</B> </TD><TD><TT>'%a, %d %b %Y %T %z'</TT> </TD></TR>
<TR VALIGN=top><TD><B>RFC1123</B> </TD><TD><TT>'%a, %d %b %Y %T GMT'</TT> </TD></TR>
</TABLE>
</CENTER>
</DD>
<DT class="pubdef"><A NAME="format_time/4"><STRONG>format_time</STRONG>(<VAR>+Out,
+Format, +StampOrDateTime, +Locale</VAR>)</A></DT>
<DD class="defbody">
Format time given a specified <VAR>Locale</VAR>. This predicate is a
work-around for lacking proper portable and thread-safe time and locale
handling in current C libraries. In its current implementation the only
value allowed for <VAR>Locale</VAR> is <CODE>posix</CODE>, which
currently only modifies the behaviour or the <CODE>a</CODE>, <CODE>A</CODE>, <CODE>b</CODE>
and <CODE>B</CODE> format specifiers. The predicate is used to be able
to emit POSIX locale week and month names for emitting standardised
time-stamps such as RFC1123.</DD>
<DT class="pubdef"><A NAME="parse_time/2"><STRONG>parse_time</STRONG>(<VAR>+Text,
-Stamp</VAR>)</A></DT>
<DD class="defbody">
Same as <CODE>parse_time(Text, _Format, Stamp)</CODE>. See <A NAME="idx:parsetime3:1124"></A><A class="pred" href="system.html#parse_time/3">parse_time/3</A>.</DD>
<DT class="pubdef"><A NAME="parse_time/3"><STRONG>parse_time</STRONG>(<VAR>+Text,
?Format, -Stamp</VAR>)</A></DT>
<DD class="defbody">
Parse a textual time representation, producing a time-stamp. Supported
formats for <VAR>Text</VAR> are in the table below. If the format is
known, it may be given to reduce parse-time and avoid ambiguities.
Otherwise,
<VAR>Format</VAR> is unified with the format encountered.
<P>
<CENTER>
<TABLE BORDER=2 FRAME=box RULES=groups>
<TR VALIGN=top><TD><B>Name</B></TD><TD><B>Example </B></TD></TR>
<TBODY>
<TR VALIGN=top><TD>rfc_1123</TD><TD><TT>Fri, 08 Dec 2006 15:29:44 GMT </TT></TD></TR>
<TBODY>
<TR VALIGN=top><TD>iso_8601</TD><TD><TT>2006-12-08T17:29:44+02:00 </TT></TD></TR>
<TR VALIGN=top><TD></TD><TD><TT>20061208T172944+0200 </TT></TD></TR>
<TR VALIGN=top><TD></TD><TD><TT>2006-12-08T15:29Z </TT></TD></TR>
<TR VALIGN=top><TD></TD><TD><TT>2006-12-08 </TT></TD></TR>
<TR VALIGN=top><TD></TD><TD><TT>20061208 </TT></TD></TR>
<TR VALIGN=top><TD></TD><TD><TT>2006-12 </TT></TD></TR>
<TR VALIGN=top><TD></TD><TD><TT>2006-W49-5 </TT></TD></TR>
<TR VALIGN=top><TD></TD><TD><TT>2006-342 </TT></TD></TR>
</TABLE>
</CENTER>
</DD>
<DT class="pubdef"><A NAME="day_of_the_week/2"><STRONG>day_of_the_week</STRONG>(<VAR>+Date,-DayOfTheWeek</VAR>)</A></DT>
<DD class="defbody">
Computes the day of the week for a given date.
<CODE><VAR>Date</VAR> = date(<VAR>Year</VAR>,<VAR>Month</VAR>,<VAR>Day</VAR>)</CODE>,
Days of the week are numbered from one to seven: monday = 1, tuesday =
2, ... , sunday = 7.
</DD>
</DL>
<H3><A NAME="sec:4.33.2"><SPAN class="sec-nr">4.33.2</SPAN> <SPAN class="sec-title">Controlling
the <B>swipl-win.exe</B> console window</SPAN></A></H3>
<A NAME="sec:plwin"></A>
<P>The Windows executable <B>swipl-win.exe</B> console has a number of
predicates to control the appearance of the console. Being totally
non-portable, we do not advice using it for your own application, but
use XPCE or another portable GUI platform instead. We give the
predicates for reference here.
<DL class="latex">
<DT class="pubdef"><A NAME="window_title/2"><STRONG>window_title</STRONG>(<VAR>-Old,
+New</VAR>)</A></DT>
<DD class="defbody">
Unify <VAR>Old</VAR> with the title displayed in the console and change
the title to <VAR>New</VAR>.<SUP class="fn">bug<SPAN class="fn-text">This
predicate should have been called <CODE>win_window_title</CODE> for
consistent naming.</SPAN></SUP></DD>
<DT class="pubdef"><A NAME="win_window_pos/1"><STRONG>win_window_pos</STRONG>(<VAR>+ListOfOptions</VAR>)</A></DT>
<DD class="defbody">
Interface to the MS-Windows SetWindowPos() function, controlling size,
position and stacking order of the window. <VAR>ListOfOptions</VAR> is a
list that may hold any number of the terms below.
<DL class="latex">
<DT><STRONG>size</STRONG>(<VAR>W, H</VAR>)</DT>
<DD class="defbody">
Change the size of the window. <VAR>W</VAR> and <VAR>H</VAR> are
expressed in character-units.
</DD>
<DT><STRONG>position</STRONG>(<VAR>X, Y</VAR>)</DT>
<DD class="defbody">
Change the top-left corner of the window. The values are expressed in
pixel units.
</DD>
<DT><STRONG>zorder</STRONG>(<VAR>ZOrder</VAR>)</DT>
<DD class="defbody">
Change the location in the window stacking order. Values are
<CODE>bottom</CODE>, <CODE>top</CODE>, <CODE>topmost</CODE> and <CODE>notopmost</CODE>.
<EM>Topmost</EM> windows are displayed above all other windows.
</DD>
<DT><STRONG>show</STRONG>(<VAR>Bool</VAR>)</DT>
<DD class="defbody">
If <CODE>true</CODE>, show the window, if <CODE>false</CODE> hide the
window.
</DD>
<DT><STRONG>activate</STRONG></DT>
<DD class="defbody">
If present, activate the window.
</DD>
</DL>
</DD>
<DT class="pubdef"><A NAME="win_has_menu/0"><STRONG>win_has_menu</STRONG></A></DT>
<DD class="defbody">
True if <A NAME="idx:wininsertmenu2:1125"></A><A class="pred" href="system.html#win_insert_menu/2">win_insert_menu/2</A>
and <A NAME="idx:wininsertmenuitem4:1126"></A><A class="pred" href="system.html#win_insert_menu_item/4">win_insert_menu_item/4</A>
are present.</DD>
<DT class="pubdef"><A NAME="win_insert_menu/2"><STRONG>win_insert_menu</STRONG>(<VAR>+Label,
+Before</VAR>)</A></DT>
<DD class="defbody">
Insert a new entry (pulldown) in the menu. If the menu already contains
this entry, nothing is done. The <VAR>Label</VAR> is the label and using
the Windows conventions, a letter prefixed with <CODE>&</CODE> is
underlined and defines the associated accelerator key. <VAR>Before</VAR>
is the label before which this one must be inserted. Using <CODE><CODE>-</CODE></CODE>
adds the new entry at the end (right). For example, the call below adds
a <B>Application</B> entry just before the <B>Help</B> menu.
<PRE class="code">
win_insert_menu('&Application', '&Help')
</PRE>
</DD>
<DT class="pubdef"><A NAME="win_insert_menu_item/4"><STRONG>win_insert_menu_item</STRONG>(<VAR>+Pulldown,
+Label, +Before, :Goal</VAR>)</A></DT>
<DD class="defbody">
Add an item to the named <VAR>Pulldown</VAR> menu. <VAR>Label</VAR> and
<VAR>Before</VAR> are handled as in <A NAME="idx:wininsertmenu2:1127"></A><A class="pred" href="system.html#win_insert_menu/2">win_insert_menu/2</A>,
but the label <CODE><CODE>-</CODE></CODE> inserts a <EM>separator</EM>. <VAR>Goal</VAR>
is called if the user selects the item.
</DD>
</DL>
<P></BODY></HTML>
|