Adding drupal node containing date in drupal-ios-sdk - ios

I am developing an iOS app that needs to create drupal nodes. I am using drupal-ios-sdk to create the nodes. It works fine sending strings to text fields in drupal but the node also needs to contain a date field. When I convert and format the NSDate to a string and put it in a dictionary and send like a text field I get an error from the drupal services module indicating that the date is in the wrong format. What is the correct format or where would I find some documentation?

Here is the best way to find it.
Create a node on your Drupal site first and check the database column for your date field. Then send the date value in the date value in the same format. Also, if you are using date module -- that's obvious, you can convert the string using some date function from the date module.

Related

Google Sheet-Date validation in specific format

how to use specific date formats in data validation in Google Sheets.
I set this date format in google sheet dd-mmm-yyyy (09-Jan-2023) but the user enters a different date format in the sheet so im want to use data validation for this the user must enter data in specific format dd-mmm-yyyy
i want that when user enter data in different format its auto rejects entry.
try:
=REGEXMATCH(A1&""; "\d{2}-.{3}-\d{4}")
or:
=REGEXMATCH(A1; "\d{2}-.[A-z]{3}-\d{4}")
If you previously set the date format in the range you want, then no matter in which way the date is inserted then it will be displayed as you wish. Specially with mmm format you'll be always at risk that they can mess with how the month is supposed to be written, I think it's preferably for them to insert the number and you choose how it is displayed

How do I convert a string to timestamp format in Data Refinery from Watson Studio?

I have a csv file that has a timestamp column but it shows up as a String type since I uploaded it locally to the project in Watson Studio. Can Data Refinery convert that string column into actual Timestamp type format?
You can use the Convert Type operation and select the format of timestamp that matches your data. It's not limited to a specific timestamp format...there are different formats you can choose from. For example:

Ion DateTime also sends DateTime as UTC (Z)

My Ionic 3 app uses the ion DateTime field where the user inputs a date.
<ion-datetime displayFormat="DD/MM/YYYY HH:mm" [(ngModel)]="scheduled_at"></ion-datetime>
This gets then send to my Rails 5 API. The string that arrives at my API endpoint looks like this:
"scheduled_at"=>"2018-06-14T23:33:42.939Z"
I read that the Z indicates UTC (https://robots.thoughtbot.com/its-about-time-zones). The issue is that the timezone the user enters is not in ZTC but in 'America/Sao_Paulo', so when I parse the string to a DateTime object in Rails and store it to the DB it will always be wrong.
Is there any way to tell the ion DateTime the correct timezone?
Maybe, there is no way to do that. moment.js is an alternative.
In ionic datatime documentation,
Advanced Datetime Validation and Manipulation
The datetime picker provides the simplicity of selecting an exact
format, and persists the datetime values as a string using the
standardized ISO 8601 datetime format. However, it's important to note
that ion-datetime does not attempt to solve all situtations when
validating and manipulating datetime values. If datetime values need
to be parsed from a certain format, or manipulated (such as adding 5
days to a date, subtracting 30 minutes, etc.), or even formatting data
to a specific locale, then we highly recommend using moment.js to
"Parse, validate, manipulate, and display dates in JavaScript".
Moment.js has quickly become our goto standard when dealing with
datetimes within JavaScript, but Ionic does not prepackage this
dependency since most apps will not require it, and its locale
configuration should be decided by the end-developer.
Try to use toLocaleString() string function of Date
myDate: String = new Date().toLocaleString();

Dygraphs timestamp with timezone

I know there was a lot of discussion about datetime parsing in dygraphs and problems with Javascript. But still, I have a problem how to correctly pass datetime.
I'm using dygraph to show data (points with 5 seconds interval) and it's crucial to have correct datetime. But if I pass datetime as timestamp (1401580800) or as ISO 8601 (2014-06-01T00:00:00+00:00), I always get datetime modified to my local time.
My question is, how to correctly pass the datetime to dygraph so datetime doesn't change?
Dygraphs use Javascript Dates, which display according to your local timezone (unfortunately, there's no way to display them using an arbitrary timezone).
One solution is to modify the data - I've encountered a similar problem in my own work, and I made a small helper function to make fake Javascript UTC dates (basically ending up with a Javascript date that's actually the wrong time but shows up looking correct when displayed in local time). This worked for my application, which used moments (http://momentjs.com/) to represent dates everywhere unless required by some other library to use Javascript's Dates.
Another (probably more correct) solution is to modify Dygraph's functions to display the right things, as demonstrated in the answer to this post: Dygraph showing dates in an arbitrary Timezone
The JavaScript Date object will always use the local time of the computer it's running on. If you don't want that behavior, you'll need to use something else. Consider building a pre-formatted string using something like moment.js and then just pass the string to dygraphs instead of the date.

change date format in sqlite

Change this date format which is in sqlite db 12/10/11 to 12-10-11 (mm-dd-yy) I am unable to do so .I am a noob in sqlite and have to parse this value SELECT strftime('%d-%m-%Y',Date) from report but I am getting null as sqlite db excepts value in mm-dd-yy so How do I convert format 12/10/11 to 12-10-11 (mm-dd-yy) .Thanks in advance .Really appreciate the help.
The short answer:
If you have a text string stored as "12/10/11" that you want reported as "12-10-11", you should use the replace(X,Y,Z) function, to replace occurrences of Y in X with Z. Thus:
SELECT replace('12/24/11','/','-');
will return:
12-10-11
The long answer:
First, dates do not actually exist as a proper datatype in SQLite. They're stored as either TEXT, REAL, or INTEGER values. See date and time datatype in SQLite. So it depends upon how your date was stored in the database.
Second, you seem to be implying that you stored the date in a "mm/dd/yy" format. That's not a valid/useful TEXT format to be storing date/time values (as the date cannot be sorted, cannot used in "greater than" and "less than" operations, cannot be used in SQLite date functions, etc.). You really want to store datetime values in one of the formats listed in the "Time strings" section of the date and time functions document.
So, generally you should store your date/time values in one of those formats, use NSDateFormatter to convert that to a NSDate when you retrieve it from the database. And when you want to display the date value in your app, use whatever format you want for output.
But, if you don't care that the dates are stored as text strings and are not effectively usable as dates in SQLite, then just treat it as a plain old TEXT string and use TEXT functions, such as replace(X,Y,Z) to replace occurrences of "/" with "-", as outlined above.

Resources