Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Readme.md 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. # dateformat
  2. A node.js package for Steven Levithan's excellent [dateFormat()][dateformat] function.
  3. [![Build Status](https://travis-ci.org/felixge/node-dateformat.svg)](https://travis-ci.org/felixge/node-dateformat)
  4. ## Modifications
  5. - Removed the `Date.prototype.format` method. Sorry folks, but extending native prototypes is for suckers.
  6. - Added a `module.exports = dateFormat;` statement at the bottom
  7. - Added the placeholder `N` to get the ISO 8601 numeric representation of the day of the week
  8. ## Installation
  9. ```bash
  10. $ npm install dateformat
  11. $ dateformat --help
  12. ```
  13. ## Usage
  14. As taken from Steven's post, modified to match the Modifications listed above:
  15. ```js
  16. var dateFormat = require("dateformat");
  17. var now = new Date();
  18. // Basic usage
  19. dateFormat(now, "dddd, mmmm dS, yyyy, h:MM:ss TT");
  20. // Saturday, June 9th, 2007, 5:46:21 PM
  21. // You can use one of several named masks
  22. dateFormat(now, "isoDateTime");
  23. // 2007-06-09T17:46:21
  24. // ...Or add your own
  25. dateFormat.masks.hammerTime = 'HH:MM! "Can\'t touch this!"';
  26. dateFormat(now, "hammerTime");
  27. // 17:46! Can't touch this!
  28. // You can also provide the date as a string
  29. dateFormat("Jun 9 2007", "fullDate");
  30. // Saturday, June 9, 2007
  31. // Note that if you don't include the mask argument,
  32. // dateFormat.masks.default is used
  33. dateFormat(now);
  34. // Sat Jun 09 2007 17:46:21
  35. // And if you don't include the date argument,
  36. // the current date and time is used
  37. dateFormat();
  38. // Sat Jun 09 2007 17:46:22
  39. // You can also skip the date argument (as long as your mask doesn't
  40. // contain any numbers), in which case the current date/time is used
  41. dateFormat("longTime");
  42. // 5:46:22 PM EST
  43. // And finally, you can convert local time to UTC time. Simply pass in
  44. // true as an additional argument (no argument skipping allowed in this case):
  45. dateFormat(now, "longTime", true);
  46. // 10:46:21 PM UTC
  47. // ...Or add the prefix "UTC:" or "GMT:" to your mask.
  48. dateFormat(now, "UTC:h:MM:ss TT Z");
  49. // 10:46:21 PM UTC
  50. // You can also get the ISO 8601 week of the year:
  51. dateFormat(now, "W");
  52. // 42
  53. // and also get the ISO 8601 numeric representation of the day of the week:
  54. dateFormat(now, "N");
  55. // 6
  56. ```
  57. ### Mask options
  58. | Mask | Description |
  59. | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  60. | `d` | Day of the month as digits; no leading zero for single-digit days. |
  61. | `dd` | Day of the month as digits; leading zero for single-digit days. |
  62. | `ddd` | Day of the week as a three-letter abbreviation. |
  63. | `DDD` | "Ysd", "Tdy" or "Tmw" if date lies within these three days. Else fall back to ddd. |
  64. | `dddd` | Day of the week as its full name. |
  65. | `DDDD` | "Yesterday", "Today" or "Tomorrow" if date lies within these three days. Else fall back to dddd. |
  66. | `m` | Month as digits; no leading zero for single-digit months. |
  67. | `mm` | Month as digits; leading zero for single-digit months. |
  68. | `mmm` | Month as a three-letter abbreviation. |
  69. | `mmmm` | Month as its full name. |
  70. | `yy` | Year as last two digits; leading zero for years less than 10. |
  71. | `yyyy` | Year represented by four digits. |
  72. | `h` | Hours; no leading zero for single-digit hours (12-hour clock). |
  73. | `hh` | Hours; leading zero for single-digit hours (12-hour clock). |
  74. | `H` | Hours; no leading zero for single-digit hours (24-hour clock). |
  75. | `HH` | Hours; leading zero for single-digit hours (24-hour clock). |
  76. | `M` | Minutes; no leading zero for single-digit minutes. |
  77. | `MM` | Minutes; leading zero for single-digit minutes. |
  78. | `N` | ISO 8601 numeric representation of the day of the week. |
  79. | `o` | GMT/UTC timezone offset, e.g. -0500 or +0230. |
  80. | `p` | GMT/UTC timezone offset, e.g. -05:00 or +02:30. |
  81. | `s` | Seconds; no leading zero for single-digit seconds. |
  82. | `ss` | Seconds; leading zero for single-digit seconds. |
  83. | `S` | The date's ordinal suffix (st, nd, rd, or th). Works well with `d`. |
  84. | `l` | Milliseconds; gives 3 digits. |
  85. | `L` | Milliseconds; gives 2 digits. |
  86. | `t` | Lowercase, single-character time marker string: a or p. |
  87. | `tt` | Lowercase, two-character time marker string: am or pm. |
  88. | `T` | Uppercase, single-character time marker string: A or P. |
  89. | `TT` | Uppercase, two-character time marker string: AM or PM. |
  90. | `W` | ISO 8601 week number of the year, e.g. 4, 42 |
  91. | `WW` | ISO 8601 week number of the year, leading zero for single-digit, e.g. 04, 42 |
  92. | `Z` | US timezone abbreviation, e.g. EST or MDT. For non-US timezones, the GMT/UTC offset is returned, e.g. GMT-0500 |
  93. | `'...'`, `"..."` | Literal character sequence. Surrounding quotes are removed. |
  94. | `UTC:` | Must be the first four characters of the mask. Converts the date from local time to UTC/GMT/Zulu time before applying the mask. The "UTC:" prefix is removed. |
  95. ### Named Formats
  96. | Name | Mask | Example |
  97. | ----------------- | ------------------------------ | ------------------------ |
  98. | `default` | `ddd mmm dd yyyy HH:MM:ss` | Sat Jun 09 2007 17:46:21 |
  99. | `shortDate` | `m/d/yy` | 6/9/07 |
  100. | `paddedShortDate` | `mm/dd/yyyy` | 06/09/2007 |
  101. | `mediumDate` | `mmm d, yyyy` | Jun 9, 2007 |
  102. | `longDate` | `mmmm d, yyyy` | June 9, 2007 |
  103. | `fullDate` | `dddd, mmmm d, yyyy` | Saturday, June 9, 2007 |
  104. | `shortTime` | `h:MM TT` | 5:46 PM |
  105. | `mediumTime` | `h:MM:ss TT` | 5:46:21 PM |
  106. | `longTime` | `h:MM:ss TT Z` | 5:46:21 PM EST |
  107. | `isoDate` | `yyyy-mm-dd` | 2007-06-09 |
  108. | `isoTime` | `HH:MM:ss` | 17:46:21 |
  109. | `isoDateTime` | `yyyy-mm-dd'T'HH:MM:sso` | 2007-06-09T17:46:21+0700 |
  110. | `isoUtcDateTime` | `UTC:yyyy-mm-dd'T'HH:MM:ss'Z'` | 2007-06-09T22:46:21Z |
  111. ### Localization
  112. Day names, month names and the AM/PM indicators can be localized by
  113. passing an object with the necessary strings. For example:
  114. ```js
  115. var dateFormat = require("dateformat");
  116. dateFormat.i18n = {
  117. dayNames: [
  118. "Sun",
  119. "Mon",
  120. "Tue",
  121. "Wed",
  122. "Thu",
  123. "Fri",
  124. "Sat",
  125. "Sunday",
  126. "Monday",
  127. "Tuesday",
  128. "Wednesday",
  129. "Thursday",
  130. "Friday",
  131. "Saturday",
  132. ],
  133. monthNames: [
  134. "Jan",
  135. "Feb",
  136. "Mar",
  137. "Apr",
  138. "May",
  139. "Jun",
  140. "Jul",
  141. "Aug",
  142. "Sep",
  143. "Oct",
  144. "Nov",
  145. "Dec",
  146. "January",
  147. "February",
  148. "March",
  149. "April",
  150. "May",
  151. "June",
  152. "July",
  153. "August",
  154. "September",
  155. "October",
  156. "November",
  157. "December",
  158. ],
  159. timeNames: ["a", "p", "am", "pm", "A", "P", "AM", "PM"],
  160. };
  161. ```
  162. > Notice that only one language is supported at a time and all strings
  163. > _must_ be present in the new value.
  164. ### Breaking change in 2.1.0
  165. - 2.1.0 was published with a breaking change, for those using localized strings.
  166. - 2.2.0 has been published without the change, to keep packages refering to ^2.0.0 to continue working. This is now branch v2_2.
  167. - 3.0.\* contains the localized AM/PM change.
  168. ## License
  169. (c) 2007-2009 Steven Levithan [stevenlevithan.com][stevenlevithan], MIT license.
  170. [dateformat]: http://blog.stevenlevithan.com/archives/date-time-format
  171. [stevenlevithan]: http://stevenlevithan.com/