Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
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.

162 lines
5.9 KiB

  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. `dddd` | Day of the week as its full name.
  64. `m` | Month as digits; no leading zero for single-digit months.
  65. `mm` | Month as digits; leading zero for single-digit months.
  66. `mmm` | Month as a three-letter abbreviation.
  67. `mmmm` | Month as its full name.
  68. `yy` | Year as last two digits; leading zero for years less than 10.
  69. `yyyy` | Year represented by four digits.
  70. `h` | Hours; no leading zero for single-digit hours (12-hour clock).
  71. `hh` | Hours; leading zero for single-digit hours (12-hour clock).
  72. `H` | Hours; no leading zero for single-digit hours (24-hour clock).
  73. `HH` | Hours; leading zero for single-digit hours (24-hour clock).
  74. `M` | Minutes; no leading zero for single-digit minutes.
  75. `MM` | Minutes; leading zero for single-digit minutes.
  76. `N` | ISO 8601 numeric representation of the day of the week.
  77. `o` | GMT/UTC timezone offset, e.g. -0500 or +0230.
  78. `s` | Seconds; no leading zero for single-digit seconds.
  79. `ss` | Seconds; leading zero for single-digit seconds.
  80. `S` | The date's ordinal suffix (st, nd, rd, or th). Works well with `d`.
  81. `l` | Milliseconds; gives 3 digits.
  82. `L` | Milliseconds; gives 2 digits.
  83. `t` | Lowercase, single-character time marker string: a or p.
  84. `tt` | Lowercase, two-character time marker string: am or pm.
  85. `T` | Uppercase, single-character time marker string: A or P.
  86. `TT` | Uppercase, two-character time marker string: AM or PM.
  87. `W` | ISO 8601 week number of the year, e.g. 42
  88. `Z` | US timezone abbreviation, e.g. EST or MDT. With non-US timezones or in the
  89. `'...'`, `"..."` | Literal character sequence. Surrounding quotes are removed.
  90. `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.
  91. ### Named Formats
  92. Name | Mask | Example
  93. ---- | ---- | -------
  94. `default` | `ddd mmm dd yyyy HH:MM:ss` | Sat Jun 09 2007 17:46:21
  95. `shortDate` | `m/d/yy` | 6/9/07
  96. `mediumDate` | `mmm d, yyyy` | Jun 9, 2007
  97. `longDate` | `mmmm d, yyyy` | June 9, 2007
  98. `fullDate` | `dddd, mmmm d, yyyy` | Saturday, June 9, 2007
  99. `shortTime` | `h:MM TT` | 5:46 PM
  100. `mediumTime` | `h:MM:ss TT` | 5:46:21 PM
  101. `longTime` | `h:MM:ss TT Z` | 5:46:21 PM EST
  102. `isoDate` | `yyyy-mm-dd` | 2007-06-09
  103. `isoTime` | `HH:MM:ss` | 17:46:21
  104. `isoDateTime` | `yyyy-mm-dd'T'HH:MM:ss` | 2007-06-09T17:46:21
  105. `isoUtcDateTime` | `UTC:yyyy-mm-dd'T'HH:MM:ss'Z'` | 2007-06-09T22:46:21Z
  106. ### Localization
  107. Day names, month names and the AM/PM indicators can be localized by
  108. passing an object with the necessary strings. For example:
  109. ```js
  110. var dateFormat = require('dateformat');
  111. dateFormat.i18n = {
  112. dayNames: [
  113. 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',
  114. 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
  115. ],
  116. monthNames: [
  117. 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
  118. 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
  119. ],
  120. timeNames: [
  121. 'a', 'p', 'am', 'pm', 'A', 'P', 'AM', 'PM'
  122. ]
  123. };
  124. ```
  125. > Notice that only one language is supported at a time and all strings
  126. > *must* be present in the new value.
  127. ### Breaking change in 2.1.0
  128. - 2.1.0 was published with a breaking change, for those using localized strings.
  129. - 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.
  130. - 3.0.* contains the localized AM/PM change.
  131. ## License
  132. (c) 2007-2009 Steven Levithan [stevenlevithan.com][stevenlevithan], MIT license.
  133. [dateformat]: http://blog.stevenlevithan.com/archives/date-time-format
  134. [stevenlevithan]: http://stevenlevithan.com/