toExternal

Summary

Constructs a new external Date object with the value of the internal Date object.

Usage

public override external toExternal()

Returns

A new external Date object with the same date and time.

Description

Constructs a new external Date object with the value of the internal Date object.

Examples

Basic Usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import System;
 
external mysql = { query: function(q, a) { Console.log(q, a); } };
 
// Constrain type arguments to only classes that can convert to 'external'
interface ICommand<T: IExportable>
{
    void execute(...T args);
}
 
class UpdateLastLogin : ICommand<Date>
{
    final void execute(...Date args) {
        auto d = (Date) args[0];
        mysql.query("UPDATE `users` SET `last_login` = ? WHERE `id` = 1;", d.toExternal());
    }
}
 
auto updateLastLoginCommand = new UpdateLastLogin();
updateLastLoginCommand.execute(new Date());

Share

HTML | BBCode | Direct Link