License:
Version:
Author:
Parameters:
format | A _format string. |
formatService | An IFormatService that provides culture-specific formatting information. |
Returns:
Remarks:
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 |