tango.text.locale.Convert

License:

BSD style: see license.txt

Version:

Initial release: 2005

Author:

John Chapman
char[] formatDateTime(char[] output, Time dateTime, const(char)[] format, IFormatService formatService = null) [public]
Converts the value of this instance to its equivalent string representation using the specified _format and culture-specific formatting information.

Parameters:

formatA _format string.
formatServiceAn IFormatService that provides culture-specific formatting information.

Returns:

A string representation of the value of this instance as specified by format and formatService.

Remarks:

See Time Formatting for more information about date and time formatting.

Examples:

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
import tango.io.Print, tango.text.locale.Core, tango.time.WallClock;

void main() {
  Culture culture = Culture.current;
  Time now = WallClock.now;

  Println("Current date and time: %s", now.toString());
  Println();

  // Format the current date and time in a number of ways.
  Println("Culture: %s", culture.englishName);
  Println();

  Println("Short date:              %s", now.toString("d"));
  Println("Long date:               %s", now.toString("D"));
  Println("Short time:              %s", now.toString("t"));
  Println("Long time:               %s", now.toString("T"));
  Println("General date short time: %s", now.toString("g"));
  Println("General date long time:  %s", now.toString("G"));
  Println("Month:                   %s", now.toString("M"));
  Println("RFC1123:                 %s", now.toString("R"));
  Println("Sortable:                %s", now.toString("s"));
  Println("Year:                    %s", now.toString("Y"));
  Println();

  // Display the same values using a different culture.
  culture = Culture.getCulture("fr-FR");
  Println("Culture: %s", culture.englishName);
  Println();

  Println("Short date:              %s", now.toString("d", culture));
  Println("Long date:               %s", now.toString("D", culture));
  Println("Short time:              %s", now.toString("t", culture));
  Println("Long time:               %s", now.toString("T", culture));
  Println("General date short time: %s", now.toString("g", culture));
  Println("General date long time:  %s", now.toString("G", culture));
  Println("Month:                   %s", now.toString("M", culture));
  Println("RFC1123:                 %s", now.toString("R", culture));
  Println("Sortable:                %s", now.toString("s", culture));
  Println("Year:                    %s", now.toString("Y", culture));
  Println();
}

// Produces the following output:
// Current date and time: 26/05/2006 10:04:57 AM
//
// Culture: English (United Kingdom)
//
// Short date:              26/05/2006
// Long date:               26 May 2006
// Short time:              10:04
// Long time:               10:04:57 AM
// General date short time: 26/05/2006 10:04
// General date long time:  26/05/2006 10:04:57 AM
// Month:                   26 May
// RFC1123:                 Fri, 26 May 2006 10:04:57 GMT
// Sortable:                2006-05-26T10:04:57
// Year:                    May 2006
//
// Culture: French (France)
//
// Short date:              26/05/2006
// Long date:               vendredi 26 mai 2006
// Short time:              10:04
// Long time:               10:04:57
// General date short time: 26/05/2006 10:04
// General date long time:  26/05/2006 10:04:57
// Month:                   26 mai
// RFC1123:                 ven., 26 mai 2006 10:04:57 GMT
// Sortable:                2006-05-26T10:04:57
// Year:                    mai 2006
immutable(char)[] positiveNumberFormat [package, manifest]
template charTerm(T) [package]
char[] longToString(char[] buffer, long value, int digits, const(char)[] negativeSign)
char[] longToHexString(char[] buffer, ulong value, int digits, char format)
char[] longToBinString(char[] buffer, ulong value, int digits)
char parseFormatSpecifier(const(char)[] format, out int length)
char[] formatInteger(char[] output, long value, const(char)[] format, NumberFormat nf)
void formatGeneral(ref Number number, ref Result target, int length, char format, NumberFormat nf)
void formatNumber(ref Number number, ref Result target, int length, NumberFormat nf)
void formatCurrency(ref Number number, ref Result target, int length, NumberFormat nf)
void formatFixed(ref Number number, ref Result target, int length, const(int)[] groupSizes, const(char)[] decimalSeparator, const(char)[] groupSeparator)
char[] toString(ref Number number, ref Result result, char format, int length, NumberFormat nf)